[llvm] [InstCombine] Fix miscompilation for `select` + `FCmp` (PR #177872)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 29 13:48:48 PST 2026


================
@@ -4303,16 +4302,29 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
       // (X ugt Y) ? X : Y -> (X ole Y) ? Y : X
       if (FCmp->hasOneUse() && FCmpInst::isUnordered(Pred)) {
         FCmpInst::Predicate InvPred = FCmp->getInversePredicate();
-        Value *NewCond = Builder.CreateFCmpFMF(InvPred, Cmp0, Cmp1, FCmp,
+        // Intersect fast-math flags from the original fcmp and select.
----------------
arsenm wrote:

Do you need both of these pieces? You have one test, but seem to be touching 2 separate transforms. I think this one is not related to the new test function 

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


More information about the llvm-commits mailing list