cselib.c (cselib_hash_rtx): Perform addition in unsigned type to avoid signed integer...
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Mar 2014 09:27:54 +0000 (10:27 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Mar 2014 09:27:54 +0000 (10:27 +0100)
* cselib.c (cselib_hash_rtx): Perform addition in unsigned
type to avoid signed integer overflow.
* explow.c (plus_constant): Likewise.

From-SVN: r208804

gcc/ChangeLog
gcc/cselib.c
gcc/explow.c

index 95e46dc..8ba19f5 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * cselib.c (cselib_hash_rtx): Perform addition in unsigned
+       type to avoid signed integer overflow.
+       * explow.c (plus_constant): Likewise.
+
 2014-03-25  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        * doc/generic.texi: Correct typos.
index 26bcbe0..7918b2b 100644 (file)
@@ -1137,7 +1137,7 @@ cselib_hash_rtx (rtx x, int create, enum machine_mode memmode)
       return hash ? hash : (unsigned int) ENTRY_VALUE;
 
     case CONST_INT:
-      hash += ((unsigned) CONST_INT << 7) + INTVAL (x);
+      hash += ((unsigned) CONST_INT << 7) + UINTVAL (x);
       return hash ? hash : (unsigned int) CONST_INT;
 
     case CONST_DOUBLE:
index f4df9df..4e2f704 100644 (file)
@@ -110,7 +110,7 @@ plus_constant (enum machine_mode mode, rtx x, HOST_WIDE_INT c)
          return immed_double_int_const (v, mode);
        }
 
-      return gen_int_mode (INTVAL (x) + c, mode);
+      return gen_int_mode (UINTVAL (x) + c, mode);
 
     case CONST_DOUBLE:
       {