diff options
author | Craig Topper <craig.topper@sifive.com> | 2025-06-10 12:50:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-10 12:50:16 -0700 |
commit | f72dd4eca8dac84d819abccde4447755a7d9420d (patch) | |
tree | 39f25a88abbe7124f214098253fd2a969c52f0a1 /llvm/lib/IR/ConstantFold.cpp | |
parent | be3c6a06d36d6210ce51bbeacc343f3590043b96 (diff) | |
download | llvm-f72dd4eca8dac84d819abccde4447755a7d9420d.zip llvm-f72dd4eca8dac84d819abccde4447755a7d9420d.tar.gz llvm-f72dd4eca8dac84d819abccde4447755a7d9420d.tar.bz2 |
[ConstantFolding] Fold scalable shufflevector of poison/undef. (#143475)
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index b9db402..d4ad21e 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -463,10 +463,9 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, Constant *Elt = ConstantExpr::getExtractElement(V1, ConstantInt::get(Ty, 0)); - if (Elt->isNullValue()) { - auto *VTy = VectorType::get(EltTy, MaskEltCount); - return ConstantAggregateZero::get(VTy); - } else if (!MaskEltCount.isScalable()) + // For scalable vectors, make sure this doesn't fold back into a + // shufflevector. + if (!MaskEltCount.isScalable() || Elt->isNullValue() || isa<UndefValue>(Elt)) return ConstantVector::getSplat(MaskEltCount, Elt); } |