[PATCH] D102404: [InstCombine] Add instcombine fold for extractelement + splat for scalable vectors
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 25 05:06:15 PDT 2021
foad added inline comments.
================
Comment at: llvm/lib/IR/ConstantFold.cpp:875-879
+ if (Constant *SplatVal = Val->getSplatValue()) {
+ unsigned NumElts = ValVTy->getElementCount().getKnownMinValue();
+ if (CIdx->getZExtValue() < NumElts)
+ return SplatVal;
+ }
----------------
It looks like this handles some of the same cases as the "CAZ of ScalableVectorType" case below. Can you combine them?
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:350
+ if (auto *I = dyn_cast<Instruction>(SrcVec))
+ if (auto *SE = dyn_cast<ShuffleVectorInst>(I))
----------------
This needs a comment explaining what case you are trying to handle, e.g. "(extractelement (shufflevector ...), ...) -> (...)"
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:351
+ if (auto *I = dyn_cast<Instruction>(SrcVec))
+ if (auto *SE = dyn_cast<ShuffleVectorInst>(I))
+ if (isSplatValue(SE) && IndexC->getZExtValue() < NumElts)
----------------
You can dyn_cast SrcVec directly to ShuffleVectorInst, no need to go via Instruction.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102404/new/
https://reviews.llvm.org/D102404
More information about the llvm-commits
mailing list