On Thu, Jun 29, 2017 at 7:06 AM, Hurugalawadi, Naveen <naveen.hurugalaw...@cavium.com> wrote: > Hi, > > 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. Thanks, Richard. > Thanks, > Naveen > > 2017-06-28 Naveen H.S <naveen.hurugalaw...@cavium.com> > > gcc > * tree-vrp.c (simplify_stmt_using_ranges): Add case for > optimizing a case of multiplication. > (simplify_mult_ops_using_ranges): New. > > gcc/testsuite > * gcc.dg/tree-ssa/vrp116.c: New Test. > >