diff options
author | Markus Trippelsdorf <markus@trippelsdorf.de> | 2014-11-20 16:36:14 +0000 |
---|---|---|
committer | Markus Trippelsdorf <trippels@gcc.gnu.org> | 2014-11-20 16:36:14 +0000 |
commit | d7ca26e4167f1c7abe50041c838111ee4fab15d1 (patch) | |
tree | bd5b144b7bbe1e7b714275f855291e53127e214a /gcc/config | |
parent | 46ed60245a76b90e6161134fc6a22480aa1248fe (diff) | |
download | gcc-d7ca26e4167f1c7abe50041c838111ee4fab15d1.zip gcc-d7ca26e4167f1c7abe50041c838111ee4fab15d1.tar.gz gcc-d7ca26e4167f1c7abe50041c838111ee4fab15d1.tar.bz2 |
PR63426 Fix various signed integer overflows
Running the testsuite after bootstrap-ubsan on gcc112 shows several issues. See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426 for the full list.
This patch fixes several of them.
2014-11-20 Markus Trippelsdorf <markus@trippelsdorf.de>
* config/rs6000/constraints.md: Avoid signed integer overflows.
* config/rs6000/predicates.md: Likewise.
* config/rs6000/rs6000.c (num_insns_constant_wide): Likewise.
(includes_rldic_lshift_p): Likewise.
(includes_rldicr_lshift_p): Likewise.
* emit-rtl.c (const_wide_int_htab_hash): Likewise.
* loop-iv.c (determine_max_iter): Likewise.
(iv_number_of_iterations): Likewise.
* tree-ssa-loop-ivopts.c (get_computation_cost_at): Likewise.
* varasm.c (get_section_anchor): Likewise.
From-SVN: r217886
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/rs6000/constraints.md | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/predicates.md | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md index 0e0e517..3f12b07 100644 --- a/gcc/config/rs6000/constraints.md +++ b/gcc/config/rs6000/constraints.md @@ -176,7 +176,7 @@ (define_constraint "P" "constant whose negation is 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"))) ;; Floating-point constraints diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 1767cbd..ea230a5 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -408,7 +408,7 @@ (define_predicate "reg_or_sub_cint_operand" (if_then_else (match_code "const_int") (match_test "(unsigned HOST_WIDE_INT) - (- INTVAL (op) + (mode == SImode ? 0x80000000 : 0x80008000)) + (- UINTVAL (op) + (mode == SImode ? 0x80000000 : 0x80008000)) < (unsigned HOST_WIDE_INT) 0x100000000ll") (match_operand 0 "gpc_reg_operand"))) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 506daa1..a9604cf 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5083,7 +5083,7 @@ int num_insns_constant_wide (HOST_WIDE_INT value) { /* signed constant loadable with addi */ - if ((unsigned HOST_WIDE_INT) (value + 0x8000) < 0x10000) + if (((unsigned HOST_WIDE_INT) value + 0x8000) < 0x10000) return 1; /* constant loadable with addis */ @@ -16194,7 +16194,7 @@ includes_rldic_lshift_p (rtx shiftop, rtx andop) { if (GET_CODE (andop) == CONST_INT) { - HOST_WIDE_INT c, lsb, shift_mask; + unsigned HOST_WIDE_INT c, lsb, shift_mask; c = INTVAL (andop); if (c == 0 || c == ~0) @@ -16233,7 +16233,7 @@ includes_rldicr_lshift_p (rtx shiftop, rtx andop) { if (GET_CODE (andop) == CONST_INT) { - HOST_WIDE_INT c, lsb, shift_mask; + unsigned HOST_WIDE_INT c, lsb, shift_mask; shift_mask = ~0; shift_mask <<= INTVAL (shiftop); |