[PATCH] Remove fold () dispatch from fold_gimple_assign
Richard Biener
rguenther@suse.de
Thu Oct 29 15:00:00 GMT 2015
After
Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c (revision 229518)
+++ gcc/gimple-fold.c (working copy)
@@ -398,7 +398,10 @@ fold_gimple_assign (gimple_stmt_iterator
/* If we couldn't fold the RHS, hand over to the generic
fold routines. */
if (result == NULL_TREE)
- result = fold (rhs);
+ {
+ result = fold (rhs);
+ gcc_assert (result == rhs);
+ }
/* Strip away useless type conversions. Both the NON_LVALUE_EXPR
that may have been added by fold, and "useless" type
passed bootstrap and regtest on x86_64-unknown-linux-gnu I am now
testing the following.
There is still GIMPLE_TERNARY_RHS handling going via fold_ternary,
mostly for [VEC_]COND_EXPR handling not moved to match.pd
(and some others).
Richard.
2015-10-29 Richard Biener <rguenther@suse.de>
* gimple-fold.c (fold_gimple_assign): Do not dispatch to
fold () on single RHSs.
Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c (revision 229520)
+++ gcc/gimple-fold.c (working copy)
@@ -355,8 +355,8 @@ fold_gimple_assign (gimple_stmt_iterator
return val;
}
}
-
}
+
else if (TREE_CODE (rhs) == ADDR_EXPR)
{
tree ref = TREE_OPERAND (rhs, 0);
@@ -371,6 +371,18 @@ fold_gimple_assign (gimple_stmt_iterator
else if (TREE_CODE (ref) == MEM_REF
&& integer_zerop (TREE_OPERAND (ref, 1)))
result = fold_convert (TREE_TYPE (rhs), TREE_OPERAND (ref, 0));
+
+ if (result)
+ {
+ /* Strip away useless type conversions. Both the
+ NON_LVALUE_EXPR that may have been added by fold, and
+ "useless" type conversions that might now be apparent
+ due to propagation. */
+ STRIP_USELESS_TYPE_CONVERSION (result);
+
+ if (result != rhs && valid_gimple_rhs_p (result))
+ return result;
+ }
}
else if (TREE_CODE (rhs) == CONSTRUCTOR
@@ -394,21 +406,6 @@ fold_gimple_assign (gimple_stmt_iterator
else if (DECL_P (rhs))
return get_symbol_constant_value (rhs);
-
- /* If we couldn't fold the RHS, hand over to the generic
- fold routines. */
- if (result == NULL_TREE)
- result = fold (rhs);
-
- /* Strip away useless type conversions. Both the NON_LVALUE_EXPR
- that may have been added by fold, and "useless" type
- conversions that might now be apparent due to propagation. */
- STRIP_USELESS_TYPE_CONVERSION (result);
-
- if (result != rhs && valid_gimple_rhs_p (result))
- return result;
-
- return NULL_TREE;
}
break;
More information about the Gcc-patches
mailing list