[PATCH] D152659: [LV] Add IRBuilder folder to simplify GEP x, 0.
Ayal Zaks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 15:00:45 PDT 2023
Ayal added a comment.
Trying to see if we can catch all redundant cases and reason about optimizing them explicitly during recipe execution (and potentially earlier, e.g., if every GEP would be represented by a recipe) rather than during Builder code-gen.
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2661
Idx = Builder.CreateAdd(Idx, Builder.getInt32(Index));
Idx = Builder.CreateNeg(Idx);
} else
----------------
Idx is zero iff !reverse and Index == 0. Reverse sets Idx according to (negative) last lane which cannot be zero: -((VF-1)*|IG|+Index).
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2684
InBounds = gep->isInBounds();
AddrPart = Builder.CreateGEP(ScalarTy, AddrPart, Idx, "", InBounds);
----------------
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9749
Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF);
PartPtr = Builder.CreateGEP(ScalarDataTy, Ptr, NumElt, "", InBounds);
PartPtr =
----------------
NumElt is zero iff Part is zero, being set to -Part * RunTimeVF.
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9756-9757
} else {
Value *Increment = createStepForVF(Builder, IndexTy, State.VF, Part);
PartPtr = Builder.CreateGEP(ScalarDataTy, Ptr, Increment, "", InBounds);
}
----------------
Increment is zero iff Part is zero, being set to State.VF * Part.
VPlan code-gen should ideally be straightforward, potentially at the expense of more accurate modelling in VPlan recipes. Rather than delegating folding optimizations to the Builder at code-gen, trying to see if recipes could reason more accurately about the code they represent. Some optimizations relate specifically to the first unrolled part.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152659/new/
https://reviews.llvm.org/D152659
More information about the llvm-commits
mailing list