epicsCalc bit-wise operators on aarch64

Bug #1838792 reported by Andrew Johnson on 2019-08-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Status tracked in 7.0
3.15
Undecided
Unassigned
7.0
Undecided
Unassigned

Bug Description

Kiman Ha has reported failures of epicsCalcTest running on a 64-bit ARM system with a quad Cortex-A53 core:

OS : Debian GNU/Linux 10.0
Core Architecture : aarch64
Kernel : 4.19.0
gcc version 8.3.0 (Debian 8.3.0-6)

The failures are identical on Base 3.16.2, 7.0.2.2 and 7.0.3 (no other tests fail):

> not ok 225 - ~~5
> # Expected result is 5, actually got -1
> Integer 5 (0x5)
> BIT_NOT
> BIT_NOT
> not ok 511 - 2 | 1 - 3
> # Expected result is -2, actually got 2
> Integer 2 (0x2)
> Integer 1 (0x1)
> Integer 3 (0x3)
> SUB
> BIT_OR
> not ok 522 - 3 AND -2
> # Expected result is 2, actually got 0
> Integer 3 (0x3)
> Integer 2 (0x2)
> UNARY_NEG
> BIT_AND
> not ok 578 - 0xaaaaaaaa AND 0xffff0000
> # Expected result is 0xaaaa0000 (2863267840), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> Integer -65536 (0xffff0000)
> BIT_AND
> not ok 579 - 0xaaaaaaaa OR 0xffff0000
> # Expected result is 0xffffaaaa (4294945450), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> Integer -65536 (0xffff0000)
> BIT_OR
> not ok 580 - 0xaaaaaaaa XOR 0xffff0000
> # Expected result is 0x5555aaaa (1431677610), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> Integer -65536 (0xffff0000)
> BIT_EXCL_OR
> not ok 581 - ~0xaaaaaaaa
> # Expected result is 0x55555555 (1431655765), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> BIT_NOT
> not ok 582 - ~~0xaaaaaaaa
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> BIT_NOT
> BIT_NOT
> not ok 583 - 0xaaaaaaaa >> 8
> # Expected result is 0xffaaaaaa (4289374890), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> Integer 8 (0x8)
> RIGHT_SHIFT
> not ok 584 - 0xaaaaaaaa << 8
> # Expected result is 0xaaaaaa00 (2863311360), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> Integer 8 (0x8)
> LEFT_SHIFT
> not ok 585 - a:=0xaaaaaaaa; b:=0xffff0000; a AND b
> # Expected result is 0xaaaa0000 (2863267840), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> Integer -65536 (0xffff0000)
> STORE_B
> FETCH_A
> FETCH_B
> BIT_AND
> not ok 586 - a:=0xaaaaaaaa; b:=0xffff0000; a OR b
> # Expected result is 0xffffaaaa (4294945450), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> Integer -65536 (0xffff0000)
> STORE_B
> FETCH_A
> FETCH_B
> BIT_OR
> not ok 587 - a:=0xaaaaaaaa; b:=0xffff0000; a XOR b
> # Expected result is 0x5555aaaa (1431677610), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> Integer -65536 (0xffff0000)
> STORE_B
> FETCH_A
> FETCH_B
> BIT_EXCL_OR
> not ok 588 - a:=0xaaaaaaaa; ~a
> # Expected result is 0x55555555 (1431655765), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> FETCH_A
> BIT_NOT
> not ok 589 - a:=0xaaaaaaaa; ~~a
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> FETCH_A
> BIT_NOT
> BIT_NOT
> not ok 590 - a:=0xaaaaaaaa; a >> 8
> # Expected result is 0xffaaaaaa (4289374890), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> FETCH_A
> Integer 8 (0x8)
> RIGHT_SHIFT
> not ok 591 - a:=0xaaaaaaaa; a << 8
> # Expected result is 0xaaaaaa00 (2863311360), actually got 0x0 (0)
> Integer -1431655766 (0xaaaaaaaa)
> STORE_A
> FETCH_A
> Integer 8 (0x8)
> LEFT_SHIFT
> not ok 592 - -1431655766.1 OR 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Integer 0 (0x0)
> BIT_OR
> not ok 593 - 2863311530.1 OR 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Integer 0 (0x0)
> BIT_OR
> not ok 594 - 0 OR -1431655766.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer 0 (0x0)
> Double 1.43166e+09
> UNARY_NEG
> BIT_OR
> not ok 595 - 0 OR 2863311530.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer 0 (0x0)
> Double 2.86331e+09
> BIT_OR
> not ok 596 - -1431655766.1 XOR 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Integer 0 (0x0)
> BIT_EXCL_OR
> not ok 597 - 2863311530.1 XOR 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Integer 0 (0x0)
> BIT_EXCL_OR
> not ok 598 - 0 XOR -1431655766.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer 0 (0x0)
> Double 1.43166e+09
> UNARY_NEG
> BIT_EXCL_OR
> not ok 599 - 0 XOR 2863311530.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer 0 (0x0)
> Double 2.86331e+09
> BIT_EXCL_OR
> not ok 600 - -1431655766.1 AND 0xffffffff
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Integer -1 (0xffffffff)
> BIT_AND
> not ok 601 - 2863311530.1 AND 0xffffffff
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Integer -1 (0xffffffff)
> BIT_AND
> not ok 602 - 0xffffffff AND -1431655766.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer -1 (0xffffffff)
> Double 1.43166e+09
> UNARY_NEG
> BIT_AND
> not ok 603 - 0xffffffff AND 2863311530.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Integer -1 (0xffffffff)
> Double 2.86331e+09
> BIT_AND
> not ok 604 - ~ -1431655766.1
> # Expected result is 0x55555555 (1431655765), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> BIT_NOT
> not ok 606 - -1431655766.1 >> 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Integer 0 (0x0)
> RIGHT_SHIFT
> not ok 607 - 2863311530.1 >> 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Integer 0 (0x0)
> RIGHT_SHIFT
> not ok 608 - -1431655766.1 >> 0.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Double 0.1
> RIGHT_SHIFT
> not ok 609 - 2863311530.1 >> 0.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Double 0.1
> RIGHT_SHIFT
> not ok 610 - -1431655766.1 << 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Integer 0 (0x0)
> LEFT_SHIFT
> not ok 611 - 2863311530.1 << 0
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Integer 0 (0x0)
> LEFT_SHIFT
> not ok 612 - -1431655766.1 << 0.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 1.43166e+09
> UNARY_NEG
> Double 0.1
> LEFT_SHIFT
> not ok 613 - 2863311530.1 << 0.1
> # Expected result is 0xaaaaaaaa (2863311530), actually got 0x0 (0)
> Double 2.86331e+09
> Double 0.1
> LEFT_SHIFT

Related branches

On Debian 10 amd64 all tests pass (same compiler version) but a quick test on my Raspberry Pi 3+ running a 32 bit Raspbian confirms this problem. In case of the first failing test, the direct evaluation of the expression "~~5" by the compiler is correct - it is in fact calcPerform() that ends up with a wrong result when performing bitwise operations. The problem also occurs with -O0.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers