[llvm] [InstCombine] Fold `(x == y) ? 0 : (x > y ? 1 : -1)` into `ucmp/scmp(x,y)` (PR #107314)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 03:17:32 PDT 2024


================
@@ -15,8 +15,7 @@ define void @test_low_sgt(i64 %a, i64 %b) {
 ; CHECK:       normal:
 ; CHECK-NEXT:    ret void
 ; CHECK:       unreached:
-; CHECK-NEXT:    [[EQ:%.*]] = icmp ne i64 [[A]], [[B]]
-; CHECK-NEXT:    [[RESULT:%.*]] = zext i1 [[EQ]] to i32
+; CHECK-NEXT:    [[RESULT:%.*]] = call i32 @llvm.scmp.i32.i64(i64 [[A]], i64 [[B]])
----------------
nikic wrote:

This is a bit iffy, but also not directly related to this PR. It's not clear whether we should expand scmp/ucmp back to icmp+select if we can exclude one of the cases.

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


More information about the llvm-commits mailing list