[PATCH] Fix undefined behaviour in cris port
authorJeff Law <law@redhat.com>
Sat, 26 Sep 2015 07:33:05 +0000 (01:33 -0600)
committerJeff Law <law@gcc.gnu.org>
Sat, 26 Sep 2015 07:33:05 +0000 (01:33 -0600)
[PATCH] Fix undefined behaviour in cris port
* config/cris/cris.md (asrandb): Fix left shift undefined
behaviour.
(asrandw): Likewise.

From-SVN: r228163

gcc/ChangeLog
gcc/config/cris/cris.md

index 910fd4f3d7ad8ede836f4965497abef29f3ea0c8..98c1bd9c913e6e82a84ead36fa5b22870d15080b 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-26  Jeff Law  <law@redhat.com>
+
+       * config/cris/cris.md (asrandb): Fix left shift undefined
+       behaviour.
+       (asrandw): Likewise.
+
 2015-09-25  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/61578
index 3c2409bd1d82965a153aee40f09a2315c4d58829..b90d6b1b3a154f4e005d5a75a6bd546785af6969 100644 (file)
    && INTVAL (operands[1]) > 23
    /* Check that the and-operation enables us to use logical-shift.  */
    && (INTVAL (operands[2])
-         & ((HOST_WIDE_INT) -1 << (32 - INTVAL (operands[1])))) == 0"
+       & ((HOST_WIDE_INT) (HOST_WIDE_INT_M1U
+                          << (32 - INTVAL (operands[1]))))) == 0"
   [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1)))
    (set (match_dup 3) (and:QI (match_dup 3) (match_dup 4)))]
   ;; FIXME: CC0 is valid except for the M bit.
    && INTVAL (operands[1]) > 15
    /* Check that the and-operation enables us to use logical-shift.  */
    && (INTVAL (operands[2])
-       & ((HOST_WIDE_INT) -1 << (32 - INTVAL (operands[1])))) == 0"
+       & ((HOST_WIDE_INT) (HOST_WIDE_INT_M1U
+                          << (32 - INTVAL (operands[1]))))) == 0"
   [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 1)))
    (set (match_dup 3) (and:HI (match_dup 3) (match_dup 4)))]
   ;; FIXME: CC0 is valid except for the M bit.