This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Transform (m1 > m2) * d into m1> m2 ? d : 0
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at cavium dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 29 Jun 2017 11:08:21 +0200
- Subject: Re: [PATCH] Transform (m1 > m2) * d into m1> m2 ? d : 0
- Authentication-results: sourceware.org; auth=none
- References: <CO2PR07MB2693DB4568B156AB3A5C50B083D20@CO2PR07MB2693.namprd07.prod.outlook.com>
On Thu, Jun 29, 2017 at 7:06 AM, Hurugalawadi, Naveen
> The code (m1 > m2) * d code should be optimized as m1> m2 ? d : 0.
> The patch optimizes it inside tree-vrp.c when simplifying with the range
> inside simplify_stmt_using_ranges. If a multiply is found and either side
> has a range [0,1], then transform it.
> Ex:- d * c where d has a range of [0,1] transform it to be
> COND_EXPR(d != 0, c, 0).
> The other optimization passes should prop m1 > m2.
> Bootstrapped and Regression tested on AArch64 and X86_64.
> Please review the patch and let us know if its okay?
What's the reason of this transform? I expect that the HW multiplier
is quite fast given one operand is either zero or one and a multiplication
is a gimple operation that's better handled in optimizations than
COND_EXPRs which eventually expand to conditional code which
would be much slower.
> 2017-06-28 Naveen H.S <Naveen.Hurugalawadi@cavium.com>
> * tree-vrp.c (simplify_stmt_using_ranges): Add case for
> optimizing a case of multiplication.
> (simplify_mult_ops_using_ranges): New.
> * gcc.dg/tree-ssa/vrp116.c: New Test.