[PATCH] D105632: [LV] Use lookThroughAnd with logical reductions
Kerry McLaughlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 07:51:39 PDT 2021
kmclaughlin reopened this revision.
kmclaughlin added inline comments.
This revision is now accepted and ready to land.
================
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
----------------
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.
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