[llvm] [InstCombine] Fold fcmp ogt (x - y), 0 into fcmp ogt x, y #85245 (PR #85506)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 10:21:31 PDT 2024


https://github.com/SahilPatidar updated https://github.com/llvm/llvm-project/pull/85506

>From 38be749710349c1fcd8b903dda61dafc3bbe59f5 Mon Sep 17 00:00:00 2001
From: SahilPatidar <patidarsahil2001 at gmail.com>
Date: Fri, 15 Mar 2024 16:49:36 +0530
Subject: [PATCH 1/3] [InstCombine] Fold fcmp ogt (x - y), 0 into fcmp ogt x, y
 #85245

---
 .../InstCombine/InstCombineCompares.cpp       |  7 +++
 llvm/test/Transforms/InstCombine/fcmp.ll      | 43 +++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 0dce0077bf1588..e3b869d42e70b2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -7972,6 +7972,13 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
   Constant *RHSC;
   if (match(Op0, m_Instruction(LHSI)) && match(Op1, m_Constant(RHSC))) {
     switch (LHSI->getOpcode()) {
+    case Instruction::FSub:
+      if ((Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_OLT ||
+           Pred == FCmpInst::FCMP_ONE) &&
+          match(RHSC, m_AnyZeroFP()) &&
+          match(LHSI, m_FSub(m_Value(X), m_Value(Y))))
+        return new FCmpInst(Pred, X, Y);
+      break;
     case Instruction::PHI:
       if (Instruction *NV = foldOpIntoPhi(I, cast<PHINode>(LHSI)))
         return NV;
diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index 159c84d0dd8aa9..abbae610b0e346 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -1284,3 +1284,46 @@ define <1 x i1> @bitcast_1vec_eq0(i32 %x) {
   %cmp = fcmp oeq <1 x float> %f, zeroinitializer
   ret <1 x i1> %cmp
 }
+
+define i1 @fcmp_ogt_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ogt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ogt float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_olt_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_olt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp olt float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_one_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_one_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp one float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp one float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_fsub_neg_zero(float %x, float %y) {
+; CHECK-LABEL: @fcmp_fsub_neg_zero(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    call void @use(float [[FS]])
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[X]], [[Y]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  call void @use(float %fs)
+  %cmp = fcmp ogt float %fs, -0.000000e+00
+  ret i1 %cmp
+}

>From 9cad26536f477af67e137633b194d7ffc968b871 Mon Sep 17 00:00:00 2001
From: SahilPatidar <patidarsahil2001 at gmail.com>
Date: Mon, 18 Mar 2024 15:11:30 +0530
Subject: [PATCH 2/3] Added tests to verify fast math flag behavior

---
 llvm/test/Transforms/InstCombine/fcmp.ll | 97 +++++++++++++++++++++---
 1 file changed, 87 insertions(+), 10 deletions(-)

diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index abbae610b0e346..407f65340924df 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -1315,15 +1315,92 @@ define i1 @fcmp_one_fsub_const(float %x, float %y) {
   ret i1 %cmp
 }
 
-define i1 @fcmp_fsub_neg_zero(float %x, float %y) {
-; CHECK-LABEL: @fcmp_fsub_neg_zero(
-; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    call void @use(float [[FS]])
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt float [[X]], [[Y]]
-; CHECK-NEXT:    ret i1 [[CMP]]
+define <8 x i1> @fcmp_vec_ogt_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ogt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub float %x, %y
-  call void @use(float %fs)
-  %cmp = fcmp ogt float %fs, -0.000000e+00
-  ret i1 %cmp
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp ogt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_olt_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_olt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp olt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_one_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_one_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp one <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_ogt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ogt_fm_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ogt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_olt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_olt_fm_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp olt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_one_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_one_fm_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp one <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @ffcmp_vec_ogt_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @ffcmp_vec_ogt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp fast ogt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @ffcmp_vec_olt_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @ffcmp_vec_olt_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp fast olt <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @ffcmp_vec_one_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @ffcmp_vec_one_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub <8 x float> %x, %y
+  %cmp = fcmp fast one <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
 }

>From 2d32ffeadab32e78bddb44371a800913f623048c Mon Sep 17 00:00:00 2001
From: SahilPatidar <patidarsahil2001 at gmail.com>
Date: Fri, 22 Mar 2024 22:23:05 +0530
Subject: [PATCH 3/3] Modifies code and updates relevant tests

---
 .../InstCombine/InstCombineCompares.cpp       |  35 +++-
 llvm/test/Transforms/InstCombine/fcmp.ll      | 198 ++++++++++++++----
 2 files changed, 192 insertions(+), 41 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index e3b869d42e70b2..fe7f0123d8c1d9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -7973,11 +7973,36 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
   if (match(Op0, m_Instruction(LHSI)) && match(Op1, m_Constant(RHSC))) {
     switch (LHSI->getOpcode()) {
     case Instruction::FSub:
-      if ((Pred == FCmpInst::FCMP_OGT || Pred == FCmpInst::FCMP_OLT ||
-           Pred == FCmpInst::FCMP_ONE) &&
-          match(RHSC, m_AnyZeroFP()) &&
-          match(LHSI, m_FSub(m_Value(X), m_Value(Y))))
-        return new FCmpInst(Pred, X, Y);
+      switch (Pred) {
+      default:
+        break;
+      case FCmpInst::FCMP_UGT:
+      case FCmpInst::FCMP_ULT:
+      case FCmpInst::FCMP_UNE:
+      case FCmpInst::FCMP_OEQ:
+      case FCmpInst::FCMP_OGE:
+      case FCmpInst::FCMP_OLE: {
+        BinaryOperator *SubI = cast<BinaryOperator>(LHSI);
+        if (!computeKnownFPClass(SubI->getOperand(0), SubI->getFastMathFlags(),
+                                 fcInf, LHSI, 0)
+                 .isKnownNeverInfinity() &&
+            !computeKnownFPClass(SubI->getOperand(1), SubI->getFastMathFlags(),
+                                 fcInf, LHSI, 0)
+                 .isKnownNeverInfinity())
+          break;
+      }
+        LLVM_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:
+        if (match(RHSC, m_AnyZeroFP()) &&
+            match(LHSI, m_FSub(m_Value(X), m_Value(Y))))
+          return new FCmpInst(Pred, X, Y);
+        break;
+      }
       break;
     case Instruction::PHI:
       if (Instruction *NV = foldOpIntoPhi(I, cast<PHINode>(LHSI)))
diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll
index 407f65340924df..c4f558b2e25344 100644
--- a/llvm/test/Transforms/InstCombine/fcmp.ll
+++ b/llvm/test/Transforms/InstCombine/fcmp.ll
@@ -1315,38 +1315,164 @@ define i1 @fcmp_one_fsub_const(float %x, float %y) {
   ret i1 %cmp
 }
 
-define <8 x i1> @fcmp_vec_ogt_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_ogt_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
+define i1 @fcmp_oeq_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_oeq_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp oeq float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_oge_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_oge_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp oge float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp oge float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_ole_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ole_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ole float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ole float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_ueq_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ueq_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ueq float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ueq float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_uge_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_uge_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp uge float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp uge float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_ule_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ule_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ule float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_ugt_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ugt_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ugt float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ugt float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_ult_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_ult_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ult float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp ult float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define i1 @fcmp_une_fsub_const(float %x, float %y) {
+; CHECK-LABEL: @fcmp_une_fsub_const(
+; CHECK-NEXT:    [[FS:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp une float [[FS]], 0.000000e+00
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %fs = fsub float %x, %y
+  %cmp = fcmp une float %fs, 0.000000e+00
+  ret i1 %cmp
+}
+
+define <8 x i1> @fcmp_vec_uge_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_uge_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp uge <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp ogt <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp uge <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @fcmp_vec_olt_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_olt_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
+define <8 x i1> @fcmp_vec_ule_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ule_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ule <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp olt <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ule <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @fcmp_vec_one_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_one_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
+define <8 x i1> @fcmp_vec_ueq_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ueq_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ueq <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp one <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ueq <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @fcmp_vec_ogt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_ogt_fm_fsub_const(
+define <8 x i1> @fcmp_vec_oge_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_oge_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp oge <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp oge <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_ole_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ole_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ole <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ole <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_oeq_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_oeq_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp oeq <8 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <8 x i1> [[CMP]]
+;
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp oeq <8 x float> %fs, zeroinitializer
+  ret <8 x i1> %cmp
+}
+
+define <8 x i1> @fcmp_vec_ogt_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ogt_fast_fsub_const(
 ; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
@@ -1355,8 +1481,8 @@ define <8 x i1> @fcmp_vec_ogt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @fcmp_vec_olt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_olt_fm_fsub_const(
+define <8 x i1> @fcmp_vec_olt_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_olt_fast_fsub_const(
 ; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
@@ -1365,8 +1491,8 @@ define <8 x i1> @fcmp_vec_olt_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @fcmp_vec_one_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @fcmp_vec_one_fm_fsub_const(
+define <8 x i1> @fcmp_vec_one_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_one_fast_fsub_const(
 ; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
@@ -1375,32 +1501,32 @@ define <8 x i1> @fcmp_vec_one_fm_fsub_const(<8 x float> %x, <8 x float> %y) {
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @ffcmp_vec_ogt_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @ffcmp_vec_ogt_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp ogt <8 x float> [[X:%.*]], [[Y:%.*]]
+define <8 x i1> @fcmp_vec_ugt_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ugt_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ugt <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp fast ogt <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ugt <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @ffcmp_vec_olt_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @ffcmp_vec_olt_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp olt <8 x float> [[X:%.*]], [[Y:%.*]]
+define <8 x i1> @fcmp_vec_ult_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_ult_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ult <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp fast olt <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp ult <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }
 
-define <8 x i1> @ffcmp_vec_one_fsub_const(<8 x float> %x, <8 x float> %y) {
-; CHECK-LABEL: @ffcmp_vec_one_fsub_const(
-; CHECK-NEXT:    [[CMP:%.*]] = fcmp one <8 x float> [[X:%.*]], [[Y:%.*]]
+define <8 x i1> @fcmp_vec_une_fast_fsub_const(<8 x float> %x, <8 x float> %y) {
+; CHECK-LABEL: @fcmp_vec_une_fast_fsub_const(
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp une <8 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <8 x i1> [[CMP]]
 ;
-  %fs = fsub <8 x float> %x, %y
-  %cmp = fcmp fast one <8 x float> %fs, zeroinitializer
+  %fs = fsub fast <8 x float> %x, %y
+  %cmp = fcmp une <8 x float> %fs, zeroinitializer
   ret <8 x i1> %cmp
 }



More information about the llvm-commits mailing list