aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarkus Trippelsdorf <markus@trippelsdorf.de>2014-11-19 16:28:23 +0000
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>2014-11-19 16:28:23 +0000
commit2d302f47a023715afb272eb119b72a36d3233388 (patch)
treee63c30e7a25cea9e0b8e18a0c21fc63fc5a9d01f /gcc
parent31b0bf51d6fc543057aa55f8678d17f866c8b864 (diff)
downloadgcc-2d302f47a023715afb272eb119b72a36d3233388.zip
gcc-2d302f47a023715afb272eb119b72a36d3233388.tar.gz
gcc-2d302f47a023715afb272eb119b72a36d3233388.tar.bz2
rs6000: Fix signed integer overflows
bootstrap-ubsan on gcc112 shows a couple of signed integer overflows: config/rs6000/constraints.md:143:33: runtime error: signed integer overflow: 9223372036854775807 + 32768 cannot be represented in type 'long int' config/rs6000/predicates.md:396:22: runtime error: signed integer overflow: 9223372036854775807 + 2147516416 cannot be represented in type 'long int' config/rs6000/predicates.md:856:11: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:862:12: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:865:11: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:868:12: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:914:11: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:917:12: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:940:11: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:946:12: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:949:11: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself config/rs6000/predicates.md:955:12: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself 2014-11-19 Markus Trippelsdorf <markus@trippelsdorf.de> * config/rs6000/constraints.md: Avoid signed integer overflows. * config/rs6000/predicates.md: Likewise. From-SVN: r217785
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/rs6000/constraints.md2
-rw-r--r--gcc/config/rs6000/predicates.md12
3 files changed, 12 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e20f8cb..aeb8fad 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-19 Markus Trippelsdorf <markus@trippelsdorf.de>
+
+ * config/rs6000/constraints.md: Avoid signed integer overflows.
+ * config/rs6000/predicates.md: Likewise.
+
2014-11-19 Renlin Li <Renlin.Li@arm.com>
PR middle-end/63762
diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md
index b8800e6..0e0e517 100644
--- a/gcc/config/rs6000/constraints.md
+++ b/gcc/config/rs6000/constraints.md
@@ -140,7 +140,7 @@
(define_constraint "I"
"A signed 16-bit constant"
(and (match_code "const_int")
- (match_test "(unsigned HOST_WIDE_INT) (ival + 0x8000) < 0x10000")))
+ (match_test "((unsigned HOST_WIDE_INT) ival + 0x8000) < 0x10000")))
(define_constraint "J"
"high-order 16 bits nonzero"
diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index de7fa4e..1767cbd 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -392,8 +392,8 @@
;; Return 1 if op is a constant integer valid for addition with addis, addi.
(define_predicate "add_cint_operand"
(and (match_code "const_int")
- (match_test "(unsigned HOST_WIDE_INT)
- (INTVAL (op) + (mode == SImode ? 0x80000000 : 0x80008000))
+ (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)
+ + (mode == SImode ? 0x80000000 : 0x80008000))
< (unsigned HOST_WIDE_INT) 0x100000000ll")))
;; Return 1 if op is a constant integer valid for addition
@@ -827,7 +827,7 @@
(define_predicate "mask_operand"
(match_code "const_int")
{
- HOST_WIDE_INT c, lsb;
+ unsigned HOST_WIDE_INT c, lsb;
c = INTVAL (op);
@@ -872,7 +872,7 @@
(define_predicate "mask_operand_wrap"
(match_code "const_int")
{
- HOST_WIDE_INT c, lsb;
+ unsigned HOST_WIDE_INT c, lsb;
c = INTVAL (op);
@@ -897,7 +897,7 @@
(define_predicate "mask64_operand"
(match_code "const_int")
{
- HOST_WIDE_INT c, lsb;
+ unsigned HOST_WIDE_INT c, lsb;
c = INTVAL (op);
@@ -923,7 +923,7 @@
(define_predicate "mask64_2_operand"
(match_code "const_int")
{
- HOST_WIDE_INT c, lsb;
+ unsigned HOST_WIDE_INT c, lsb;
c = INTVAL (op);