Skip to content

Commit

Permalink
[ConstantFPRange] Address review comments. NFC.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed Oct 1, 2024
1 parent 203d316 commit 2295fdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions llvm/lib/IR/ConstantFPRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ConstantFPRange ConstantFPRange::getNonNaN(const fltSemantics &Sem) {
/// Return [-inf, V) or [-inf, V]
static ConstantFPRange makeLessThan(APFloat V, FCmpInst::Predicate Pred) {
const fltSemantics &Sem = V.getSemantics();
if (!(Pred & FCmpInst::FCMP_OEQ)) {
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred))) {
if (V.isNegInfinity())
return ConstantFPRange::getEmpty(Sem);
V.next(/*nextDown=*/true);
Expand All @@ -124,7 +124,7 @@ static ConstantFPRange makeLessThan(APFloat V, FCmpInst::Predicate Pred) {
/// Return (V, +inf] or [V, +inf]
static ConstantFPRange makeGreaterThan(APFloat V, FCmpInst::Predicate Pred) {
const fltSemantics &Sem = V.getSemantics();
if (!(Pred & FCmpInst::FCMP_OEQ)) {
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred))) {
if (V.isPosInfinity())
return ConstantFPRange::getEmpty(Sem);
V.next(/*nextDown=*/false);
Expand All @@ -136,7 +136,7 @@ static ConstantFPRange makeGreaterThan(APFloat V, FCmpInst::Predicate Pred) {
/// Make sure that +0/-0 are both included in the range.
static ConstantFPRange extendZeroIfEqual(const ConstantFPRange &CR,
FCmpInst::Predicate Pred) {
if (!(Pred & FCmpInst::FCMP_OEQ))
if (FCmpInst::isFalseWhenEqual(FCmpInst::getOrderedPredicate(Pred)))
return CR;

APFloat Lower = CR.getLower();
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/IR/ConstantFPRangeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ TEST_F(ConstantFPRangeTest, makeAllowedFCmpRegion) {
Optimal = Optimal.unionWith(ConstantFPRange(V));
});

ASSERT_TRUE(Res.contains(Optimal))
EXPECT_TRUE(Res.contains(Optimal))
<< "Wrong result for makeAllowedFCmpRegion(" << Pred << ", " << CR
<< "). Expected " << Optimal << ", but got " << Res;
EXPECT_EQ(Res, Optimal)
Expand Down

0 comments on commit 2295fdc

Please sign in to comment.