[llvm] [InstCombine]Fold fcmp+select to min/max if its zero sign is missing (PR #213133)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 1 11:12:02 PDT 2026


================
@@ -4511,6 +4511,34 @@ static Instruction *foldSelectNegNot(SelectInst &SI,
   return nullptr;
 }
 
+// Return true if no use can observe the sign of zero of the select result,
+// looking through phis, selects and the loop back edge to the select itself.
+static bool isSelectZeroSignInsignificant(SelectInst &SI) {
+  // Bound the number of instructions to look through to keep the compile time
+  // in check.
+  constexpr unsigned MaxLookThroughNodes = 6;
----------------
dtcxzyw wrote:

This threshold should bound the number of uses, not the number of phi/selects.


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


More information about the llvm-commits mailing list