[llvm] [NVPTX] Add truncate and zero-extend free type conversions (PR #125580)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 15:07:17 PST 2025


================
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 | FileCheck %s
+
+define i32 @test_trunc(i64 %x, i64 %y) {
+; CHECK-LABEL: test_trunc(
+; CHECK:       {
+; CHECK-NEXT:    .reg .b32 %r<4>;
+; CHECK-EMPTY:
+; CHECK-NEXT:  // %bb.0:
+; CHECK-NEXT:    ld.param.u32 %r1, [test_trunc_param_0];
+; CHECK-NEXT:    ld.param.u32 %r2, [test_trunc_param_1];
+; CHECK-NEXT:    mad.lo.s32 %r3, %r1, %r2, 123456789;
+; CHECK-NEXT:    st.param.b32 [func_retval0], %r3;
+; CHECK-NEXT:    ret;
+  %a = mul i64 %x, %y
+  %b = add i64 %a, 123456789
+  %c = and i64 %b, -1
+  %trunc = trunc i64 %c to i32
+  ret i32 %trunc
+}
----------------
shiltian wrote:

test for zext?

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


More information about the llvm-commits mailing list