[Bug c/65842] combine is overly cautious when operating on side effect operands references

zhongyunde at huawei dot com gcc-bugzilla@gcc.gnu.org
Wed Apr 22 10:39:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65842

--- Comment #1 from vfdff <zhongyunde at huawei dot com> ---
(gdb) p debug_rtx (newpat)
(set (reg:SI 191 [ g_123$6+4 ])
    (and:SI (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])
        (const_int 0 [0])))

combined to

(gdb) p debug_rtx (i3)
(insn 44 43 51 2 (set (reg:SI 191 [ g_123$6+4 ])
        (const_int 0 [0])) test.c:61 30 {andsi3}
     (expr_list:REG_DEAD (reg:SI 165 [ g_123+4 ])


combine_simplify_rtx in combine pass call function simplify_binary_operation_1
and simplify_and_const_int_1 to simplify operands.
in simplify_binary_operation_1, it can be simplified as the condition
side_effects_p (op0). see detail as follow:

Breakpoint 1, simplify_binary_operation_1 (code=AND, mode=SImode,
op0=0xf7f89dd4, op1=0xf7e052b8, trueop0=0xf7f89dd4, trueop1=0xf7e052b8)
    at /net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/simplify-rtx.c:1933
1933      unsigned int width = GET_MODE_PRECISION (mode);
(gdb) p debug_rtx (op0)
(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])
$8 = void
(gdb) n
1938      switch (code)
(gdb) 
2732          if (trueop1 == CONST0_RTX (mode) && ! side_effects_p (op0))
(gdb)

while in simplify_and_const_int_1, it can be simplified as no simalar condition
side_effects_p (op0), so it may be the causation. 

(gdb) bt
#0  simplify_and_const_int_1 (mode=SImode, varop=0xf7f89dd4, constop=0) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:9468
#1  0x08a517d8 in simplify_and_const_int (x=0xf7f8b780, mode=SImode,
varop=0xf7f89dd4, constop=0) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:9578
#2  0x08a4aca4 in simplify_logical (x=0xf7f8b780) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:6726
#3  0x08a48cb5 in combine_simplify_rtx (x=0xf7f8b780, op0_mode=VOIDmode,
in_dest=0, in_cond=0) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:5989
#4  0x08a47370 in subst (x=0xf7f8b780, from=0xf7f43930, to=0xf7e052b8,
in_dest=0, in_cond=0, unique_copy=0) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:5314
#5  0x08a4714b in subst (x=0xf7f7c750, from=0xf7f43930, to=0xf7e052b8,
in_dest=0, in_cond=0, unique_copy=0) at
/net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:5250
#6  0x08a41a93 in try_combine (i3=0xf7f88384, i2=0xf7f88360, i1=0xf7e6af9c,
i0=0x0, new_direct_jump_p=0xffffcd14, last_combined_insn=0xf7f88384)
    at /net1/home/zhongyunde/6183_hcc/gcc/gcc-4.7.0/gcc/combine.c:3271
9501      constop &= nonzero;
(gdb) 
9504      if (constop == 0)



More information about the Gcc-bugs mailing list