summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2019-12-06 12:33:46 -0800
committerEli Friedman <efriedma@quicinc.com>2019-12-09 15:31:50 -0800
commit7c69a03c56601a55f47f29ea59e33c37e62db556 (patch)
tree946b82b7006ec374ce5f2d504361ba63626287e7 /llvm/lib
parent584ed8822631481ced8d3574cc1fed1585aed77d (diff)
downloadbcm5719-llvm-7c69a03c56601a55f47f29ea59e33c37e62db556.tar.gz
bcm5719-llvm-7c69a03c56601a55f47f29ea59e33c37e62db556.zip
[ConstantFold][SVE] Fix constant folding for shufflevector.
Don't try to fold away shuffles which can't be folded. Fix creation of shufflevector constant expressions. Differential Revision: https://reviews.llvm.org/D71147
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp6
-rw-r--r--llvm/lib/IR/Constants.cpp2
-rw-r--r--llvm/lib/IR/ConstantsContext.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index bf01f9f2ae6..6e24f03c4cf 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -873,6 +873,12 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1,
// Don't break the bitcode reader hack.
if (isa<ConstantExpr>(Mask)) return nullptr;
+ // Do not iterate on scalable vector. The num of elements is unknown at
+ // compile-time.
+ VectorType *ValTy = cast<VectorType>(V1->getType());
+ if (ValTy->isScalable())
+ return nullptr;
+
unsigned SrcNumElts = V1->getType()->getVectorNumElements();
// Loop over the shuffle mask, evaluating each element.
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 7ea5cb8b167..fc215d6bf95 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2211,7 +2211,7 @@ Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2,
if (Constant *FC = ConstantFoldShuffleVectorInstruction(V1, V2, Mask))
return FC; // Fold a few common cases.
- unsigned NElts = Mask->getType()->getVectorNumElements();
+ ElementCount NElts = Mask->getType()->getVectorElementCount();
Type *EltTy = V1->getType()->getVectorElementType();
Type *ShufTy = VectorType::get(EltTy, NElts);
diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h
index 1ec9087551f..f5e2481f390 100644
--- a/llvm/lib/IR/ConstantsContext.h
+++ b/llvm/lib/IR/ConstantsContext.h
@@ -149,7 +149,7 @@ public:
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
: ConstantExpr(VectorType::get(
cast<VectorType>(C1->getType())->getElementType(),
- cast<VectorType>(C3->getType())->getNumElements()),
+ cast<VectorType>(C3->getType())->getElementCount()),
Instruction::ShuffleVector,
&Op<0>(), 3) {
Op<0>() = C1;
OpenPOWER on IntegriCloud