[llvm] [ConstantFolding] Fold scalable shufflevector of poison/undef. (PR #143475)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 04:00:22 PDT 2025
================
@@ -463,10 +463,7 @@ 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())
+ if (!MaskEltCount.isScalable() || Elt->isNullValue() || isa<UndefValue>(Elt))
----------------
nikic wrote:
It took me a while to get why we need this condition. I'd add a comment like
```
// For scalable vectors, make sure this doesn't fold back into a shufflevector.
```
https://github.com/llvm/llvm-project/pull/143475
More information about the llvm-commits
mailing list