combine: Don't call extract_left_shift with count < 0 (PR67483)
authorSegher Boessenkool <segher@kernel.crashing.org>
Fri, 13 May 2016 23:01:40 +0000 (01:01 +0200)
committerSegher Boessenkool <segher@gcc.gnu.org>
Fri, 13 May 2016 23:01:40 +0000 (01:01 +0200)
If the compiled program does a shift by a negative amount, combine will
happily work with that, but it shouldn't then do an undefined operation
in GCC itself.  This patch fixes the first case mentioned in the bug
report (I haven't been able to reproduce the second case, on trunk at
least).

PR rtl-optimization/67483
* combine.c (make_compound_operation): Don't call extract_left_shift
with negative shift amounts.

From-SVN: r236232

gcc/ChangeLog
gcc/combine.c

index 5133b37024bd0b34133a00960b9b15040379ce3e..7178c7c849a78c4e1a2b3d5566fded440e09d7bf 100644 (file)
@@ -1,3 +1,9 @@
+2016-05-13  Segher Boessenkool  <segher@kernel.crashing.org>
+
+       PR rtl-optimization/67483
+       * combine.c (make_compound_operation): Don't call extract_left_shift
+       with negative shift amounts.
+
 2016-05-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/71071
index 3554f515582c3e49d20be7fa91e03207ffacfb7b..cd864ccb0d4f203aad27f267bbd2e1b1b2981d21 100644 (file)
@@ -8037,6 +8037,7 @@ make_compound_operation (rtx x, enum rtx_code in_code)
          && ! (GET_CODE (lhs) == SUBREG
                && (OBJECT_P (SUBREG_REG (lhs))))
          && CONST_INT_P (rhs)
+         && INTVAL (rhs) >= 0
          && INTVAL (rhs) < HOST_BITS_PER_WIDE_INT
          && INTVAL (rhs) < mode_width
          && (new_rtx = extract_left_shift (lhs, INTVAL (rhs))) != 0)