Fix combiner bug with 4th insn

Eric Botcazou ebotcazou@adacore.com
Sat Mar 23 11:06:00 GMT 2013


We ran into a combiner bug on the 4.7 branch for ARM (LE/soft-float/Thumb):

FAIL: gcc.c-torture/execute/930718-1.c compilation,  -O2  (internal compiler 
error)

It's a bug introduced by the handling of the 4th instruction:

(insn 8 68 9 2 (set (reg/v:SI 139 [ foo ])
        (const_int 1 [0x1])) 930718-1.c:11:16 714 {*thumb2_movsi_insn}
     (nil))

(insn 9 8 11 2 (set (zero_extract:SI (reg/v:SI 139 [ foo ])
            (const_int 1 [0x1])
            (const_int 1 [0x1]))
        (const_int 0 [0])) 930718-1.c:11:16 84 {insv_zero}
     (nil))

(insn 14 13 67 2 (set (reg:CC_NOOV 24 cc)
        (compare:CC_NOOV (zero_extract:SI (reg/v:SI 139 [ foo ])
                (const_int 2 [0x2])
                (const_int 0 [0]))
            (const_int 0 [0]))) 930718-1.c:11:16 79 
{*zeroextractsi_compare0_scratch}
     (expr_list:REG_DEAD (reg/v:SI 139 [ foo ])
        (nil)))

(insn 21 19 22 2 (set (reg:SI 147)
        (if_then_else:SI (eq:SI (reg:CC_NOOV 24 cc)
                (const_int 0 [0]))
            (const_int 2 [0x2])
            (const_int 0 [0]))) 930718-1.c:31:30 721 {*thumb2_movsicc_insn}
     (expr_list:REG_DEAD (reg:CC 24 cc)
        (nil)))

The combiner first thinks that it needs to keep the set in insn 8, only to 
discover later that the REG_DEAD note in insn 14 kills it, which confuses the 
code putting back the notes at the end.

Fixed thusly.  The patch also does a bit of refactoring in the block of code 
putting back notes at the end.

Tested on x86_64-suse-linux, applied on the mainline.


2013-03-23  Eric Botcazou  <ebotcazou@adacore.com>

	* combine.c (try_combine): Adjust comment.  Do not add the set of
	insn #0 if the destination indirectly is set or dies in insn #2.
	Tidy up code to distribute a new note.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 2284 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130323/b5a45505/attachment.bin>


More information about the Gcc-patches mailing list