[llvm] [llvm][InstCombine] Fold signum(x) into scmp(x, 0) (PR #143445)

Yash Solanki via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 11 10:01:18 PDT 2025


================
@@ -3603,6 +3603,18 @@ Instruction *InstCombinerImpl::foldSelectToCmp(SelectInst &SI) {
        ICmpInst::getSwappedPredicate(ExtendedCmpPredicate) == Pred))
     Replace = true;
 
+  // Handle the edge case (x > -1) ? zext(x != 0), -1
----------------
yashnator wrote:

I modified the code to handle weak inequalities and inverted inequalities. So, all constants should work now

I previously handled only 0 because the code generated by C only showed a difference for 0

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


More information about the llvm-commits mailing list