From: Jakub Jelinek Date: Tue, 25 Mar 2014 09:27:54 +0000 (+0100) Subject: cselib.c (cselib_hash_rtx): Perform addition in unsigned type to avoid signed integer... X-Git-Tag: releases/gcc-4.9.0~320 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8acccddfd67f1a0c6c4716700e188b1d0f1a148;p=thirdparty%2Fgcc.git cselib.c (cselib_hash_rtx): Perform addition in unsigned type to avoid signed integer overflow. * cselib.c (cselib_hash_rtx): Perform addition in unsigned type to avoid signed integer overflow. * explow.c (plus_constant): Likewise. From-SVN: r208804 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95e46dcf7f6c..8ba19f5617e3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-03-25 Jakub Jelinek + + * 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 * doc/generic.texi: Correct typos. diff --git a/gcc/cselib.c b/gcc/cselib.c index 26bcbe077691..7918b2be869d 100644 --- a/gcc/cselib.c +++ b/gcc/cselib.c @@ -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: diff --git a/gcc/explow.c b/gcc/explow.c index f4df9df42387..4e2f70448fbd 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -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: {