Hopefully one last patch for UB in combine.c:

 combine.c:12561:14: runtime error: left shift of negative value -9

Fixed by casting to unsigned, as usual.

Tested on ppc64le.
OK for trunk?

Thanks.

        PR rtl-optimization/78596
        * combine.c (simplify_comparison): Cast to unsigned to avoid
        left shifting of negative value.

diff --git a/gcc/combine.c b/gcc/combine.c
index faafcb741f41..e32c02b06810 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -12561,7 +12561,8 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx 
*pop1)
                  if (GET_CODE (op0) == LSHIFTRT)
                    code = unsigned_condition (code);

-                 const_op <<= INTVAL (XEXP (op0, 1));
+                 const_op = (unsigned HOST_WIDE_INT) const_op
+                             << INTVAL (XEXP (op0, 1));
                  if (low_bits != 0
                      && (code == GT || code == GTU
                          || code == LE || code == LEU))

--
Markus

Reply via email to