[llvm] [LSV] Enhance LoadStoreVectorizer to Handle Disjoint Flag in OR Instructions and Restore Vectorization Opportunities (PR #96495)
Hao Li via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 22:53:19 PDT 2024
================
@@ -437,9 +437,18 @@ bool Vectorizer::run() {
SmallVector<BasicBlock::iterator, 8> Barriers;
Barriers.push_back(BB->begin());
- for (Instruction &I : *BB)
+ for (Instruction &I : *BB){
+ if (auto *OrInst = dyn_cast<PossiblyDisjointInst>(&I)) {
+ Value *Op0 = OrInst->getOperand(0);
+ Value *Op1 = OrInst->getOperand(1);
+
+ if (haveNoCommonBitsSet(Op0, Op1, DL)) {
+ OrInst->setIsDisjoint(true);
----------------
LiHao217 wrote:
The backend I tested was not X86 but NVPTX. Without this change, llvm would not be able to autovectorize the following test case
```
Test case:
LLVM/test/Transforms/LoadStoreVectorizer/NVPTX/disjoint_or_vectorizer ll
Test the command:
opt -mtriple=nvptx64-nvidia-cuda -debug-pass-manager -passes=load-store-vectorizer -S -o - llvm/test/Transforms/LoadStoreVectorizer/NVPTX/disjoint_or_vectorizer.ll
```
https://github.com/llvm/llvm-project/pull/96495
More information about the llvm-commits
mailing list