This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC]Move simplification from fold-cond.c to match.pd and extend it
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <Bin dot Cheng at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Wed, 23 Nov 2016 11:29:14 +0100
- Subject: Re: [PATCH GCC]Move simplification from fold-cond.c to match.pd and extend it
- Authentication-results: sourceware.org; auth=none
- References: <AM4PR0802MB2163E557F53D6D34C2C20D43E7B00@AM4PR0802MB2163.eurprd08.prod.outlook.com>
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.