[PATCH] Fix undefined behaviour in msp430 port
authorJeff Law <law@redhat.com>
Tue, 29 Sep 2015 16:25:21 +0000 (10:25 -0600)
committerJeff Law <law@gcc.gnu.org>
Tue, 29 Sep 2015 16:25:21 +0000 (10:25 -0600)
       * config/msp430/msp430.c (msp430_legitimate_constant): Fix undefined
        left shift behaviour.
        * config/msp430/constraints.md ('L' constraint): Similarly.
        ('Ys' constraint): Similarly.

From-SVN: r228251

gcc/ChangeLog
gcc/config/msp430/constraints.md
gcc/config/msp430/msp430.c

index 03f566c..1b9985a 100644 (file)
@@ -1,3 +1,10 @@
+2015-09-29  Jeff Law  <law@redhat.com>
+
+       * config/msp430/msp430.c (msp430_legitimate_constant): Fix undefined
+       left shift behaviour.
+       * config/msp430/constraints.md ('L' constraint): Similarly.
+       ('Ys' constraint): Similarly.
+
 2015-09-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/67170
index 30f944c..dfda152 100644 (file)
@@ -32,7 +32,7 @@
 (define_constraint "L"
   "Integer constant -1^20..1^19."
   (and (match_code "const_int")
-       (match_test "IN_RANGE (ival, -1 << 20, 1 << 19)")))
+       (match_test "IN_RANGE (ival, HOST_WIDE_INT_M1U << 20, 1 << 19)")))
 
 (define_constraint "M"
   "Integer constant 1-4."
@@ -77,7 +77,7 @@
        (and (match_code "plus" "0")
             (and (match_code "reg" "00")
                  (match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))"))
-                 (match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), -1 << 15, (1 << 15)-1)"))))
+                 (match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)"))))
        (match_code "reg" "0")
        )))
 
index d2308cb..ba8d862 100644 (file)
@@ -998,7 +998,7 @@ msp430_legitimate_constant (machine_mode mode, rtx x)
     /* GCC does not know the width of the PSImode, so make
        sure that it does not try to use a constant value that
        is out of range.  */
-    || (INTVAL (x) < (1 << 20) && INTVAL (x) >= (-1 << 20));
+    || (INTVAL (x) < (1 << 20) && INTVAL (x) >= (HOST_WIDE_INT)(HOST_WIDE_INT_M1U << 20));
 }
 
 \f