]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[committed] Avoid right shifting signed value on ext-dce.cc
authorJeff Law <jlaw@ventanamicro.com>
Sat, 17 Aug 2024 21:10:38 +0000 (15:10 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 17 Aug 2024 21:10:38 +0000 (15:10 -0600)
This is analogous to a prior patch to ext-dce which fixes propagation of sign
bits, but this time for the saturating variants.  I'd held off fixing those
because I wanted the time to look at that code (since we don't have a testcase
for it as far as I know).

Not surprisingly, putting an abort on that path and running an x86 bootstrap
and testsuite run, it never triggers.  Of course not a lot of code tries to do
saturating shifts.

Anyway, bootstrapped and regression tested on x86_64.  Pushing to the trunk.

Thanks for everyone's patience.

gcc/
* ext-dce.cc (carry_backpropagate): Cast mask to HOST_WIDE_INT before
shifting.

gcc/ext-dce.cc

index 97a664271183bb08849cccff000352947b1b686a..017e2de000dfa14aa3b2b135e4143b6fa6d04402 100644 (file)
@@ -556,7 +556,7 @@ carry_backpropagate (unsigned HOST_WIDE_INT mask, enum rtx_code code, rtx x)
                             >> (INTVAL (XEXP (x, 1))
                                 + (XEXP (x, 1) != const0_rtx
                                    && code == SS_ASHIFT))))
-                 | (mask >> INTVAL (XEXP (x, 1))));
+                 | ((HOST_WIDE_INT)mask >> INTVAL (XEXP (x, 1))));
        }
       return mmask;