This is the mail archive of the 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] Transform (m1 > m2) * d into m1> m2 ? d : 0

On Thu, Jun 29, 2017 at 7:06 AM, Hurugalawadi, Naveen
<> 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,
> Naveen
> 2017-06-28  Naveen H.S  <>
> 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.

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