[PATCH] D105632: [LV] Use lookThroughAnd with logical reductions
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 28 05:19:44 PDT 2021
spatel added inline comments.
================
Comment at: llvm/test/Transforms/LoopVectorize/trunc-reductions.ll:237
+ %sum.02p = phi i32 [ %min, %for.body ], [ 0, %entry ]
+ %sum.02 = and i32 %sum.02p, 65535
+ %gep = getelementptr inbounds i16, i16* %ptr, i32 %iv
----------------
kmclaughlin wrote:
> spatel wrote:
> > It's independent of this patch, but I noticed that all of the affected tests have this kind of mask op on the phi.
> > I think -instcombine will eliminate that op, so -loop-vectorize will not typically see this pattern, and we still get the wide reduction op. Is there a plan to account for that?
> Hi @spatel, thanks for taking a look at this! I think it is possible for -loop-vectorize to see this pattern - I've tried using this patch with some small examples such as the following:
>
> ```
> short foo(short *values, long long N) {
> int sum = 0;
> for(long long i=0; i<N; ++i) {
> sum &= 65535;
> sum |= (int)values[i];
> }
> return (short)sum;
> }
> ```
> I don't believe -instcombine is eliminating the `and` before -loop-vectorize with the above example, and we do get the narrower reduction op after -loop-vectorize with these changes.
Thanks for checking. I was seeing the mask op disappear in some of the reduced IR examples, but that may be due to over-simplification in tests.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105632/new/
https://reviews.llvm.org/D105632
More information about the llvm-commits
mailing list