Commit 5c42d341 by Kyrylo Tkachov Committed by Kyrylo Tkachov

[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
parent bf9a1a07
2016-05-25 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR rtl-optimization/66940
* ifcvt.c (noce_get_alt_condition): Check that incrementing or
decrementing desired_val will not overflow before performing these
operations.
2016-05-25 Ilya Verbin <ilya.verbin@intel.com> 2016-05-25 Ilya Verbin <ilya.verbin@intel.com>
* config/i386/i386-builtin-types.def: Add V16SI_FTYPE_V16SF, * config/i386/i386-builtin-types.def: Add V16SI_FTYPE_V16SF,
......
...@@ -2364,28 +2364,32 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target, ...@@ -2364,28 +2364,32 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
switch (code) switch (code)
{ {
case LT: case LT:
if (actual_val == desired_val + 1) if (desired_val != HOST_WIDE_INT_MAX
&& actual_val == desired_val + 1)
{ {
code = LE; code = LE;
op_b = GEN_INT (desired_val); op_b = GEN_INT (desired_val);
} }
break; break;
case LE: case LE:
if (actual_val == desired_val - 1) if (desired_val != HOST_WIDE_INT_MIN
&& actual_val == desired_val - 1)
{ {
code = LT; code = LT;
op_b = GEN_INT (desired_val); op_b = GEN_INT (desired_val);
} }
break; break;
case GT: case GT:
if (actual_val == desired_val - 1) if (desired_val != HOST_WIDE_INT_MIN
&& actual_val == desired_val - 1)
{ {
code = GE; code = GE;
op_b = GEN_INT (desired_val); op_b = GEN_INT (desired_val);
} }
break; break;
case GE: case GE:
if (actual_val == desired_val + 1) if (desired_val != HOST_WIDE_INT_MAX
&& actual_val == desired_val + 1)
{ {
code = GT; code = GT;
op_b = GEN_INT (desired_val); op_b = GEN_INT (desired_val);
......
2016-05-25 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR rtl-optimization/66940
* gcc.c-torture/execute/pr66940.c: New test.
2016-05-25 Ilya Verbin <ilya.verbin@intel.com> 2016-05-25 Ilya Verbin <ilya.verbin@intel.com>
* gcc.target/i386/avx512f-ceil-vec-1.c: New test. * gcc.target/i386/avx512f-ceil-vec-1.c: New test.
......
long long __attribute__ ((noinline, noclone))
foo (long long ival)
{
if (ival <= 0)
return -0x7fffffffffffffffL - 1;
return 0x7fffffffffffffffL;
}
int
main (void)
{
if (foo (-1) != (-0x7fffffffffffffffL - 1))
__builtin_abort ();
if (foo (1) != 0x7fffffffffffffffL)
__builtin_abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment