summaryrefslogtreecommitdiff
path: root/gcc/loop-iv.c
diff options
context:
space:
mode:
authortrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-20 16:36:14 +0000
committertrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-20 16:36:14 +0000
commit06b8401d563d626786964701f16ced1008d39593 (patch)
treebd5b144b7bbe1e7b714275f855291e53127e214a /gcc/loop-iv.c
parent650ad49efde0cfb457804acae1acd8d86f921fd4 (diff)
downloadgcc-06b8401d563d626786964701f16ced1008d39593.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217886 138bc75d-0d04-0410-961f-82ee72b054a4
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);