This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH GCC]Move simplification from fold-cond.c to match.pd and extend it


On Fri, Nov 18, 2016 at 11:20 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is a rework of https://gcc.gnu.org/ml/gcc-patches/2016-10/msg02005.html.  According to review comment, I extended the original patch and made it covering last kind simplification of fold_cond_expr_with_comparison (Well, this patch handles <, <=, > and >=.  == will be handled by a follow up).  This patch also adds several tests, some tests are for existing fold_cond_expr_with_comparison simplification but not covered yet; others are for new extension.
> Bootstrap and test on x86_64 and AArch64 along with following patches, is it OK?

I think you don't need the explicit types in the result

+   (if (code == MAX_EXPR)
+    (convert (max @1 (convert:from_type @2)))
+    (if (code == MIN_EXPR)
+     (convert (min @1 (convert:from_type @2))))))))

A simple (convert (max @1 (convert @2))) should work.

Otherwise ok.

Thanks,
Richard.

> Thanks,
> bin
>
> 2016-11-16  Bin Cheng  <bin.cheng@arm.com>
>
>         * fold-const.c (fold_cond_expr_with_comparison): Move simplification
>         for A cmp C1 ? A : C2 to below, also simplify remaining code.
>         * match.pd: Move and extend simplification from above to here:
>         (cond (cmp (convert1? x) c1) (convert2? x) c2) -> (minmax (x c)).
>         * tree-if-conv.c (ifcvt_follow_ssa_use_edges): New func.
>         (predicate_scalar_phi): Call fold_stmt using the new valueize func.
>
> gcc/testsuite/ChangeLog
> 2016-11-16  Bin Cheng  <bin.cheng@arm.com>
>
>         * gcc.dg/fold-cond_expr-1.c: New test.
>         * gcc.dg/fold-condcmpconv-1.c: New test.
>         * gcc.dg/fold-condcmpconv-2.c: New test.
>         * gcc.dg/tree-ssa/pr66726.c: Adjust test strings.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]