Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilPatidar committed May 9, 2024
1 parent 386e7c8 commit 3661877
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8036,6 +8036,7 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
return replaceOperand(I, 0, X);
if (Instruction *NV = FoldOpIntoSelect(I, cast<SelectInst>(LHSI)))
return NV;
break;
case Instruction::FSub:
switch (Pred) {
default:
Expand All @@ -8045,21 +8046,23 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
case FCmpInst::FCMP_UNE:
case FCmpInst::FCMP_OEQ:
case FCmpInst::FCMP_OGE:
case FCmpInst::FCMP_OLE: {
case FCmpInst::FCMP_OLE:
// fsub x, y --> isnnan(x, y) && isninf(x, y)
if (!LHSI->hasNoNaNs() && !LHSI->hasNoInfs() &&
!isKnownNeverInfinity(LHSI->getOperand(1), /*Depth=*/0,
getSimplifyQuery().getWithInstruction(&I)) &&
!isKnownNeverInfinity(LHSI->getOperand(0), /*Depth=*/0,
getSimplifyQuery().getWithInstruction(&I)))
break;
}
LLVM_FALLTHROUGH;

[[fallthrough]];
case FCmpInst::FCMP_OGT:
case FCmpInst::FCMP_OLT:
case FCmpInst::FCMP_ONE:
case FCmpInst::FCMP_UEQ:
case FCmpInst::FCMP_UGE:
case FCmpInst::FCMP_ULE:
// fcmp pred (x - y), 0 --> fcmp pred x, y
if (match(RHSC, m_AnyZeroFP()) &&
match(LHSI, m_FSub(m_Value(X), m_Value(Y))) &&
I.getFunction()->getDenormalMode(
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/InstCombine/fcmp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ define <8 x i1> @fcmp_une_fsub_const_nnan_vec(<8 x float> %x, <8 x float> %y) {
ret <8 x i1> %cmp
}

define <8 x i1> @fcmp_ugt_fsub_const_vec_denormal_positive-zero(<8 x float> %x, <8 x float> %y) "denormal-fp-math"="positive-zero" {
define <8 x i1> @fcmp_ugt_fsub_const_vec_denormal_positive-zero(<8 x float> %x, <8 x float> %y) "denormal-fp-math"="positive-zero,positive-zero" {
; CHECK-LABEL: @fcmp_ugt_fsub_const_vec_denormal_positive-zero(
; CHECK-NEXT: [[FS:%.*]] = fsub <8 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <8 x float> [[FS]], zeroinitializer
Expand All @@ -2077,7 +2077,7 @@ define <8 x i1> @fcmp_ogt_fsub_const_vec_denormal_dynamic(<8 x float> %x, <8 x f
ret <8 x i1> %cmp
}

define <8 x i1> @fcmp_ogt_fsub_const_vec_denormal_preserve-sign(<8 x float> %x, <8 x float> %y) "denormal-fp-math"="preserve-sign" {
define <8 x i1> @fcmp_ogt_fsub_const_vec_denormal_preserve-sign(<8 x float> %x, <8 x float> %y) "denormal-fp-math"="preserve-sign,preserve-sign" {
; CHECK-LABEL: @fcmp_ogt_fsub_const_vec_denormal_preserve-sign(
; CHECK-NEXT: [[FS:%.*]] = fsub <8 x float> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt <8 x float> [[FS]], zeroinitializer
Expand Down

0 comments on commit 3661877

Please sign in to comment.