aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.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/Constants.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/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index eb0e589..c609add 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2175,7 +2175,7 @@ Constant *ConstantExpr::getICmp(unsigned short pred, Constant *LHS,
Type *ResultTy = Type::getInt1Ty(LHS->getContext());
if (VectorType *VT = dyn_cast<VectorType>(LHS->getType()))
- ResultTy = VectorType::get(ResultTy, VT->getNumElements());
+ ResultTy = VectorType::get(ResultTy, VT->getElementCount());
LLVMContextImpl *pImpl = LHS->getType()->getContext().pImpl;
return pImpl->ExprConstants.getOrCreate(ResultTy, Key);
@@ -2200,7 +2200,7 @@ Constant *ConstantExpr::getFCmp(unsigned short pred, Constant *LHS,
Type *ResultTy = Type::getInt1Ty(LHS->getContext());
if (VectorType *VT = dyn_cast<VectorType>(LHS->getType()))
- ResultTy = VectorType::get(ResultTy, VT->getNumElements());
+ ResultTy = VectorType::get(ResultTy, VT->getElementCount());
LLVMContextImpl *pImpl = LHS->getType()->getContext().pImpl;
return pImpl->ExprConstants.getOrCreate(ResultTy, Key);