Skip to content

Commit 7b27969

Browse files
committed
Fix minor Staylic issue
1 parent ea3f94f commit 7b27969

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7909,7 +7909,8 @@ static Instruction *foldFCmpFNegCommonOp(FCmpInst &I) {
79097909
static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
79107910
Constant *RHSC, InstCombinerImpl &CI) {
79117911
const CmpInst::Predicate Pred = I.getPredicate();
7912-
Value *X, *Y;
7912+
Value *X = LHSI->getOperand(0);
7913+
Value *Y = LHSI->getOperand(1);
79137914
switch (Pred) {
79147915
default:
79157916
break;
@@ -7919,8 +7920,10 @@ static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
79197920
case FCmpInst::FCMP_OEQ:
79207921
case FCmpInst::FCMP_OGE:
79217922
case FCmpInst::FCMP_OLE:
7922-
// Skip optimization: fsub x, y unless guaranteed !isinf(x) ||
7923-
// !isinf(y).
7923+
// The optimization is not valid if X and Y are infinities of the same
7924+
// sign, i.e. the inf - inf = nan case. If the fsub has the ninf or nnan
7925+
// flag then we can assume we do not have that case. Otherwise we might be
7926+
// able to prove that either X or Y is not infinity.
79247927
if (!LHSI->hasNoNaNs() && !LHSI->hasNoInfs() &&
79257928
!isKnownNeverInfinity(LHSI->getOperand(1), /*Depth=*/0,
79267929
CI.getSimplifyQuery().getWithInstruction(&I)) &&
@@ -7937,7 +7940,6 @@ static Instruction *foldFCmpFSubIntoFCmp(FCmpInst &I, Instruction *LHSI,
79377940
case FCmpInst::FCMP_ULE:
79387941
// fcmp pred (x - y), 0 --> fcmp pred x, y
79397942
if (match(RHSC, m_AnyZeroFP()) &&
7940-
match(LHSI, m_FSub(m_Value(X), m_Value(Y))) &&
79417943
I.getFunction()->getDenormalMode(
79427944
LHSI->getType()->getScalarType()->getFltSemantics()) ==
79437945
DenormalMode::getIEEE()) {

0 commit comments

Comments
 (0)