[llvm] [InstCombine] Refactor fixed and scalable binop shuffle combine. NFCI (PR #141287)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sat May 24 06:08:47 PDT 2025
================
@@ -2094,6 +2094,50 @@ static bool shouldMergeGEPs(GEPOperator &GEP, GEPOperator &Src) {
return true;
}
+// Find constant NewC that has property:
+// shuffle(NewC, ShMask) = C
+// Returns nullptr if such a constant does not exist e.g. ShMask=<0,0> C=<1,2>
+//
+// A 1-to-1 mapping is not required. Example:
+// ShMask = <1,1,2,2> and C = <5,5,6,6> --> NewC = <poison,5,6,poison>
+static Constant *unshuffleConstant(ArrayRef<int> ShMask, Constant *C,
+ VectorType *NewCTy) {
+ if (isa<ScalableVectorType>(NewCTy)) {
+ Constant *Splat = C->getSplatValue();
+ if (!Splat)
+ return nullptr;
+ return ConstantVector::getSplat(
+ cast<VectorType>(C->getType())->getElementCount(), Splat);
----------------
lukel97 wrote:
Thanks for catching this, a fix and test should be added in dd1e8e8b0e29e8ad53a6a7675692241db224f02c
https://github.com/llvm/llvm-project/pull/141287
More information about the llvm-commits
mailing list