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

--- Comment #5 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Author: segher
Date: Fri Sep  1 16:54:53 2017
New Revision: 251607

URL: https://gcc.gnu.org/viewcvs?rev=251607&root=gcc&view=rev
Log:
combine: Fix for PR82024

With the testcase in the PR, with all the command line options mentioned
there, a (comparison) instruction becomes dead in fwprop1 but is not
deleted until all the way in rtl_dce.

Before combine this insn look like:

20: flags:CC=cmp(r106:DI,0xffffffffffffffff)
      REG_DEAD r106:DI
      REG_UNUSED flags:CC
      REG_EQUAL cmp(0,0xffffffffffffffff)

(note the only output is unused).

Combining some earlier insns gives

13: r106:DI=0
14: r105:DI=r101:DI+r103:DI

14+13+20 then gives

(parallel [
        (set (reg:CC 17 flags)
            (compare:CC (const_int 0 [0])
                (const_int -1 [0xffffffffffffffff])))
        (set (reg:DI 105)
            (plus:DI (reg/v:DI 101 [ e ])
                (reg:DI 103)))
    ])

which doesn't match; but the set of flags is dead, so combine makes the
set of r105 the whole new instruction, which it then places at i3.  But
that is wrong, because r105 is used after i2 but before i3!  We forget
to check for that in this case.

This patch fixes it.


        PR rtl-optimization/82024
        * combine.c (try_combine): If the combination result is a PARALLEL,
        and we only need to retain the SET in there that would be placed
        at I2, check that we can place that at I3 instead, before doing so.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c

Reply via email to