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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 02:16:21 PDT 2024


================
@@ -8037,6 +8037,45 @@ Instruction *InstCombinerImpl::visitFCmpInst(FCmpInst &I) {
       if (Instruction *NV = FoldOpIntoSelect(I, cast<SelectInst>(LHSI)))
         return NV;
       break;
+    case Instruction::FSub:
+      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:
+        // Skip optimization: fsub x, y unless guaranteed !isinf(x) ||
+        // !isinf(y).
+        if (!LHSI->hasNoNaNs() && !LHSI->hasNoInfs() &&
----------------
arsenm wrote:

Could have had the hasOneUse check skip the complex isKnownNeverInfinity calls 

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


More information about the llvm-commits mailing list