aboutsummaryrefslogtreecommitdiff
path: root/gcc/ifcvt.c
diff options
context:
space:
mode:
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>2016-05-25 15:53:21 +0000
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>2016-05-25 15:53:21 +0000
commit5c42d3414397b59b0431be58732900c2c0165c72 (patch)
tree131f0f77d0d7c2be0f18092dc8ec7993aaff6922 /gcc/ifcvt.c
parentbf9a1a07adb0594b8060bbe23e2cde3475885fdc (diff)
downloadgcc-5c42d3414397b59b0431be58732900c2c0165c72.zip
gcc-5c42d3414397b59b0431be58732900c2c0165c72.tar.gz
gcc-5c42d3414397b59b0431be58732900c2c0165c72.tar.bz2
[RTL ifcvt] PR rtl-optimization/66940: Avoid signed overflow in noce_get_alt_condition
PR rtl-optimization/66940 * ifcvt.c (noce_get_alt_condition): Check that incrementing or decrementing desired_val will not overflow before performing these operations. * gcc.c-torture/execute/pr66940.c: New test. From-SVN: r236728
Diffstat (limited to 'gcc/ifcvt.c')
-rw-r--r--gcc/ifcvt.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 4949965..44ae020 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2364,28 +2364,32 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
switch (code)
{
case LT:
- if (actual_val == desired_val + 1)
+ if (desired_val != HOST_WIDE_INT_MAX
+ && actual_val == desired_val + 1)
{
code = LE;
op_b = GEN_INT (desired_val);
}
break;
case LE:
- if (actual_val == desired_val - 1)
+ if (desired_val != HOST_WIDE_INT_MIN
+ && actual_val == desired_val - 1)
{
code = LT;
op_b = GEN_INT (desired_val);
}
break;
case GT:
- if (actual_val == desired_val - 1)
+ if (desired_val != HOST_WIDE_INT_MIN
+ && actual_val == desired_val - 1)
{
code = GE;
op_b = GEN_INT (desired_val);
}
break;
case GE:
- if (actual_val == desired_val + 1)
+ if (desired_val != HOST_WIDE_INT_MAX
+ && actual_val == desired_val + 1)
{
code = GT;
op_b = GEN_INT (desired_val);