[llvm] [SelectionDAG] Add support for the 3-way comparison intrinsics [US]CMP (PR #91871)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 1 03:25:47 PDT 2024


================
@@ -0,0 +1,972 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+define i8 @ucmp(i32 %x, i32 %y) nounwind {
+; CHECK-LABEL: ucmp:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    xorl %ecx, %ecx
+; CHECK-NEXT:    cmpl %esi, %edi
+; CHECK-NEXT:    seta %cl
+; CHECK-NEXT:    movl $255, %eax
+; CHECK-NEXT:    cmovael %ecx, %eax
+; CHECK-NEXT:    # kill: def $al killed $al killed $eax
+; CHECK-NEXT:    retq
+  %1 = call i8 @llvm.ucmp(i32 %x, i32 %y)
+  ret i8 %1
+}
----------------
nikic wrote:

I'd also add some tests for the practically relevant cases, in addition to the legalization coverage. cmp i32 with i8 result is one of them, but also cmp i128, i64, i16 and i8 with i8 result. And then maybe also i32/i64 result type.

Those are the ones where we would care about good codegen, the rest mostly just needs to work...

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


More information about the llvm-commits mailing list