tree-ssa-reassoc.c (reassociate_expr): Allow scaler floating point types when flag_unsafe_math_optimizations is true.

2005-07-25  Andrew Pinski  <pinskia@physics.uc.edu>

        * tree-ssa-reassoc.c (reassociate_expr): Allow scaler floating point
        types when flag_unsafe_math_optimizations is true.

2005-07-25  Andrew Pinski  <pinskia@physics.uc.edu>

        * gcc.dg/tree-ssa/reassoc-3.c: New test.
        * gcc.dg/tree-ssa/reassoc-4.c: New test.

From-SVN: r102368
This commit is contained in:
Andrew Pinski 2005-07-25 20:23:50 +00:00 committed by Andrew Pinski
parent 160633c626
commit c72f711f8a
5 changed files with 53 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2005-07-25 Andrew Pinski <pinskia@physics.uc.edu>
* tree-ssa-reassoc.c (reassociate_expr): Allow scaler floating point
types when flag_unsafe_math_optimizations is true.
2005-07-25 Mark Mitchell <mark@codesourcery.com>
* gcc.c (option_map): Add --sysroot.

View File

@ -1,3 +1,8 @@
2005-07-25 Andrew Pinski <pinskia@physics.uc.edu>
* gcc.dg/tree-ssa/reassoc-3.c: New test.
* gcc.dg/tree-ssa/reassoc-4.c: New test.
2005-07-25 Adam Nemet <anemet@lnxw.com>
* lib/profopt.exp (profopt-execute): Check for profiling data

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized -ffast-math" } */
float a, b, c, d;
extern int printf (const char *, ...);
int main(void)
{
float e;
float f;
/* We should be able to transform these into the same expression, and only have two additions. */
e = a + b;
e = e + c;
f = c + a;
f = f + b;
printf ("%f %f\n", e, f);
}
/* { dg-final { scan-tree-dump-times "\\\+" 2 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
float a, b, c, d;
extern int printf (const char *, ...);
int main(void)
{
float e;
float f;
/* We should not be able to transform these into the same expression, and only have two additions. */
e = a + b;
e = e + c;
f = c + a;
f = f + b;
printf ("%f %f\n", e, f);
}
/* { dg-final { scan-tree-dump-times "\\\+" 4 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -435,10 +435,13 @@ reassociate_expr (tree bexpr, block_stmt_iterator *currbsi)
unsigned int lhsrank = get_rank (lhs);
unsigned int rhsrank = get_rank (rhs);
/* I don't want to get into the business of floating point
reassociation. */
if (!INTEGRAL_TYPE_P (TREE_TYPE (lhs))
|| !INTEGRAL_TYPE_P (TREE_TYPE (rhs)))
/* If unsafe math optimizations we can do reassociation for non integal
types. */
if ((!INTEGRAL_TYPE_P (TREE_TYPE (lhs))
|| !INTEGRAL_TYPE_P (TREE_TYPE (rhs)))
&& (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (rhs))
|| !SCALAR_FLOAT_TYPE_P (TREE_TYPE(lhs))
|| !flag_unsafe_math_optimizations))
return false;
/* We want the greater ranked operand to be our "LHS" for simplicity