Ping: [PATCH 1/2] Fold plusminus_mult expr with multi-use operands (PR 94234)

Richard Biener richard.guenther@gmail.com
Tue Sep 15 06:42:39 GMT 2020


On Tue, Sep 15, 2020 at 5:28 AM Feng Xue OS <fxue@os.amperecomputing.com> wrote:
>
> >@@ -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.
> Ok.
>
> >
> >I've tried again to think about sth prettier to cover these kind of
> >single-use checks but failed to come up with sth.
> Maybe we need a smart combiner that can deduce cost globally, and
> remove these single-use specifiers from rule description.

Yeah, but I've never found the time to try sth like that ... in theory
the GIMPLE forwprop pass is the appropriate place to do this.

Richard.

> Feng
>
> ________________________________________
> From: Richard Biener <richard.guenther@gmail.com>
> Sent: Monday, September 14, 2020 9:39 PM
> To: Feng Xue OS
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: Ping: [PATCH 1/2] Fold plusminus_mult expr with multi-use operands (PR 94234)
>
> 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  <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 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.
> > ---


More information about the Gcc-patches mailing list