aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorHuihui Zhang <huihuiz@quicinc.com>2020-03-12 15:59:14 -0700
committerHuihui Zhang <huihuiz@quicinc.com>2020-03-12 16:15:38 -0700
commitf4f2706572b1851d902fd569d8fb75bc42c8c82b (patch)
treeb64dc75f146e3b96621c0f0e5ff53109501c3a45 /llvm/lib/IR/ConstantFold.cpp
parentccc6e780c8fa769fc503f193d27a1ef356f6355d (diff)
downloadllvm-f4f2706572b1851d902fd569d8fb75bc42c8c82b.zip
llvm-f4f2706572b1851d902fd569d8fb75bc42c8c82b.tar.gz
llvm-f4f2706572b1851d902fd569d8fb75bc42c8c82b.tar.bz2
[ConstantFold][SVE] Fix constant folding for scalable vector compare instruction.
Summary: Do not iterate on scalable vector. Also do not return constant scalable vector from ConstantInt::get(). Fix result type by using getElementCount() instead of getNumElements(). Reviewers: sdesmalen, efriedma, apazos, huntergr, willlovett Reviewed By: efriedma Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73753
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 0da027f..dc78c55 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1840,7 +1840,7 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
Type *ResultTy;
if (VectorType *VT = dyn_cast<VectorType>(C1->getType()))
ResultTy = VectorType::get(Type::getInt1Ty(C1->getContext()),
- VT->getNumElements());
+ VT->getElementCount());
else
ResultTy = Type::getInt1Ty(C1->getContext());
@@ -1971,6 +1971,11 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
R==APFloat::cmpEqual);
}
} else if (C1->getType()->isVectorTy()) {
+ // Do not iterate on scalable vector. The number of elements is unknown at
+ // compile-time.
+ if (C1->getType()->getVectorIsScalable())
+ return nullptr;
+
// If we can constant fold the comparison of each element, constant fold
// the whole vector comparison.
SmallVector<Constant*, 4> ResElts;