Fix rtl-optimization/78596 - combine.c:12561:14: runtime error: left shift of negativ...
authorMarkus Trippelsdorf <markus@trippelsdorf.de>
Thu, 1 Dec 2016 14:04:13 +0000 (14:04 +0000)
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>
Thu, 1 Dec 2016 14:04:13 +0000 (14:04 +0000)
PR rtl-optimization/78596
* combine.c (simplify_comparison): Cast to unsigned to avoid
left shifting of negative value.

From-SVN: r243111

gcc/ChangeLog
gcc/combine.c

index 4d15a73..b90cbc6 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-01  Markus Trippelsdorf  <markus@trippelsdorf.de>
+
+       PR rtl-optimization/78596
+       * combine.c (simplify_comparison): Cast to unsigned to avoid
+       left shifting of negative value.
+
 2016-12-01  Matthias Klose  <doko@ubuntu.com>
 
        * doc/install.texi: Don't use pkg-config to check for bdw-gc.
index faafcb7..b429453 100644 (file)
@@ -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))