[PATCH] D120609: [Analysis] Simplify the interface to llvm::getICmpCode. NFC
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 25 21:52:36 PST 2022
craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, lebedev.ri.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.
Instead of passing an InstCmpInt * and a bool just pass the predicate
from the caller.
I'm considering moving the similar FCmp functions from InstCombine
over here and this makes the interface consistent with what is used
for FCmp.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120609
Files:
llvm/include/llvm/Analysis/CmpInstAnalysis.h
llvm/lib/Analysis/CmpInstAnalysis.cpp
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1251,7 +1251,8 @@
if (LHS->getOperand(0) == RHS->getOperand(0) &&
LHS->getOperand(1) == RHS->getOperand(1)) {
Value *Op0 = LHS->getOperand(0), *Op1 = LHS->getOperand(1);
- unsigned Code = getICmpCode(LHS) & getICmpCode(RHS);
+ unsigned Code =
+ getICmpCode(LHS->getPredicate()) & getICmpCode(RHS->getPredicate());
bool IsSigned = LHS->isSigned() || RHS->isSigned();
return getNewICmpValue(Code, IsSigned, Op0, Op1, Builder);
}
@@ -2570,7 +2571,8 @@
if (LHS0 == RHS1 && LHS1 == RHS0)
LHS->swapOperands();
if (LHS0 == RHS0 && LHS1 == RHS1) {
- unsigned Code = getICmpCode(LHS) | getICmpCode(RHS);
+ unsigned Code =
+ getICmpCode(LHS->getPredicate()) | getICmpCode(RHS->getPredicate());
bool IsSigned = LHS->isSigned() || RHS->isSigned();
return getNewICmpValue(Code, IsSigned, LHS0, LHS1, Builder);
}
@@ -3094,7 +3096,8 @@
LHS->getOperand(1) == RHS->getOperand(1)) {
// (icmp1 A, B) ^ (icmp2 A, B) --> (icmp3 A, B)
Value *Op0 = LHS->getOperand(0), *Op1 = LHS->getOperand(1);
- unsigned Code = getICmpCode(LHS) ^ getICmpCode(RHS);
+ unsigned Code =
+ getICmpCode(LHS->getPredicate()) ^ getICmpCode(RHS->getPredicate());
bool IsSigned = LHS->isSigned() || RHS->isSigned();
return getNewICmpValue(Code, IsSigned, Op0, Op1, Builder);
}
Index: llvm/lib/Analysis/CmpInstAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/CmpInstAnalysis.cpp
+++ llvm/lib/Analysis/CmpInstAnalysis.cpp
@@ -18,9 +18,7 @@
using namespace llvm;
-unsigned llvm::getICmpCode(const ICmpInst *ICI, bool InvertPred) {
- ICmpInst::Predicate Pred = InvertPred ? ICI->getInversePredicate()
- : ICI->getPredicate();
+unsigned llvm::getICmpCode(CmpInst::Predicate Pred) {
switch (Pred) {
// False -> 0
case ICmpInst::ICMP_UGT: return 1; // 001
Index: llvm/include/llvm/Analysis/CmpInstAnalysis.h
===================================================================
--- llvm/include/llvm/Analysis/CmpInstAnalysis.h
+++ llvm/include/llvm/Analysis/CmpInstAnalysis.h
@@ -17,7 +17,6 @@
#include "llvm/IR/InstrTypes.h"
namespace llvm {
- class ICmpInst;
class Type;
class Value;
@@ -44,7 +43,7 @@
/// 110 6 A <= B
/// 111 7 Always true
///
- unsigned getICmpCode(const ICmpInst *ICI, bool InvertPred = false);
+ unsigned getICmpCode(CmpInst::Predicate Pred);
/// This is the complement of getICmpCode. It turns a predicate code into
/// either a constant true or false or the predicate for a new ICmp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120609.411578.patch
Type: text/x-patch
Size: 2942 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220226/ad87eb77/attachment.bin>
More information about the llvm-commits
mailing list