[Bug c/65842] New: combine is overly cautious when operating on side effect operands references
zhongyunde at huawei dot com
gcc-bugzilla@gcc.gnu.org
Wed Apr 22 05:38:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65842
Bug ID: 65842
Summary: combine is overly cautious when operating on side
effect operands references
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: zhongyunde at huawei dot com
Created attachment 35382
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35382&action=edit
float32 is a custom define type, so default gcc can't compile is directly
this bug is discovered on gcc 4.7.0, but gcc 4.8/4.9 still have such bug.
during the combine:
first try_combine the insn 15 and insn 17, we can get the value of reg 143 is
zero.
then try_combine the insn 17, insn 43 and insn 44, we can get the value of reg
191 is zero. But the insn 43 has side effect, so it bring runtime fail after is
is deleted here.
=========================================
(insn 15 14 17 2 (set (reg:SI 142)
(and:SI (reg:SI 123 [ D.3491 ])
(const_int 1 [0x1]))) 30 {andsi3}
(expr_list:REG_DEAD (reg:SI 123 [ D.3491 ])
(nil)))
(insn 17 15 21 2 (set (reg:SI 143)
(ashiftrt:SI (reg:SI 142)
(const_int 31 [0x1f]))) 42 {ashrsi3_internal}
(nil))
=================================================
(insn 43 88 44 2 (set (reg:SI 165 [ g_123+4 ])
(mem/c:SI (pre_modify:SI (reg/f:SI 164)
(plus:SI (reg/f:SI 164)
(const_int -12 [0xfffffff4]))) [4 g_123+4 S4 A32]))
test.c:61 48 {movsi_internal}
(expr_list:REG_INC (reg/f:SI 164)
(nil)))
(insn 44 43 51 2 (set (reg:SI 191 [ g_123$6+4 ])
(and:SI (reg:SI 165 [ g_123+4 ])
(reg:SI 143))) test.c:61 30 {andsi3}
(expr_list:REG_DEAD (reg:SI 165 [ g_123+4 ])
(nil)))
related code in gcc is the function simplify_and_const_int_1:
/* If we don't have any bits left, return zero. */
if (constop == 0)
return const0_rtx;
More information about the Gcc-bugs
mailing list