[PATCH] D24557: [Loop Vectorizer] Simplified GEP cloning. NFC.
Elena Demikhovsky via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 14 06:26:17 PDT 2016
delena created this revision.
delena added reviewers: mkuper, Ayal.
delena added a subscriber: llvm-commits.
delena set the repository for this revision to rL LLVM.
Herald added a subscriber: mzolotukhin.
I simplified GEP cloning in vectorizeMemoryInstruction().
Repository:
rL LLVM
https://reviews.llvm.org/D24557
Files:
../lib/Transforms/Vectorize/LoopVectorize.cpp
Index: ../lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- ../lib/Transforms/Vectorize/LoopVectorize.cpp
+++ ../lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2783,44 +2783,15 @@
// Handle consecutive loads/stores.
GetElementPtrInst *Gep = getGEPInstruction(Ptr);
if (ConsecutiveStride) {
- if (Gep && Legal->isInductionVariable(Gep->getPointerOperand())) {
- setDebugLocFromInst(Builder, Gep);
- auto *FirstBasePtr = getScalarValue(Gep->getPointerOperand(), 0, 0);
-
- // Create the new GEP with the new induction variable.
+ if (Gep) {
GetElementPtrInst *Gep2 = cast<GetElementPtrInst>(Gep->clone());
- Gep2->setOperand(0, FirstBasePtr);
- Gep2->setName("gep.indvar.base");
- Ptr = Builder.Insert(Gep2);
- } else if (Gep) {
- setDebugLocFromInst(Builder, Gep);
- assert(PSE.getSE()->isLoopInvariant(PSE.getSCEV(Gep->getPointerOperand()),
- OrigLoop) &&
- "Base ptr must be invariant");
- // The last index does not have to be the induction. It can be
- // consecutive and be a function of the index. For example A[I+1];
unsigned NumOperands = Gep->getNumOperands();
- unsigned InductionOperand = getGEPInductionOperand(Gep);
- // Create the new GEP with the new induction variable.
- GetElementPtrInst *Gep2 = cast<GetElementPtrInst>(Gep->clone());
-
- for (unsigned i = 0; i < NumOperands; ++i) {
- Value *GepOperand = Gep->getOperand(i);
- Instruction *GepOperandInst = dyn_cast<Instruction>(GepOperand);
-
- // Update last index or loop invariant instruction anchored in loop.
- if (i == InductionOperand ||
- (GepOperandInst && OrigLoop->contains(GepOperandInst))) {
- assert((i == InductionOperand ||
- PSE.getSE()->isLoopInvariant(PSE.getSCEV(GepOperandInst),
- OrigLoop)) &&
- "Must be last index or loop invariant");
-
- Gep2->setOperand(i, getScalarValue(GepOperand, 0, 0));
- Gep2->setName("gep.indvar.idx");
- }
- }
+ Gep2->setName("gep.indvar");
+ for (unsigned i = 0; i < NumOperands; ++i)
+ Gep2->setOperand(i, getScalarValue(Gep->getOperand(i), 0, 0));
+ setDebugLocFromInst(Builder, Gep);
Ptr = Builder.Insert(Gep2);
+
} else { // No GEP
// Use the induction element ptr.
assert(isa<PHINode>(Ptr) && "Invalid induction ptr");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24557.71341.patch
Type: text/x-patch
Size: 2570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160914/16b84e0d/attachment.bin>
More information about the llvm-commits
mailing list