Added BaseShuffleAnalysis as a base class for ShuffleInstructionBuilder
and integrated shuffle logic from shuffles for externally used scalars
into this class. This class is used as the main container that
implements smart shuffle instruction builder logic.
ShuffleInstructionBuilder uses this logic.
ShuffleInstructionBuilder is also used in building of the shuffle for
the externally used scalars instead of lambdas, which are now part of BaseShuffleAnalysis class.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
6292 | Please add that when isStrict is true it returns false if mask size does not match vector size. | |
6297 | You can drop " && VF != Limit". | |
6318 | Could you please give more explanatory description here including arguments and return values? | |
6329 | We do not exit. The comment needs an update. | |
6338 | We do not exit here too. | |
6341 | this needs an explanation why IdentityMask is assigned with Mask |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
6306 | Please describe the purpose of LocalVF argument? | |
6342 | Thanks for the update. What is still confusing me... | |
6384 | What is still confusing.. it is unclear why broadcast mask & Op saved as identity (it's not actually an identity mask). | |
6449 | Could you share some insights why you put this into BaseShuffleAnalysis class method rather than into ShuffleInstructionBuilder? Since it produces new code technically it is not a pure analysis method. And why you want it to be a template (it seems to be instantiated just once with ShuffleIRBuilder)? |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
6306 | Will do | |
6342 | I'll fix it | |
6384 | Because we can treat it as identity too, because the mask 0,1,2,3,.. can be applied to broadcasts too. | |
6449 | It will be used for ShuffleCostEstimator too to avoid duplication/diffs in analysis/emission and cost estimation logic. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
6384 | A small example would be very helpful here... | |
6449 | Ah, I see. There is actually a comment to the class saying that, which I overlooked. So you are going to produce another class from it which will serve as cost estimator. Perhaps having "Analysis" as a part of its name isn't quite accurate. It probably makes sense to rename it to something like ShuffleBuilderBase to avoid confusion in future. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
6449 | It will be used not only for ShuffleBuilder, but for ShuffleCostEstimator, that's why I named it just ShuffleBaseAnalaysis |
Heads-up: This has caused a change in behavior when using #pragma unroll in some test using SIMD. In other words, using #pragma unroll results in a different output than without it. I'm preparing a reduced test case.
I've got a reduced IR file for that case:
$ old-clang -O2 q.ll && ./a.out 0.0 $ new-clang -O2 q.ll && ./a.out 5.0
Please fix or revert the patch, if there's no trivial fix.
Thanks!
It is not so easy, there are several commits on top of it already. I just started looking at it, hope to provide a fix in 1-2hrs, if it will take more time, I'll revert it.
Ok, found the bug, has a patch, preparing the test. Will be ready in 1-2hrs (need to test it).
Thanks! Verified that this fixes the issue. I'll run this through the full testing and let you know if it breaks anything else )
Please add that when isStrict is true it returns false if mask size does not match vector size.