aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2024-05-09 16:50:01 -0700
committerGitHub <noreply@github.com>2024-05-09 16:50:01 -0700
commitf893dccbba372792e7e7095d741f98a234654875 (patch)
tree67fdb1f867e4af93d4b39c4fa96200b05b2f9a06 /llvm/lib/IR/Constants.cpp
parent95f208f97e709139c3ecbce552bcf1e34b9fcf12 (diff)
downloadllvm-f893dccbba372792e7e7095d741f98a234654875.zip
llvm-f893dccbba372792e7e7095d741f98a234654875.tar.gz
llvm-f893dccbba372792e7e7095d741f98a234654875.tar.bz2
Replace uses of ConstantExpr::getCompare. (#91558)
Use ICmpInst::compare() where possible, ConstantFoldCompareInstOperands in other places. This only changes places where the either the fold is guaranteed to succeed, or the code doesn't use the resulting compare if we fail to fold.
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 5268ecc..db442c5 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -315,8 +315,8 @@ bool Constant::isElementWiseEqual(Value *Y) const {
Type *IntTy = VectorType::getInteger(VTy);
Constant *C0 = ConstantExpr::getBitCast(const_cast<Constant *>(this), IntTy);
Constant *C1 = ConstantExpr::getBitCast(cast<Constant>(Y), IntTy);
- Constant *CmpEq = ConstantExpr::getICmp(ICmpInst::ICMP_EQ, C0, C1);
- return isa<PoisonValue>(CmpEq) || match(CmpEq, m_One());
+ Constant *CmpEq = ConstantFoldCompareInstruction(ICmpInst::ICMP_EQ, C0, C1);
+ return CmpEq && (isa<PoisonValue>(CmpEq) || match(CmpEq, m_One()));
}
static bool