]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PR86438] compare-elim: cope with set of in_b
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Nov 2018 10:16:09 +0000 (10:16 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Nov 2018 10:16:09 +0000 (10:16 +0000)
commitf7d5c90578092c8ef42705f491f64429769216d1
treefca3caf0766d3151c362068508b4da0f0763b702
parent2a6c0337e4d6bc90cea3da4d5d7e2da3d5509c23
[PR86438] compare-elim: cope with set of in_b

When in_a resolves to a register set in the prev_clobber insn, we may
use the SET_SRC for the compare instead.  However, when in_b so
resolves, we proceed to use the reg with its earlier value.  When both
resolve to the same register and prev_clobber is an insn that modifies
the register, this arrangement may cause the compare to match (when it
shouldn't) and the elimination of the compare to incorrectly succeed.

(set (reg 1) (plus (reg 1) (const_int N)))
(set (reg 2) (reg 1))
(set (reg flags) (compare (reg 1) (reg 2)))

in_a: (reg 1)            --> (plus (reg 1) (const_int N))
in_b: (reg 2) -> (reg 1) -/> oops

(parallel [
 (set (reg flags) (compare (plus (reg 1) (const_int N))
                           (reg 1))) ;; should be (plus...)
 (set (reg 1) (plus (reg 1) (const_int N)))])
(set (reg 2) (reg 1))

This patch arranges for in_b to also undergo SET_SRC substitution
when appropriate, with a shortcut for when in_a and in_b are the same
rtx.

for  gcc/ChangeLog

PR rtl-optimization/86438
* compare-elim.c (try_eliminate_compare): Use SET_SRC instead
of in_b for the compare if in_b is SET_DEST.

for  gcc/testsuite/ChangeLog

PR rtl-optimization/86438
* gcc.dg/torture/pr86438.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265957 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/compare-elim.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr86438.c [new file with mode: 0644]