* [PATCH] Remove fold_binary use from gimple_fold_stmt_to_constant_1
@ 2015-08-04 9:34 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2015-08-04 9:34 UTC (permalink / raw)
To: gcc-patches
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2015-08-04 Richard Biener <rguenther@suse.de>
* gimple-fold.c (gimple_fold_stmt_to_constant_1): Remove
dispatching to fold_binary for GIMPLE_BINARY_RHS and for
comparisons embedded in [VEC_]COND_EXPRs.
Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c (revision 226489)
+++ gcc/gimple-fold.c (working copy)
@@ -5008,28 +5008,26 @@ gimple_fold_stmt_to_constant_1 (gimple s
return NULL_TREE;
case GIMPLE_BINARY_RHS:
- {
- /* Handle binary operators that can appear in GIMPLE form. */
- tree op0 = (*valueize) (gimple_assign_rhs1 (stmt));
- tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
-
- /* Translate &x + CST into an invariant form suitable for
- further propagation. */
- if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
- && TREE_CODE (op0) == ADDR_EXPR
- && TREE_CODE (op1) == INTEGER_CST)
- {
- tree off = fold_convert (ptr_type_node, op1);
- return build_fold_addr_expr_loc
- (loc,
- fold_build2 (MEM_REF,
- TREE_TYPE (TREE_TYPE (op0)),
- unshare_expr (op0), off));
- }
-
- return fold_binary_loc (loc, subcode,
- gimple_expr_type (stmt), op0, op1);
- }
+ /* Translate &x + CST into an invariant form suitable for
+ further propagation. */
+ if (subcode == POINTER_PLUS_EXPR)
+ {
+ /* Handle binary operators that can appear in GIMPLE form. */
+ tree op0 = (*valueize) (gimple_assign_rhs1 (stmt));
+ tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
+
+ if (TREE_CODE (op0) == ADDR_EXPR
+ && TREE_CODE (op1) == INTEGER_CST)
+ {
+ tree off = fold_convert (ptr_type_node, op1);
+ return build_fold_addr_expr_loc
+ (loc,
+ fold_build2 (MEM_REF,
+ TREE_TYPE (TREE_TYPE (op0)),
+ unshare_expr (op0), off));
+ }
+ }
+ return NULL_TREE;
case GIMPLE_TERNARY_RHS:
{
@@ -5037,20 +5035,6 @@ gimple_fold_stmt_to_constant_1 (gimple s
tree op0 = (*valueize) (gimple_assign_rhs1 (stmt));
tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
tree op2 = (*valueize) (gimple_assign_rhs3 (stmt));
-
- /* Fold embedded expressions in ternary codes. */
- if ((subcode == COND_EXPR
- || subcode == VEC_COND_EXPR)
- && COMPARISON_CLASS_P (op0))
- {
- tree op00 = (*valueize) (TREE_OPERAND (op0, 0));
- tree op01 = (*valueize) (TREE_OPERAND (op0, 1));
- tree tem = fold_binary_loc (loc, TREE_CODE (op0),
- TREE_TYPE (op0), op00, op01);
- if (tem)
- op0 = tem;
- }
-
return fold_ternary_loc (loc, subcode,
gimple_expr_type (stmt), op0, op1, op2);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-04 9:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-04 9:34 [PATCH] Remove fold_binary use from gimple_fold_stmt_to_constant_1 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).