summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-reassoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r--gcc/tree-ssa-reassoc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 395c5495455..e0d45612b01 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -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