[llvm] [InstCombine] Fold `icmp eq/ne min|max(X, Y), Z` (PR #67087)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 22 06:09:27 PDT 2023


================
@@ -5022,6 +5022,12 @@ InstCombinerImpl::foldICmpWithMinMaxImpl(Instruction &I,
     std::swap(CmpXZ, CmpYZ);
   }
 
+  auto FoldIntoCmpYZ = [&]() -> Instruction * {
+    if (CmpYZ.has_value())
+      return replaceInstUsesWith(I, ConstantInt::getBool(I.getType(), *CmpYZ));
+    return ICmpInst::Create(Instruction::ICmp, Pred, Y, Z);
+  };
----------------
goldsteinn wrote:

This lambda is only used once.
Imo its clearer to just leave this logic inlined at its callsite.

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


More information about the llvm-commits mailing list