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 4d15a7308dbc8adfaaabaaf5e48201d67f2b0a37..b90cbc6ffa21d20c18956c87cca13f5edbc72275 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 faafcb741f4121ad95faf2af455b10885627d841..b4294532296d477faa3a21ccc60d120cb7450568 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))