aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarkus Trippelsdorf <markus@trippelsdorf.de>2015-08-21 16:44:30 +0000
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>2015-08-21 16:44:30 +0000
commitf5dffc0ba1786e6af96fd31e9c04599b818aeedb (patch)
treedc8b58a037ecde64170bd90464b597621c8066a1 /gcc
parentcf6a9610f2e86f6de12281cc47b2d5a5acba63e4 (diff)
downloadgcc-f5dffc0ba1786e6af96fd31e9c04599b818aeedb.zip
gcc-f5dffc0ba1786e6af96fd31e9c04599b818aeedb.tar.gz
gcc-f5dffc0ba1786e6af96fd31e9c04599b818aeedb.tar.bz2
Fix PR61657 (undefined behavior in loop-iv.c)
bootstrap-ubsan shows: loop-iv.c:2626:14: runtime error: signed integer overflow: 9223372036854775806 - -9223372036854775808 cannot be represented in type 'long int' Fixed by moving the variables in question from signed to unsigned. PR rtl-optimization/61657 * loop-iv.c (iv_number_of_iterations): Declare up and down as unsigned. Remove superflous uint64_t cast. From-SVN: r227075
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/loop-iv.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6600613..806ea55 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-08-21 Markus Trippelsdorf <markus@trippelsdorf.de>
+
+ PR rtl-optimization/61657
+ * loop-iv.c (iv_number_of_iterations): Declare up and down as
+ unsigned. Remove superflous uint64_t cast.
+
2014-08-21 Felix Yang <felix.yang@huawei.com>
Jiji Jiang <jiangjiji@huawei.com>
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index 6e9cc8c..1c9a159 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -2330,8 +2330,8 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
enum rtx_code cond;
machine_mode mode, comp_mode;
rtx mmin, mmax, mode_mmin, mode_mmax;
- uint64_t s, size, d, inv, max;
- int64_t up, down, inc, step_val;
+ uint64_t s, size, d, inv, max, up, down;
+ int64_t inc, step_val;
int was_sharp = false;
rtx old_niter;
bool step_is_pow2;
@@ -2621,7 +2621,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 = (uint64_t) (up - down) / inc + 1;
+ max = (up - down) / inc + 1;
if (!desc->infinite
&& !desc->assumptions)
record_niter_bound (loop, max, false, true);