diff options
author | Eli Friedman <efriedma@quicinc.com> | 2024-05-09 16:50:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 16:50:01 -0700 |
commit | f893dccbba372792e7e7095d741f98a234654875 (patch) | |
tree | 67fdb1f867e4af93d4b39c4fa96200b05b2f9a06 /llvm/lib/Analysis/InlineCost.cpp | |
parent | 95f208f97e709139c3ecbce552bcf1e34b9fcf12 (diff) | |
download | llvm-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/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index c75460f..a531064 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -2046,13 +2046,11 @@ bool CallAnalyzer::visitCmpInst(CmpInst &I) { if (RHSBase && LHSBase == RHSBase) { // We have common bases, fold the icmp to a constant based on the // offsets. - Constant *CLHS = ConstantInt::get(LHS->getContext(), LHSOffset); - Constant *CRHS = ConstantInt::get(RHS->getContext(), RHSOffset); - if (Constant *C = ConstantExpr::getICmp(I.getPredicate(), CLHS, CRHS)) { - SimplifiedValues[&I] = C; - ++NumConstantPtrCmps; - return true; - } + SimplifiedValues[&I] = ConstantInt::getBool( + I.getType(), + ICmpInst::compare(LHSOffset, RHSOffset, I.getPredicate())); + ++NumConstantPtrCmps; + return true; } } |