Commit 02a1994c by Roger Sayle Committed by Roger Sayle

re PR middle-end/11771 (Segfault with simple double arithmetics)


	PR middle-end/11771
	* fold-const.c (negate_expr_p <MINUS_EXPR>): Change to match the
	logic in negate_expr, i.e. we don't invert (A-B) for floating
	point types unless flag_unsafe_math_optimizations.

	* gcc.c-torture/compile/20030804-1.c: New test case.

From-SVN: r70159
parent f2593a66
2003-08-04 Roger Sayle <roger@eyesopen.com> 2003-08-04 Roger Sayle <roger@eyesopen.com>
PR middle-end/11771
* fold-const.c (negate_expr_p <MINUS_EXPR>): Change to match the
logic in negate_expr, i.e. we don't invert (A-B) for floating
point types unless flag_unsafe_math_optimizations.
2003-08-04 Roger Sayle <roger@eyesopen.com>
* fold-const.c (fold <PLUS_EXPR>): Transform x+x into x*2.0. * fold-const.c (fold <PLUS_EXPR>): Transform x+x into x*2.0.
Optimize x*c+x and x+x*c into x*(c+1) and x*c1+x*c2 into x*(c1+c2) Optimize x*c+x and x+x*c into x*(c+1) and x*c1+x*c2 into x*(c1+c2)
for floating point expressions with -ffast-math. for floating point expressions with -ffast-math.
......
...@@ -841,9 +841,12 @@ negate_expr_p (tree t) ...@@ -841,9 +841,12 @@ negate_expr_p (tree t)
case REAL_CST: case REAL_CST:
case NEGATE_EXPR: case NEGATE_EXPR:
case MINUS_EXPR:
return true; return true;
case MINUS_EXPR:
/* We can't turn -(A-B) into B-A when we honor signed zeros. */
return ! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations;
default: default:
break; break;
} }
......
2003-08-04 Roger Sayle <roger@eyesopen.com> 2003-08-04 Roger Sayle <roger@eyesopen.com>
PR middle-end/11771
* gcc.c-torture/compile/20030804-1.c: New test case.
2003-08-04 Roger Sayle <roger@eyesopen.com>
* gcc.dg/20030804-1.c: New test case. * gcc.dg/20030804-1.c: New test case.
2003-08-04 Alexandre Oliva <aoliva@redhat.com> 2003-08-04 Alexandre Oliva <aoliva@redhat.com>
......
/* Extracted from PR middle-end/11771. */
/* The following testcase used to ICE without -ffast-math from unbounded
recursion in fold. This was due to the logic in negate_expr_p not
matching that in negate_expr. */
double f(double x) {
return -(1 - x) + (x ? -(1 - x) : 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