]> git.ipfire.org Git - thirdparty/gcc.git/commit
combine: Don't fold away side-effects in simplify_and_const_int_1 [PR99830]
authorJakub Jelinek <jakub@redhat.com>
Mon, 12 Apr 2021 23:00:48 +0000 (01:00 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 22 Apr 2021 14:58:32 +0000 (16:58 +0200)
commit10ea9b06ec6c6788e14f5c5e693b6c7e34e28b89
treecce6e59b59afd1d2b059508fe19f2085b074065b
parentd3a2bb8009f50acd90637f9407f5c704b318f8f4
combine: Don't fold away side-effects in simplify_and_const_int_1 [PR99830]

Here is an alternate patch for the PR99830 bug.
As discussed on IRC and in the PR, the reason why a (clobber:TI (const_int 0))
has been propagated into the debug insns is that it got optimized away
during simplification from the i3 instruction pattern.

And that happened because
simplify_and_const_int_1 (SImode, varop, 255)
with varop of
(ashift:SI (subreg:SI (and:TI (clobber:TI (const_int 0 [0]))
                              (const_int 255 [0xff])) 0)
           (const_int 16 [0x10]))
was called and through nonzero_bits determined that (whatever << 16) & 255
is const0_rtx.
It is, but if there are side-effects in varop and such clobbers are
considered as such, we shouldn't optimize those away.

2021-04-13  Jakub Jelinek  <jakub@redhat.com>

PR debug/99830
* combine.c (simplify_and_const_int_1): Don't optimize varop
away if it has side-effects.

* gcc.dg/pr99830.c: New test.

(cherry picked from commit 4ac7483ede91fef7cfd548ff6e30e46eeb9d95ae)
gcc/combine.c
gcc/testsuite/gcc.dg/pr99830.c [new file with mode: 0644]