[llvm] [InstCombine] Fold select with signbit idiom into fabs (PR #76342)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 21 20:39:01 PST 2024


================
@@ -2763,6 +2763,41 @@ static Instruction *foldSelectWithFCmpToFabs(SelectInst &SI,
     }
   }
 
+  // Match select with (icmp slt (bitcast X to int), 0)
+  //                or (icmp sgt (bitcast X to int), -1)
----------------
dtcxzyw wrote:

Yeah. But this pattern is usually generated by `std::signbit`. Not sure that `((fptosi X) <s 0 ? -X : X)` exists in real-world applications.


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


More information about the llvm-commits mailing list