diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-04-13 01:00:48 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-04-13 01:00:48 +0200 |
commit | 9c1c8ad8339d551ac91a7af5614f29b9a687189a (patch) | |
tree | 0451fabdd1ac65cf568ee89dad45e6fb40d31773 /gcc/combine.c | |
parent | eb49f7de9341cb464327234c3a673ce3ef642e01 (diff) | |
download | gcc-9c1c8ad8339d551ac91a7af5614f29b9a687189a.zip gcc-9c1c8ad8339d551ac91a7af5614f29b9a687189a.tar.gz gcc-9c1c8ad8339d551ac91a7af5614f29b9a687189a.tar.bz2 |
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.
Diffstat (limited to 'gcc/combine.c')
-rw-r--r-- | gcc/combine.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index 3294575..dffa3b0 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -10153,7 +10153,7 @@ simplify_and_const_int_1 (scalar_int_mode mode, rtx varop, constop &= nonzero; /* If we don't have any bits left, return zero. */ - if (constop == 0) + if (constop == 0 && !side_effects_p (varop)) return const0_rtx; /* If VAROP is a NEG of something known to be zero or 1 and CONSTOP is |