[llvm] 3e16152 - [SLP] Fix OOB GEP index access for a no-op GEP

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 09:33:11 PST 2023


Author: Reid Kleckner
Date: 2023-12-15T17:33:06Z
New Revision: 3e16152ebc82f4e187b4471416a7d7c2d9a006ad

URL: https://github.com/llvm/llvm-project/commit/3e16152ebc82f4e187b4471416a7d7c2d9a006ad
DIFF: https://github.com/llvm/llvm-project/commit/3e16152ebc82f4e187b4471416a7d7c2d9a006ad.diff

LOG: [SLP] Fix OOB GEP index access for a no-op GEP

Issue is covered by existing test
llvm/test/Transforms/SLPVectorizer/RISCV/phi-const.ll

See issue #75632 for ideas for how we could catch these more easily in
the future.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 4bc65067473eef..9d799124074ca1 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -13682,8 +13682,10 @@ void SLPVectorizerPass::collectSeedInstructions(BasicBlock *BB) {
     // constant index, or a pointer operand that doesn't point to a scalar
     // type.
     else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
+      if (GEP->getNumIndices() != 1)
+        continue;
       Value *Idx = GEP->idx_begin()->get();
-      if (GEP->getNumIndices() > 1 || isa<Constant>(Idx))
+      if (isa<Constant>(Idx))
         continue;
       if (!isValidElementType(Idx->getType()))
         continue;


        


More information about the llvm-commits mailing list