https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Bug ID: 104814
Summary: [10/11/12 Regression] ifcvt: Deleting live variable in
IF-CASE-2
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: stefansf at linux dot ibm.com
Target Milestone: ---
Target: s390x-*-*
Created attachment 52570
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52570&action=edit
dump ce2
short a = 0;
static long b = 0;
int c = 7;
char d = 0;
short *e = &a;
long f = 0;
unsigned long g (unsigned long h, long j) { return j == 0 ? h : h / j; }
int main (void) {
long k = f;
for (; c; --c) {
for (int i = 0; i < 7; ++i)
;
long m = g (f, --b);
d = ((char)m | *e) <= 43165;
}
if (b != -7)
__builtin_abort ();
return 0;
}
Variable b should be decremented in each iteration of the outer loop and thus
equal -7 at the end.
After combine a load, decrement, and store insn exists:
(insn 13 12 14 3 (set (reg:DI 62 [ b_lsm.16 ])
(mem/c:DI (const:DI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags
0x182])
(const_int 8 [0x8]))) [1 b+0 S8 A64])) 1469 {*movdi_64}
(nil))
(jump_insn 40 39 46 6 (parallel [
(set (pc)
(if_then_else (ne (reg:DI 62 [ b_lsm.16 ])
(const_int 1 [0x1]))
(label_ref 38)
(pc)))
(set (reg:DI 62 [ b_lsm.16 ])
(plus:DI (reg:DI 62 [ b_lsm.16 ])
(const_int -1 [0xffffffffffffffff])))
(clobber (scratch:DI))
(clobber (reg:CC 33 %cc))
]) "t.c":8:63 2164 {doloop_di}
(expr_list:REG_UNUSED (reg:CC 33 %cc)
(int_list:REG_BR_PROB 536870916 (nil)))
-> 38)
(insn 48 47 49 7 (set (mem/c:DI (const:DI (plus:DI (symbol_ref:DI
("*.LANCHOR0") [flags 0x182])
(const_int 8 [0x8]))) [1 b+0 S8 A64])
(reg:DI 62 [ b_lsm.16 ])) 1469 {*movdi_64}
(expr_list:REG_DEAD (reg:DI 62 [ b_lsm.16 ])
(nil)))
Pass ce2 deletes jump insn 40 including the decrement of variable b:
IF-CASE-2 found, start 6, else 4
deleting insn with uid = 40.
deleting block 4
Conversion succeeded on pass 1.
Thus variable b equals 0 in the end.