https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78437
Bug ID: 78437
Summary: [7 Regression]: Invalid sign-extend conversion in REE
pass
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
Created attachment 40092
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40092&action=edit
Preprocessed source
Attached testcase triggers invalid sign-extend conversion in REE pass.
The problem can be triggered with a crosscompiler to alpha-linux-gnu using:
~/gcc-build-alpha/gcc/cc1 -O2 -std=c11 -mcpu=ev67 -mexplicit-relocs
-fpreprocessed att.i
The _.split2 dump will have:
...
50: $22:QI=$8:QI
REG_EQUAL [`expected']
43: [$2:DI+low(`expected')]=$8:QI
51: $3:DI=sign_extend($22:QI)
...
this sequence is converted in REE pass:
Trying to eliminate extension:
(insn 51 43 53 7 (set (reg:DI 3 $3 [orig:110 expected ] [110])
(sign_extend:DI (reg:QI 22 $22 [orig:111 expected ] [111]))) "att.c":27
70 {*extendqidi2_bwx}
(nil))
Tentatively merged extension with definition (copy needed):
(insn 50 52 43 7 (set (reg:DI 3 $3)
(sign_extend:DI (reg:QI 8 $8 [106]))) "att.c":27 -1
(nil))
deferring rescan insn with uid = 50.
All merges were successful.
Eliminated the extension.
...
50: $3:DI=sign_extend($8:QI)
141: $22:DI=$3:DI
43: [$2:DI+low(`expected')]=$8:QI
...
However, $22 is used later in a DImode in:
(insn 63 62 65 8 (parallel [
(set (reg:DI 7 $7 [119])
(unspec_volatile:DI [
(const_int 0 [0])
] UNSPECV_CMPXCHG))
(set (reg:DI 3 $3 [123])
(zero_extend:DI (unspec_volatile:QI [
(const_int 0 [0])
] UNSPECV_CMPXCHG)))
(set (mem/v:QI (reg/f:DI 1 $1 [138]) [-1 S1 A8])
(unspec_volatile:QI [
(mem/v:QI (reg/f:DI 1 $1 [138]) [-1 S1 A8])
(reg:DI 22 $22 [orig:111 expected ] [111])
(const_int 0 [0])
(reg:DI 4 $4 [90])
(const_int 0 [0])
(const_int 3 [0x3])
(const_int 2 [0x2])
] UNSPECV_CMPXCHG))
(clobber (reg:DI 23 $23))
]) "att.c":30 304 {atomic_compare_and_swapqi_1}
(nil))
so the converted sequence is *not* equal as long as $22 is concerned.