On Mon, Sep 14, 2020 at 5:17 AM Feng Xue OS via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Thanks,
@@ -3426,8 +3426,16 @@ 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))\n"); + fprintf_indent (f, indent + 2, "return false;\n"); please use "goto %s;\n", fail_label) here. OK with that change. I've tried again to think about sth prettier to cover these kind of single-use checks but failed to come up with sth. Thanks and sorry for the delay, Richard. > Feng > > ________________________________________ > From: Feng Xue OS > Sent: Thursday, September 3, 2020 2:06 PM > To: gcc-patches@gcc.gnu.org > Subject: [PATCH 1/2] Fold plusminus_mult expr with multi-use operands (PR > 94234) > > For pattern A * C +- B * C -> (A +- B) * C, simplification is disabled > when A and B are not single-use. This patch is a minor enhancement > on the pattern, which allows folding if final result is found to be a > simple gimple value (constant/existing SSA). > > Bootstrapped/regtested on x86_64-linux and aarch64-linux. > > Feng > --- > 2020-09-03 Feng Xue <f...@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 for > 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. > ---