Skip to content

Commit 5da6f23

Browse files
committed
[ConstantFPRange] Address review comments. NFC.
1 parent 23f064f commit 5da6f23

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

llvm/lib/IR/ConstantFPRange.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,15 @@ ConstantFPRange ConstantFPRange::getNonNaN(const fltSemantics &Sem) {
108108
/*MayBeQNaN=*/false, /*MayBeSNaN=*/false);
109109
}
110110

111+
/// Return true for ULT/UGT/OLT/OGT
112+
static bool fcmpPredExcludesEqual(FCmpInst::Predicate Pred) {
113+
return !(Pred & FCmpInst::FCMP_OEQ);
114+
}
115+
111116
/// Return [-inf, V) or [-inf, V]
112117
static ConstantFPRange makeLessThan(APFloat V, FCmpInst::Predicate Pred) {
113118
const fltSemantics &Sem = V.getSemantics();
114-
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred))) {
119+
if (fcmpPredExcludesEqual(Pred)) {
115120
if (V.isNegInfinity())
116121
return ConstantFPRange::getEmpty(Sem);
117122
V.next(/*nextDown=*/true);
@@ -123,7 +128,7 @@ static ConstantFPRange makeLessThan(APFloat V, FCmpInst::Predicate Pred) {
123128
/// Return (V, +inf] or [V, +inf]
124129
static ConstantFPRange makeGreaterThan(APFloat V, FCmpInst::Predicate Pred) {
125130
const fltSemantics &Sem = V.getSemantics();
126-
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred))) {
131+
if (fcmpPredExcludesEqual(Pred)) {
127132
if (V.isPosInfinity())
128133
return ConstantFPRange::getEmpty(Sem);
129134
V.next(/*nextDown=*/false);
@@ -135,7 +140,7 @@ static ConstantFPRange makeGreaterThan(APFloat V, FCmpInst::Predicate Pred) {
135140
/// Make sure that +0/-0 are both included in the range.
136141
static ConstantFPRange extendZeroIfEqual(const ConstantFPRange &CR,
137142
FCmpInst::Predicate Pred) {
138-
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred)))
143+
if (fcmpPredExcludesEqual(Pred))
139144
return CR;
140145

141146
APFloat Lower = CR.getLower();

0 commit comments

Comments
 (0)