aboutsummaryrefslogtreecommitdiff
path: root/gcc/genmatch.c
diff options
context:
space:
mode:
authorFeng Xue <fxue@os.amperecomputing.com>2020-09-01 17:17:58 +0800
committerFeng Xue <fxue@os.amperecomputing.com>2020-09-15 11:14:01 +0800
commitf9d2def016410a2095df6b399097b482f82064a5 (patch)
tree20271e5733559c91f04ca141f03903b0907d9af2 /gcc/genmatch.c
parent50a71cd0182ae11444bc7b582a3b1cb1c54c7a0d (diff)
downloadgcc-f9d2def016410a2095df6b399097b482f82064a5.zip
gcc-f9d2def016410a2095df6b399097b482f82064a5.tar.gz
gcc-f9d2def016410a2095df6b399097b482f82064a5.tar.bz2
tree-optimization/94234 - Fold plusminus_mult expr with multi-use operands
2020-09-03 Feng Xue <fxue@os.amperecomputing.com> gcc/ PR tree-optimization/94234 * genmatch.c (dt_simplify::gen_1): Emit check on final simplification result when "!" is specified on toplevel output expr. * match.pd ((A * C) +- (B * C) -> (A +- B) * C): Allow folding on expr with multi-use operands if final result is a simple gimple value. gcc/testsuite/ PR tree-optimization/94234 * gcc.dg/pr94234-2.c: New test.
Diffstat (limited to 'gcc/genmatch.c')
-rw-r--r--gcc/genmatch.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 906d842..01363e3 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -3426,8 +3426,14 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result)
/* Re-fold the toplevel result. It's basically an embedded
gimple_build w/o actually building the stmt. */
if (!is_predicate)
- fprintf_indent (f, indent,
- "res_op->resimplify (lseq, valueize);\n");
+ {
+ fprintf_indent (f, indent,
+ "res_op->resimplify (lseq, valueize);\n");
+ if (e->force_leaf)
+ fprintf_indent (f, indent,
+ "if (!maybe_push_res_to_seq (res_op, NULL)) "
+ "goto %s;\n", fail_label);
+ }
}
else if (result->type == operand::OP_CAPTURE
|| result->type == operand::OP_C_EXPR)