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. Jeff
commit 61e179b1b363454926504fac13b554ad7f1b0f72 Author: Jeff Law <j...@ventanamicro.com> Date: Sat Aug 17 15:10:38 2024 -0600 [committed] Avoid right shifting signed value on ext-dce.cc 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. diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc index 97a66427118..017e2de000d 100644 --- a/gcc/ext-dce.cc +++ b/gcc/ext-dce.cc @@ -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;