38b098be6605 limited scalarization to indices that are known non-poison.
For certain patterns that restrict the range of an index, we can insert
a freeze of the original value, to prevent propagation of poison.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
779 | Other than the name, this looks like it could be a generic freeze utility. Should we put it in some header for other potential callers? cc @aqjune @hyeongyukim | |
812 | Use InsertPointGuard so caller doesn't have to manually reset it. | |
857 | stray punctuation |
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
779 | Not sure whether this class can be reused, but I agree that having a header containing utilities for dealing with freeze is a good idea (or probably reuse Local.h?). |
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
779 |
I tried to keep things as general as possible here. But for now it serves a very specific use case, so maybe it would make sense to wait with moving this to a header until there are similar use cases? |
Added assertion as suggested and also just update operands of UserI, thanks!
LLVM doesn't do a great job when lowering operations on largish vectors in general, e.g. originating from uses of extended vectors in C/C++ or other frontends. The patch in particular improves the lowering of code like below
using vec_ty = float __attribute__((ext_vector_type(32))); void foo(vec_ty *ptr, int idx) { (*ptr)[idx&31] = 0.0; }
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
810 |
For the current version of the API yes! Updated, thanks! |
Seems fine to me, thanks.
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
785–786 | maybe | |
816 | ||
839–840 | @nlopes I wanted to check what can we do for potentially OOB insertions, | |
987–989 | This should either contain a FIXME comment, or a comment saying that here freeze won't help. |
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
839–840 | Both tests look correct to me. |
Address outstanding comments. I'll land this version in a bit.
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | ||
---|---|---|
785–786 | I think for constructors it is quite common to have names matching the directly initialized fields for arguments. To make things consistent for the constructor, I renamed to S argument to Status. |
Other than the name, this looks like it could be a generic freeze utility. Should we put it in some header for other potential callers? cc @aqjune @hyeongyukim