[llvm] IR: introduce CmpInst::PredicateSign (PR #116867)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 11:52:20 PST 2024
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/116867
Introduce CmpInst::PredicateSign, an abstraction over a floating-point predicate, and a pack of an integer predicate with samesign information, in order to ease extending large portions of the codebase that take a CmpInst::Predicate to respect the samesign flag.
We have chosen to demonstrate the utility of this new abstraction by migrating ValueTracking, InstructionSimplify, and InstCombine from CmpInst::Predicate to CmpInst::PredicateSign. There should be no functional changes, as we don't perform any extra optimizations with samesign in this patch.
The design approach taken by this patch allows for unaudited callers of APIs that take a CmpInst::PredicateSign to silently drop the samesign information; it does not pose a correctness issue, and allows us to migrate the codebase piece-wise.
-- 8< --
Based on #116866.
>From cf32c5b99c2388418c2acdbe9b265891beea24b7 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Tue, 19 Nov 2024 15:25:05 +0000
Subject: [PATCH 1/2] IR: de-duplicate two CmpInst routines (NFC)
De-duplicate the functions getSignedPredicate and getUnsignedPredicate,
nearly identical versions of which were present in CmpInst and ICmpInst,
creating less confusion.
---
llvm/include/llvm/IR/InstrTypes.h | 33 +++++++------
llvm/include/llvm/IR/Instructions.h | 24 ---------
llvm/lib/IR/Instructions.cpp | 76 ++++++++++++-----------------
3 files changed, 47 insertions(+), 86 deletions(-)
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 1c60eae7f2f85b..568761586326de 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -935,28 +935,29 @@ class CmpInst : public Instruction {
return isUnsigned(getPredicate());
}
- /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
- /// @returns the signed version of the unsigned predicate pred.
- /// return the signed version of a predicate
+ /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
+ /// @returns the predicate that would be the result if the operand were
+ /// regarded as signed. Asserts on FP predicates.
+ /// Static variant.
static Predicate getSignedPredicate(Predicate pred);
- /// For example, ULT->SLT, ULE->SLE, UGT->SGT, UGE->SGE, SLT->Failed assert
- /// @returns the signed version of the predicate for this instruction (which
- /// has to be an unsigned predicate).
- /// return the signed version of a predicate
- Predicate getSignedPredicate() {
+ /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
+ /// @returns the predicate that would be the result if the operand were
+ /// regarded as signed. Asserts on FP predicates.
+ Predicate getSignedPredicate() const {
return getSignedPredicate(getPredicate());
}
- /// For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert
- /// @returns the unsigned version of the signed predicate pred.
+ /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
+ /// @returns the predicate that would be the result if the operand were
+ /// regarded as unsigned. Asserts on FP predicates.
+ /// Static variant.
static Predicate getUnsignedPredicate(Predicate pred);
- /// For example, SLT->ULT, SLE->ULE, SGT->UGT, SGE->UGE, ULT->Failed assert
- /// @returns the unsigned version of the predicate for this instruction (which
- /// has to be an signed predicate).
- /// return the unsigned version of a predicate
- Predicate getUnsignedPredicate() {
+ /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
+ /// @returns the predicate that would be the result if the operand were
+ /// regarded as unsigned. Asserts on FP predicates.
+ Predicate getUnsignedPredicate() const {
return getUnsignedPredicate(getPredicate());
}
@@ -968,7 +969,7 @@ class CmpInst : public Instruction {
/// For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->Failed assert
/// @returns the unsigned version of the signed predicate pred or
/// the signed version of the signed predicate pred.
- Predicate getFlippedSignednessPredicate() {
+ Predicate getFlippedSignednessPredicate() const {
return getFlippedSignednessPredicate(getPredicate());
}
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 8eea659a00caf3..0e598d00952172 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1203,30 +1203,6 @@ class ICmpInst: public CmpInst {
#endif
}
- /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
- /// @returns the predicate that would be the result if the operand were
- /// regarded as signed.
- /// Return the signed version of the predicate
- Predicate getSignedPredicate() const {
- return getSignedPredicate(getPredicate());
- }
-
- /// This is a static version that you can use without an instruction.
- /// Return the signed version of the predicate.
- static Predicate getSignedPredicate(Predicate pred);
-
- /// For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
- /// @returns the predicate that would be the result if the operand were
- /// regarded as unsigned.
- /// Return the unsigned version of the predicate
- Predicate getUnsignedPredicate() const {
- return getUnsignedPredicate(getPredicate());
- }
-
- /// This is a static version that you can use without an instruction.
- /// Return the unsigned version of the predicate.
- static Predicate getUnsignedPredicate(Predicate pred);
-
void setSameSign(bool B = true) {
SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (B * SameSign);
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 5b89a27126150a..20d9fd2b07b48d 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -3573,32 +3573,6 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, CmpInst::Predicate Pred) {
return OS;
}
-ICmpInst::Predicate ICmpInst::getSignedPredicate(Predicate pred) {
- switch (pred) {
- default: llvm_unreachable("Unknown icmp predicate!");
- case ICMP_EQ: case ICMP_NE:
- case ICMP_SGT: case ICMP_SLT: case ICMP_SGE: case ICMP_SLE:
- return pred;
- case ICMP_UGT: return ICMP_SGT;
- case ICMP_ULT: return ICMP_SLT;
- case ICMP_UGE: return ICMP_SGE;
- case ICMP_ULE: return ICMP_SLE;
- }
-}
-
-ICmpInst::Predicate ICmpInst::getUnsignedPredicate(Predicate pred) {
- switch (pred) {
- default: llvm_unreachable("Unknown icmp predicate!");
- case ICMP_EQ: case ICMP_NE:
- case ICMP_UGT: case ICMP_ULT: case ICMP_UGE: case ICMP_ULE:
- return pred;
- case ICMP_SGT: return ICMP_UGT;
- case ICMP_SLT: return ICMP_ULT;
- case ICMP_SGE: return ICMP_UGE;
- case ICMP_SLE: return ICMP_ULE;
- }
-}
-
CmpInst::Predicate CmpInst::getSwappedPredicate(Predicate pred) {
switch (pred) {
default: llvm_unreachable("Unknown cmp predicate!");
@@ -3719,36 +3693,46 @@ CmpInst::Predicate CmpInst::getFlippedStrictnessPredicate(Predicate pred) {
}
CmpInst::Predicate CmpInst::getSignedPredicate(Predicate pred) {
- assert(CmpInst::isUnsigned(pred) && "Call only with unsigned predicates!");
-
switch (pred) {
default:
llvm_unreachable("Unknown predicate!");
- case CmpInst::ICMP_ULT:
- return CmpInst::ICMP_SLT;
- case CmpInst::ICMP_ULE:
- return CmpInst::ICMP_SLE;
- case CmpInst::ICMP_UGT:
- return CmpInst::ICMP_SGT;
- case CmpInst::ICMP_UGE:
- return CmpInst::ICMP_SGE;
+ case ICMP_EQ:
+ case ICMP_NE:
+ case ICMP_SGT:
+ case ICMP_SLT:
+ case ICMP_SGE:
+ case ICMP_SLE:
+ return pred;
+ case ICMP_UGT:
+ return ICMP_SGT;
+ case ICMP_ULT:
+ return ICMP_SLT;
+ case ICMP_UGE:
+ return ICMP_SGE;
+ case ICMP_ULE:
+ return ICMP_SLE;
}
}
CmpInst::Predicate CmpInst::getUnsignedPredicate(Predicate pred) {
- assert(CmpInst::isSigned(pred) && "Call only with signed predicates!");
-
switch (pred) {
default:
llvm_unreachable("Unknown predicate!");
- case CmpInst::ICMP_SLT:
- return CmpInst::ICMP_ULT;
- case CmpInst::ICMP_SLE:
- return CmpInst::ICMP_ULE;
- case CmpInst::ICMP_SGT:
- return CmpInst::ICMP_UGT;
- case CmpInst::ICMP_SGE:
- return CmpInst::ICMP_UGE;
+ case ICMP_EQ:
+ case ICMP_NE:
+ case ICMP_UGT:
+ case ICMP_ULT:
+ case ICMP_UGE:
+ case ICMP_ULE:
+ return pred;
+ case ICMP_SGT:
+ return ICMP_UGT;
+ case ICMP_SLT:
+ return ICMP_ULT;
+ case ICMP_SGE:
+ return ICMP_UGE;
+ case ICMP_SLE:
+ return ICMP_ULE;
}
}
>From f040f494d09345e197dd9a9098a987eec5f999ec Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Tue, 19 Nov 2024 15:25:05 +0000
Subject: [PATCH 2/2] IR: introduce ICmpInst::PredicateSign
Introduce CmpInst::PredicateSign, an abstraction over a floating-point
predicate, and a pack of an integer predicate with samesign information,
in order to ease extending large portions of the codebase that take a
CmpInst::Predicate to respect the samesign flag.
We have chosen to demonstrate the utility of this new abstraction by
migrating ValueTracking, InstructionSimplify, and InstCombine from
CmpInst::Predicate to CmpInst::PredicateSign. There should be no
functional changes, as we don't perform any extra optimizations with
samesign in this patch.
The design approach taken by this patch allows for unaudited callers of
APIs that take a CmpInst::PredicateSign to silently drop the samesign
information; it does not pose a correctness issue, and allows us to
migrate the codebase piece-wise.
---
.../llvm/Analysis/InstructionSimplify.h | 8 +-
llvm/include/llvm/Analysis/ValueTracking.h | 4 +-
llvm/include/llvm/IR/InstrTypes.h | 25 ++++++
llvm/include/llvm/IR/Instructions.h | 12 +++
.../Transforms/InstCombine/InstCombiner.h | 13 +--
llvm/lib/Analysis/InstructionSimplify.cpp | 85 ++++++++++---------
llvm/lib/Analysis/ValueTracking.cpp | 18 ++--
.../InstCombine/InstCombineCompares.cpp | 35 ++++----
.../InstCombine/InstCombineInternal.h | 10 +--
.../InstCombine/InstructionCombining.cpp | 6 +-
10 files changed, 129 insertions(+), 87 deletions(-)
diff --git a/llvm/include/llvm/Analysis/InstructionSimplify.h b/llvm/include/llvm/Analysis/InstructionSimplify.h
index cf7d3e044188a6..803050c7a0f438 100644
--- a/llvm/include/llvm/Analysis/InstructionSimplify.h
+++ b/llvm/include/llvm/Analysis/InstructionSimplify.h
@@ -152,12 +152,12 @@ Value *simplifyOrInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
Value *simplifyXorInst(Value *LHS, Value *RHS, const SimplifyQuery &Q);
/// Given operands for an ICmpInst, fold the result or return null.
-Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
+Value *simplifyICmpInst(CmpInst::PredicateSign Pred, Value *LHS, Value *RHS,
const SimplifyQuery &Q);
/// Given operands for an FCmpInst, fold the result or return null.
-Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- FastMathFlags FMF, const SimplifyQuery &Q);
+Value *simplifyFCmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q);
/// Given operands for a SelectInst, fold the result or return null.
Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
@@ -200,7 +200,7 @@ Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, ArrayRef<int> Mask,
//=== Helper functions for higher up the class hierarchy.
/// Given operands for a CmpInst, fold the result or return null.
-Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
+Value *simplifyCmpInst(CmpInst::PredicateSign Predicate, Value *LHS, Value *RHS,
const SimplifyQuery &Q);
/// Given operand for a UnaryOperator, fold the result or return null.
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 2b0377903ac8e3..81982b0a0a79d8 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -1246,7 +1246,7 @@ std::optional<bool> isImpliedCondition(const Value *LHS, const Value *RHS,
bool LHSIsTrue = true,
unsigned Depth = 0);
std::optional<bool> isImpliedCondition(const Value *LHS,
- CmpInst::Predicate RHSPred,
+ CmpInst::PredicateSign RHSPred,
const Value *RHSOp0, const Value *RHSOp1,
const DataLayout &DL,
bool LHSIsTrue = true,
@@ -1257,7 +1257,7 @@ std::optional<bool> isImpliedCondition(const Value *LHS,
std::optional<bool> isImpliedByDomCondition(const Value *Cond,
const Instruction *ContextI,
const DataLayout &DL);
-std::optional<bool> isImpliedByDomCondition(CmpInst::Predicate Pred,
+std::optional<bool> isImpliedByDomCondition(CmpInst::PredicateSign Pred,
const Value *LHS, const Value *RHS,
const Instruction *ContextI,
const DataLayout &DL);
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 568761586326de..ebba33d1a8f8ed 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -722,6 +722,31 @@ class CmpInst : public Instruction {
force_iteration_on_noniterable_enum);
}
+ /// An abstraction over a floating-point predicate, and a pack of an integer
+ /// predicate with samesign information. The getPredicateSign() family of
+ /// functions in ICmpInst construct and return this type. It is also implictly
+ /// constructed with a Predicate, dropping samesign information.
+ class PredicateSign {
+ Predicate Pred;
+ std::optional<bool> HasSameSign;
+
+ public:
+ PredicateSign(Predicate Pred, bool HasSameSign)
+ : Pred(Pred), HasSameSign(HasSameSign) {}
+
+ PredicateSign(Predicate Pred) : Pred(Pred) {
+ if (isIntPredicate(Pred))
+ HasSameSign = false;
+ }
+
+ operator Predicate() { return Pred; }
+
+ bool hasSameSign() {
+ assert(isIntPredicate(Pred) && HasSameSign);
+ return *HasSameSign;
+ }
+ };
+
protected:
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS,
Value *RHS, const Twine &Name = "",
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 0e598d00952172..8b1d9a1aa17d82 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -1203,6 +1203,18 @@ class ICmpInst: public CmpInst {
#endif
}
+ PredicateSign getPredicateSign() const {
+ return {getPredicate(), hasSameSign()};
+ }
+
+ PredicateSign getInversePredicateSign() const {
+ return {getInversePredicate(), hasSameSign()};
+ }
+
+ PredicateSign getSwappedPredicateSign() const {
+ return {getSwappedPredicate(), hasSameSign()};
+ }
+
void setSameSign(bool B = true) {
SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (B * SameSign);
}
diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
index 3075b7ebae59e6..850cf431d6e2e5 100644
--- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
+++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
@@ -157,7 +157,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
/// conditional branch or select to create a compare with a canonical
/// (inverted) predicate which is then more likely to be matched with other
/// values.
- static bool isCanonicalPredicate(CmpInst::Predicate Pred) {
+ static bool isCanonicalPredicate(CmpInst::PredicateSign Pred) {
switch (Pred) {
case CmpInst::ICMP_NE:
case CmpInst::ICMP_ULE:
@@ -185,11 +185,12 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
}
std::optional<std::pair<
- CmpInst::Predicate,
- Constant *>> static getFlippedStrictnessPredicateAndConstant(CmpInst::
- Predicate
- Pred,
- Constant *C);
+ CmpInst::PredicateSign,
+ Constant
+ *>> static getFlippedStrictnessPredicateAndConstant(CmpInst::
+ PredicateSign
+ Pred,
+ Constant *C);
static bool shouldAvoidAbsorbingNotIntoSelect(const SelectInst &SI) {
// a ? b : false and a ? true : b are the canonical form of logical and/or.
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 93b601b22c3a39..a375e0202676db 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -63,10 +63,11 @@ static Value *simplifyBinOp(unsigned, Value *, Value *, const SimplifyQuery &,
unsigned);
static Value *simplifyBinOp(unsigned, Value *, Value *, const FastMathFlags &,
const SimplifyQuery &, unsigned);
-static Value *simplifyCmpInst(unsigned, Value *, Value *, const SimplifyQuery &,
- unsigned);
-static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- const SimplifyQuery &Q, unsigned MaxRecurse);
+static Value *simplifyCmpInst(CmpInst::PredicateSign, Value *, Value *,
+ const SimplifyQuery &, unsigned);
+static Value *simplifyICmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q,
+ unsigned MaxRecurse);
static Value *simplifyOrInst(Value *, Value *, const SimplifyQuery &, unsigned);
static Value *simplifyXorInst(Value *, Value *, const SimplifyQuery &,
unsigned);
@@ -132,7 +133,7 @@ static Constant *getFalse(Type *Ty) { return ConstantInt::getFalse(Ty); }
static Constant *getTrue(Type *Ty) { return ConstantInt::getTrue(Ty); }
/// isSameCompare - Is V equivalent to the comparison "LHS Pred RHS"?
-static bool isSameCompare(Value *V, CmpInst::Predicate Pred, Value *LHS,
+static bool isSameCompare(Value *V, CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS) {
CmpInst *Cmp = dyn_cast<CmpInst>(V);
if (!Cmp)
@@ -150,7 +151,7 @@ static bool isSameCompare(Value *V, CmpInst::Predicate Pred, Value *LHS,
/// %cmp = icmp sle i32 %sel, %rhs
/// Compose new comparison by substituting %sel with either %tv or %fv
/// and see if it simplifies.
-static Value *simplifyCmpSelCase(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyCmpSelCase(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q, unsigned MaxRecurse,
Constant *TrueOrFalse) {
@@ -167,7 +168,7 @@ static Value *simplifyCmpSelCase(CmpInst::Predicate Pred, Value *LHS,
}
/// Simplify comparison with true branch of select
-static Value *simplifyCmpSelTrueCase(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyCmpSelTrueCase(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q,
unsigned MaxRecurse) {
@@ -176,7 +177,7 @@ static Value *simplifyCmpSelTrueCase(CmpInst::Predicate Pred, Value *LHS,
}
/// Simplify comparison with false branch of select
-static Value *simplifyCmpSelFalseCase(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyCmpSelFalseCase(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, Value *Cond,
const SimplifyQuery &Q,
unsigned MaxRecurse) {
@@ -471,7 +472,7 @@ static Value *threadBinOpOverSelect(Instruction::BinaryOps Opcode, Value *LHS,
/// We can simplify %cmp1 to true, because both branches of select are
/// less than 3. We compose new comparison by substituting %tmp with both
/// branches of select and see if it can be simplified.
-static Value *threadCmpOverSelect(CmpInst::Predicate Pred, Value *LHS,
+static Value *threadCmpOverSelect(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) {
// Recursion is always used, so bail out at once if we already hit the limit.
@@ -564,8 +565,9 @@ static Value *threadBinOpOverPHI(Instruction::BinaryOps Opcode, Value *LHS,
/// comparison by seeing whether comparing with all of the incoming phi values
/// yields the same result every time. If so returns the common result,
/// otherwise returns null.
-static Value *threadCmpOverPHI(CmpInst::Predicate Pred, Value *LHS, Value *RHS,
- const SimplifyQuery &Q, unsigned MaxRecurse) {
+static Value *threadCmpOverPHI(CmpInst::PredicateSign Pred, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q,
+ unsigned MaxRecurse) {
// Recursion is always used, so bail out at once if we already hit the limit.
if (!MaxRecurse--)
return nullptr;
@@ -1001,7 +1003,7 @@ Value *llvm::simplifyMulInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
/// Given a predicate and two operands, return true if the comparison is true.
/// This is a helper for div/rem simplification where we return some other value
/// when we can prove a relationship between the operands.
-static bool isICmpTrue(ICmpInst::Predicate Pred, Value *LHS, Value *RHS,
+static bool isICmpTrue(ICmpInst::PredicateSign Pred, Value *LHS, Value *RHS,
const SimplifyQuery &Q, unsigned MaxRecurse) {
Value *V = simplifyICmpInst(Pred, LHS, RHS, Q, MaxRecurse);
Constant *C = dyn_cast_or_null<Constant>(V);
@@ -2597,7 +2599,7 @@ static Type *getCompareTy(Value *Op) {
/// Rummage around inside V looking for something equivalent to the comparison
/// "LHS Pred RHS". Return such a value if found, otherwise return null.
/// Helper function for analyzing max/min idioms.
-static Value *extractEquivalentCondition(Value *V, CmpInst::Predicate Pred,
+static Value *extractEquivalentCondition(Value *V, CmpInst::PredicateSign Pred,
Value *LHS, Value *RHS) {
SelectInst *SI = dyn_cast<SelectInst>(V);
if (!SI)
@@ -2706,7 +2708,7 @@ static bool haveNonOverlappingStorage(const Value *V1, const Value *V2) {
// If the C and C++ standards are ever made sufficiently restrictive in this
// area, it may be possible to update LLVM's semantics accordingly and reinstate
// this optimization.
-static Constant *computePointerICmp(CmpInst::Predicate Pred, Value *LHS,
+static Constant *computePointerICmp(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) {
assert(LHS->getType() == RHS->getType() && "Must have same types");
const DataLayout &DL = Q.DL;
@@ -2855,7 +2857,7 @@ static Constant *computePointerICmp(CmpInst::Predicate Pred, Value *LHS,
}
/// Fold an icmp when its operands have i1 scalar type.
-static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyICmpOfBools(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) {
Type *ITy = getCompareTy(LHS); // The return type.
Type *OpTy = LHS->getType(); // The operand type.
@@ -2958,7 +2960,7 @@ static Value *simplifyICmpOfBools(CmpInst::Predicate Pred, Value *LHS,
}
/// Try hard to fold icmp with zero RHS because this is a common case.
-static Value *simplifyICmpWithZero(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyICmpWithZero(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q) {
if (!match(RHS, m_Zero()))
return nullptr;
@@ -3018,7 +3020,7 @@ static Value *simplifyICmpWithZero(CmpInst::Predicate Pred, Value *LHS,
return nullptr;
}
-static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyICmpWithConstant(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const InstrInfoQuery &IIQ) {
Type *ITy = getCompareTy(RHS); // The return type.
@@ -3066,7 +3068,7 @@ static Value *simplifyICmpWithConstant(CmpInst::Predicate Pred, Value *LHS,
return nullptr;
}
-static Value *simplifyICmpWithBinOpOnLHS(CmpInst::Predicate Pred,
+static Value *simplifyICmpWithBinOpOnLHS(CmpInst::PredicateSign Pred,
BinaryOperator *LBO, Value *RHS,
const SimplifyQuery &Q,
unsigned MaxRecurse) {
@@ -3223,7 +3225,7 @@ static Value *simplifyICmpWithBinOpOnLHS(CmpInst::Predicate Pred,
// *) C1 < C2 && C1 >= 0, or
// *) C2 < C1 && C1 <= 0.
//
-static bool trySimplifyICmpWithAdds(CmpInst::Predicate Pred, Value *LHS,
+static bool trySimplifyICmpWithAdds(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const InstrInfoQuery &IIQ) {
// TODO: only support icmp slt for now.
if (Pred != CmpInst::ICMP_SLT || !IIQ.UseInstrInfo)
@@ -3248,7 +3250,7 @@ static bool trySimplifyICmpWithAdds(CmpInst::Predicate Pred, Value *LHS,
/// TODO: A large part of this logic is duplicated in InstCombine's
/// foldICmpBinOp(). We should be able to share that and avoid the code
/// duplication.
-static Value *simplifyICmpWithBinOp(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyICmpWithBinOp(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) {
BinaryOperator *LBO = dyn_cast<BinaryOperator>(LHS);
@@ -3482,7 +3484,7 @@ static Value *simplifyICmpWithBinOp(CmpInst::Predicate Pred, Value *LHS,
/// simplify integer comparisons where at least one operand of the compare
/// matches an integer min/max idiom.
-static Value *simplifyICmpWithMinMax(CmpInst::Predicate Pred, Value *LHS,
+static Value *simplifyICmpWithMinMax(CmpInst::PredicateSign Pred, Value *LHS,
Value *RHS, const SimplifyQuery &Q,
unsigned MaxRecurse) {
Type *ITy = getCompareTy(LHS); // The return type.
@@ -3667,7 +3669,7 @@ static Value *simplifyICmpWithMinMax(CmpInst::Predicate Pred, Value *LHS,
return nullptr;
}
-static Value *simplifyICmpWithDominatingAssume(CmpInst::Predicate Predicate,
+static Value *simplifyICmpWithDominatingAssume(CmpInst::PredicateSign Predicate,
Value *LHS, Value *RHS,
const SimplifyQuery &Q) {
// Gracefully handle instructions that have not been inserted yet.
@@ -3690,7 +3692,7 @@ static Value *simplifyICmpWithDominatingAssume(CmpInst::Predicate Predicate,
return nullptr;
}
-static Value *simplifyICmpWithIntrinsicOnLHS(CmpInst::Predicate Pred,
+static Value *simplifyICmpWithIntrinsicOnLHS(CmpInst::PredicateSign Pred,
Value *LHS, Value *RHS) {
auto *II = dyn_cast<IntrinsicInst>(LHS);
if (!II)
@@ -3753,9 +3755,9 @@ static std::optional<ConstantRange> getRange(Value *V,
/// Given operands for an ICmpInst, see if we can fold the result.
/// If not, this returns null.
-static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- const SimplifyQuery &Q, unsigned MaxRecurse) {
- CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate;
+static Value *simplifyICmpInst(CmpInst::PredicateSign Pred, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q,
+ unsigned MaxRecurse) {
assert(CmpInst::isIntPredicate(Pred) && "Not an integer compare!");
if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
@@ -4062,17 +4064,16 @@ static Value *simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
return nullptr;
}
-Value *llvm::simplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- const SimplifyQuery &Q) {
+Value *llvm::simplifyICmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q) {
return ::simplifyICmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
}
/// Given operands for an FCmpInst, see if we can fold the result.
/// If not, this returns null.
-static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- FastMathFlags FMF, const SimplifyQuery &Q,
- unsigned MaxRecurse) {
- CmpInst::Predicate Pred = (CmpInst::Predicate)Predicate;
+static Value *simplifyFCmpInst(CmpInst::PredicateSign Pred, Value *LHS,
+ Value *RHS, FastMathFlags FMF,
+ const SimplifyQuery &Q, unsigned MaxRecurse) {
assert(CmpInst::isFPPredicate(Pred) && "Not an FP compare!");
if (Constant *CLHS = dyn_cast<Constant>(LHS)) {
@@ -4297,8 +4298,9 @@ static Value *simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
return nullptr;
}
-Value *llvm::simplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- FastMathFlags FMF, const SimplifyQuery &Q) {
+Value *llvm::simplifyFCmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, FastMathFlags FMF,
+ const SimplifyQuery &Q) {
return ::simplifyFCmpInst(Predicate, LHS, RHS, FMF, Q, RecursionLimit);
}
@@ -4534,7 +4536,7 @@ static Value *simplifySelectBitTest(Value *TrueVal, Value *FalseVal, Value *X,
}
static Value *simplifyCmpSelOfMaxMin(Value *CmpLHS, Value *CmpRHS,
- ICmpInst::Predicate Pred, Value *TVal,
+ CmpInst::PredicateSign Pred, Value *TVal,
Value *FVal) {
// Canonicalize common cmp+sel operand as CmpLHS.
if (CmpRHS == TVal || CmpRHS == FVal) {
@@ -4608,7 +4610,7 @@ static Value *simplifyCmpSelOfMaxMin(Value *CmpLHS, Value *CmpRHS,
/// An alternative way to test if a bit is set or not uses sgt/slt instead of
/// eq/ne.
static Value *simplifySelectWithFakeICmpEq(Value *CmpLHS, Value *CmpRHS,
- ICmpInst::Predicate Pred,
+ CmpInst::PredicateSign Pred,
Value *TrueVal, Value *FalseVal) {
if (auto Res = decomposeBitTestICmp(CmpLHS, CmpRHS, Pred))
return simplifySelectBitTest(TrueVal, FalseVal, Res->X, &Res->Mask,
@@ -6119,15 +6121,16 @@ Value *llvm::simplifyBinOp(unsigned Opcode, Value *LHS, Value *RHS,
}
/// Given operands for a CmpInst, see if we can fold the result.
-static Value *simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- const SimplifyQuery &Q, unsigned MaxRecurse) {
- if (CmpInst::isIntPredicate((CmpInst::Predicate)Predicate))
+static Value *simplifyCmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q,
+ unsigned MaxRecurse) {
+ if (CmpInst::isIntPredicate(Predicate))
return simplifyICmpInst(Predicate, LHS, RHS, Q, MaxRecurse);
return simplifyFCmpInst(Predicate, LHS, RHS, FastMathFlags(), Q, MaxRecurse);
}
-Value *llvm::simplifyCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
- const SimplifyQuery &Q) {
+Value *llvm::simplifyCmpInst(CmpInst::PredicateSign Predicate, Value *LHS,
+ Value *RHS, const SimplifyQuery &Q) {
return ::simplifyCmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
}
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index c48068afc04816..e223aa5aa2aa4c 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9104,7 +9104,7 @@ bool llvm::matchSimpleRecurrence(const BinaryOperator *I, PHINode *&P,
}
/// Return true if "icmp Pred LHS RHS" is always true.
-static bool isTruePredicate(CmpInst::Predicate Pred, const Value *LHS,
+static bool isTruePredicate(CmpInst::PredicateSign Pred, const Value *LHS,
const Value *RHS) {
if (ICmpInst::isTrueWhenEqual(Pred) && LHS == RHS)
return true;
@@ -9186,7 +9186,7 @@ static bool isTruePredicate(CmpInst::Predicate Pred, const Value *LHS,
/// Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred
/// ALHS ARHS" is true. Otherwise, return std::nullopt.
static std::optional<bool>
-isImpliedCondOperands(CmpInst::Predicate Pred, const Value *ALHS,
+isImpliedCondOperands(CmpInst::PredicateSign Pred, const Value *ALHS,
const Value *ARHS, const Value *BLHS, const Value *BRHS) {
switch (Pred) {
default:
@@ -9257,7 +9257,7 @@ static std::optional<bool> isImpliedCondCommonOperandWithCR(
/// is true. Return false if LHS implies RHS is false. Otherwise, return
/// std::nullopt if we can't infer anything.
static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
- CmpInst::Predicate RPred,
+ CmpInst::PredicateSign RPred,
const Value *R0, const Value *R1,
const DataLayout &DL,
bool LHSIsTrue) {
@@ -9266,8 +9266,8 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
// The rest of the logic assumes the LHS condition is true. If that's not the
// case, invert the predicate to make it so.
- CmpInst::Predicate LPred =
- LHSIsTrue ? LHS->getPredicate() : LHS->getInversePredicate();
+ CmpInst::PredicateSign LPred =
+ LHSIsTrue ? LHS->getPredicateSign() : LHS->getInversePredicateSign();
// We can have non-canonical operands, so try to normalize any common operand
// to L0/R0.
@@ -9355,7 +9355,7 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
/// expect the RHS to be an icmp and the LHS to be an 'and', 'or', or a 'select'
/// instruction.
static std::optional<bool>
-isImpliedCondAndOr(const Instruction *LHS, CmpInst::Predicate RHSPred,
+isImpliedCondAndOr(const Instruction *LHS, CmpInst::PredicateSign RHSPred,
const Value *RHSOp0, const Value *RHSOp1,
const DataLayout &DL, bool LHSIsTrue, unsigned Depth) {
// The LHS must be an 'or', 'and', or a 'select' instruction.
@@ -9385,7 +9385,7 @@ isImpliedCondAndOr(const Instruction *LHS, CmpInst::Predicate RHSPred,
}
std::optional<bool>
-llvm::isImpliedCondition(const Value *LHS, CmpInst::Predicate RHSPred,
+llvm::isImpliedCondition(const Value *LHS, CmpInst::PredicateSign RHSPred,
const Value *RHSOp0, const Value *RHSOp1,
const DataLayout &DL, bool LHSIsTrue, unsigned Depth) {
// Bail out when we hit the limit.
@@ -9439,7 +9439,7 @@ std::optional<bool> llvm::isImpliedCondition(const Value *LHS, const Value *RHS,
if (const ICmpInst *RHSCmp = dyn_cast<ICmpInst>(RHS)) {
if (auto Implied = isImpliedCondition(
- LHS, RHSCmp->getPredicate(), RHSCmp->getOperand(0),
+ LHS, RHSCmp->getPredicateSign(), RHSCmp->getOperand(0),
RHSCmp->getOperand(1), DL, LHSIsTrue, Depth))
return InvertRHS ? !*Implied : *Implied;
return std::nullopt;
@@ -9516,7 +9516,7 @@ std::optional<bool> llvm::isImpliedByDomCondition(const Value *Cond,
return std::nullopt;
}
-std::optional<bool> llvm::isImpliedByDomCondition(CmpInst::Predicate Pred,
+std::optional<bool> llvm::isImpliedByDomCondition(CmpInst::PredicateSign Pred,
const Value *LHS,
const Value *RHS,
const Instruction *ContextI,
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d602a907e72bcd..22359e9bb1898a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -631,7 +631,7 @@ static Value *rewriteGEPAsOffset(Value *Start, Value *Base, GEPNoWrapFlags NW,
/// We can look through PHIs, GEPs and casts in order to determine a common base
/// between GEPLHS and RHS.
static Instruction *transformToIndexedCompare(GEPOperator *GEPLHS, Value *RHS,
- ICmpInst::Predicate Cond,
+ CmpInst::PredicateSign Cond,
const DataLayout &DL,
InstCombiner &IC) {
// FIXME: Support vector of pointers.
@@ -675,7 +675,7 @@ static Instruction *transformToIndexedCompare(GEPOperator *GEPLHS, Value *RHS,
/// Fold comparisons between a GEP instruction and something else. At this point
/// we know that the GEP is on the LHS of the comparison.
Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
- ICmpInst::Predicate Cond,
+ CmpInst::PredicateSign Cond,
Instruction &I) {
// Don't transform signed compares of GEPs into index compares. Even if the
// GEP is inbounds, the final add of the base pointer can have signed overflow
@@ -912,7 +912,7 @@ bool InstCombinerImpl::foldAllocaCmp(AllocaInst *Alloca) {
/// Fold "icmp pred (X+C), X".
Instruction *InstCombinerImpl::foldICmpAddOpConst(Value *X, const APInt &C,
- ICmpInst::Predicate Pred) {
+ CmpInst::PredicateSign Pred) {
// From this point on, we know that (X+C <= X) --> (X+C < X) because C != 0,
// so the values can never be equal. Similarly for all other "or equals"
// operators.
@@ -3926,7 +3926,7 @@ Instruction *InstCombinerImpl::foldICmpBinOpWithConstant(ICmpInst &Cmp,
}
static Instruction *
-foldICmpUSubSatOrUAddSatWithConstant(ICmpInst::Predicate Pred,
+foldICmpUSubSatOrUAddSatWithConstant(CmpInst::PredicateSign Pred,
SaturatingInst *II, const APInt &C,
InstCombiner::BuilderTy &Builder) {
// This transform may end up producing more than one instruction for the
@@ -4011,8 +4011,8 @@ foldICmpUSubSatOrUAddSatWithConstant(ICmpInst::Predicate Pred,
}
static Instruction *
-foldICmpOfCmpIntrinsicWithConstant(ICmpInst::Predicate Pred, IntrinsicInst *I,
- const APInt &C,
+foldICmpOfCmpIntrinsicWithConstant(CmpInst::PredicateSign Pred,
+ IntrinsicInst *I, const APInt &C,
InstCombiner::BuilderTy &Builder) {
std::optional<ICmpInst::Predicate> NewPredicate = std::nullopt;
switch (Pred) {
@@ -4210,7 +4210,7 @@ Instruction *InstCombinerImpl::foldICmpInstWithConstantNotInt(ICmpInst &I) {
return nullptr;
}
-Instruction *InstCombinerImpl::foldSelectICmp(ICmpInst::Predicate Pred,
+Instruction *InstCombinerImpl::foldSelectICmp(CmpInst::PredicateSign Pred,
SelectInst *SI, Value *RHS,
const ICmpInst &I) {
// Try to fold the comparison into the select arms, which will cause the
@@ -4381,8 +4381,9 @@ static bool isMaskOrZero(const Value *V, bool Not, const SimplifyQuery &Q,
/// The Mask can be a constant, too.
/// For some predicates, the operands are commutative.
/// For others, x can only be on a specific side.
-static Value *foldICmpWithLowBitMaskedVal(ICmpInst::Predicate Pred, Value *Op0,
- Value *Op1, const SimplifyQuery &Q,
+static Value *foldICmpWithLowBitMaskedVal(CmpInst::PredicateSign Pred,
+ Value *Op0, Value *Op1,
+ const SimplifyQuery &Q,
InstCombiner &IC) {
ICmpInst::Predicate DstPred;
@@ -5493,7 +5494,7 @@ Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I,
Instruction *InstCombinerImpl::foldICmpWithMinMax(Instruction &I,
MinMaxIntrinsic *MinMax,
Value *Z,
- ICmpInst::Predicate Pred) {
+ CmpInst::PredicateSign Pred) {
Value *X = MinMax->getLHS();
Value *Y = MinMax->getRHS();
if (ICmpInst::isSigned(Pred) && !MinMax->isSigned())
@@ -6846,9 +6847,9 @@ Instruction *InstCombinerImpl::foldICmpUsingBoolRange(ICmpInst &I) {
return nullptr;
}
-std::optional<std::pair<CmpInst::Predicate, Constant *>>
-InstCombiner::getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred,
- Constant *C) {
+std::optional<std::pair<CmpInst::PredicateSign, Constant *>>
+InstCombiner::getFlippedStrictnessPredicateAndConstant(
+ CmpInst::PredicateSign Pred, Constant *C) {
assert(ICmpInst::isRelational(Pred) && ICmpInst::isIntPredicate(Pred) &&
"Only for relational integer predicates.");
@@ -7253,7 +7254,7 @@ static Instruction *foldReductionIdiom(ICmpInst &I,
}
// This helper will be called with icmp operands in both orders.
-Instruction *InstCombinerImpl::foldICmpCommutative(ICmpInst::Predicate Pred,
+Instruction *InstCombinerImpl::foldICmpCommutative(CmpInst::PredicateSign Pred,
Value *Op0, Value *Op1,
ICmpInst &CxtI) {
// Try to optimize 'icmp GEP, P' or 'icmp P, GEP'.
@@ -7381,7 +7382,7 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
Changed = true;
}
- if (Value *V = simplifyICmpInst(I.getPredicate(), Op0, Op1, Q))
+ if (Value *V = simplifyICmpInst(I.getPredicateSign(), Op0, Op1, Q))
return replaceInstUsesWith(I, V);
// Comparing -val or val with non-zero is the same as just comparing val
@@ -7488,10 +7489,10 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
if (Instruction *Res = foldICmpInstWithConstantNotInt(I))
return Res;
- if (Instruction *Res = foldICmpCommutative(I.getPredicate(), Op0, Op1, I))
+ if (Instruction *Res = foldICmpCommutative(I.getPredicateSign(), Op0, Op1, I))
return Res;
if (Instruction *Res =
- foldICmpCommutative(I.getSwappedPredicate(), Op1, Op0, I))
+ foldICmpCommutative(I.getSwappedPredicateSign(), Op1, Op0, I))
return Res;
if (I.isCommutative()) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index adbd9186c59c5a..03f5c6998f0f48 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -653,8 +653,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN);
Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
- ICmpInst::Predicate Cond, Instruction &I);
- Instruction *foldSelectICmp(ICmpInst::Predicate Pred, SelectInst *SI,
+ CmpInst::PredicateSign Cond, Instruction &I);
+ Instruction *foldSelectICmp(CmpInst::PredicateSign Pred, SelectInst *SI,
Value *RHS, const ICmpInst &I);
bool foldAllocaCmp(AllocaInst *Alloca);
Instruction *foldCmpLoadFromIndexedGlobal(LoadInst *LI,
@@ -664,7 +664,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
Instruction *foldFCmpIntToFPConst(FCmpInst &I, Instruction *LHSI,
Constant *RHSC);
Instruction *foldICmpAddOpConst(Value *X, const APInt &C,
- ICmpInst::Predicate Pred);
+ CmpInst::PredicateSign Pred);
Instruction *foldICmpWithCastOp(ICmpInst &ICmp);
Instruction *foldICmpWithZextOrSext(ICmpInst &ICmp);
@@ -678,7 +678,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
const APInt &C);
Instruction *foldICmpBinOp(ICmpInst &Cmp, const SimplifyQuery &SQ);
Instruction *foldICmpWithMinMax(Instruction &I, MinMaxIntrinsic *MinMax,
- Value *Z, ICmpInst::Predicate Pred);
+ Value *Z, CmpInst::PredicateSign Pred);
Instruction *foldICmpEquality(ICmpInst &Cmp);
Instruction *foldIRemByPowerOfTwoToBitTest(ICmpInst &I);
Instruction *foldSignBitTest(ICmpInst &I);
@@ -736,7 +736,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
const APInt &C);
Instruction *foldICmpBitCast(ICmpInst &Cmp);
Instruction *foldICmpWithTrunc(ICmpInst &Cmp);
- Instruction *foldICmpCommutative(ICmpInst::Predicate Pred, Value *Op0,
+ Instruction *foldICmpCommutative(CmpInst::PredicateSign Pred, Value *Op0,
Value *Op1, ICmpInst &CxtI);
// Helpers of visitSelectInst().
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 32f2a30afad48f..21c2248542bbf1 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1753,9 +1753,9 @@ static Value *simplifyInstructionWithPHI(Instruction &I, PHINode *PN,
if (TerminatorBI && TerminatorBI->isConditional() &&
TerminatorBI->getSuccessor(0) != TerminatorBI->getSuccessor(1) && ICmp) {
bool LHSIsTrue = TerminatorBI->getSuccessor(0) == PN->getParent();
- std::optional<bool> ImpliedCond =
- isImpliedCondition(TerminatorBI->getCondition(), ICmp->getPredicate(),
- Ops[0], Ops[1], DL, LHSIsTrue);
+ std::optional<bool> ImpliedCond = isImpliedCondition(
+ TerminatorBI->getCondition(), ICmp->getPredicateSign(), Ops[0], Ops[1],
+ DL, LHSIsTrue);
if (ImpliedCond)
return ConstantInt::getBool(I.getType(), ImpliedCond.value());
}
More information about the llvm-commits
mailing list