summaryrefslogtreecommitdiff
path: root/gcc/loop-iv.c
diff options
context:
space:
mode:
authorMarkus Trippelsdorf <markus@trippelsdorf.de>2014-11-20 16:36:14 +0000
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>2014-11-20 16:36:14 +0000
commitd7ca26e4167f1c7abe50041c838111ee4fab15d1 (patch)
treebd5b144b7bbe1e7b714275f855291e53127e214a /gcc/loop-iv.c
parent46ed60245a76b90e6161134fc6a22480aa1248fe (diff)
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/loop-iv.c')
-rw-r--r--gcc/loop-iv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 8ea458c3fc5..f55cea2a985 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -2311,7 +2311,7 @@ determine_max_iter (struct loop *loop, struct niter_desc *desc, rtx old_niter)
}
get_mode_bounds (desc->mode, desc->signed_p, desc->mode, &mmin, &mmax);
- nmax = INTVAL (mmax) - INTVAL (mmin);
+ nmax = UINTVAL (mmax) - UINTVAL (mmin);
if (GET_CODE (niter) == UDIV)
{
@@ -2649,7 +2649,7 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
down = INTVAL (CONST_INT_P (iv0.base)
? iv0.base
: mode_mmin);
- max = (up - down) / inc + 1;
+ max = (uint64_t) (up - down) / inc + 1;
if (!desc->infinite
&& !desc->assumptions)
record_niter_bound (loop, max, false, true);