[PATCH] D102404: [InstCombine] Add instcombine fold for extractelement + splat for scalable vectors
Caroline via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 2 08:37:03 PDT 2021
CarolineConcatto added a comment.
Thank you @sdesmalen for you review.
I have made the changes you've asked.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4499-4502
+ if (auto *SE = dyn_cast<ShuffleVectorInst>(Vec))
+ if (isSplatValue(SE) && IdxC->getValue().ult(NumElts))
+ if (auto *IE = dyn_cast<InsertElementInst>(SE->getOperand(0)))
+ return IE->getOperand(1);
----------------
sdesmalen wrote:
> Why not just rely on `llvm::getSplatValue` here?
>
> unsigned MinNumElts = VecVTy->getElementCount().getKnownMinValue();
> if (IdxC->getValue().ult(NumElts))
> if (auto *Splat = getSplatValue(Vec))
> return Splat;
>
>
Yes, it could check for Splat.
I like the other way because it explains/shows the instruction chain.
But your solution is cleaner, so I have changed.
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