Commit 1fc5eced by Marc Glisse Committed by Marc Glisse

re PR tree-optimization/56355 (abs and multiplication)

2013-03-20  Marc Glisse  <marc.glisse@inria.fr>

	PR tree-optimization/56355
gcc/
	* fold-const.c (tree_binary_nonnegative_warnv_p) <MULT_EXPR>:
	Also handle integers with undefined overflow.

gcc/testsuite/
	* gcc.dg/pr56355-1.c: New file.

From-SVN: r196829
parent 22c4c869
2013-03-20 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/56355
* fold-const.c (tree_binary_nonnegative_warnv_p) <MULT_EXPR>:
Also handle integers with undefined overflow.
2013-03-20 Catherine Moore <clm@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
Tom de Vries <tom@codesourcery.com>
......
......@@ -15294,15 +15294,18 @@ tree_binary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0,
break;
case MULT_EXPR:
if (FLOAT_TYPE_P (type))
if (FLOAT_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
{
/* x * x for floating point x is always non-negative. */
if (operand_equal_p (op0, op1, 0))
return true;
return (tree_expr_nonnegative_warnv_p (op0,
strict_overflow_p)
&& tree_expr_nonnegative_warnv_p (op1,
strict_overflow_p));
/* x * x is always non-negative for floating point x
or without overflow. */
if (operand_equal_p (op0, op1, 0)
|| (tree_expr_nonnegative_warnv_p (op0, strict_overflow_p)
&& tree_expr_nonnegative_warnv_p (op1, strict_overflow_p)))
{
if (TYPE_OVERFLOW_UNDEFINED (type))
*strict_overflow_p = true;
return true;
}
}
/* zero_extend(x) * zero_extend(y) is non-negative if x and y are
......
2013-03-20 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/56355
* gcc.dg/pr56355-1.c: New file.
2013-03-20 Catherine Moore <clm@codesourcery.com>
Richard Sandiford <rdsandiford@googlemail.com>
......
/* { dg-do compile } */
/* { dg-options "-O2 -Wstrict-overflow=4" } */
int
f (int i)
{
return __builtin_abs (i * i); /* { dg-warning "assuming signed overflow" } */
}
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