1 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefixes=CHECK,NOALIGN4
2 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -nvptx-force-min-byval-param-align | FileCheck %s --check-prefixes=CHECK,ALIGN4
3 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
4 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 -nvptx-force-min-byval-param-align | %ptxas-verify %}
6 ;;; Need 4-byte alignment on ptr passed byval
7 define ptx_device void @t1(ptr byval(float) %x) {
9 ; CHECK: .param .align 4 .b8 t1_param_0[4]
14 ;;; Need 8-byte alignment on ptr passed byval
15 define ptx_device void @t2(ptr byval(double) %x) {
17 ; CHECK: .param .align 8 .b8 t2_param_0[8]
22 ;;; Need 4-byte alignment on float2* passed byval
23 %struct.float2 = type { float, float }
24 define ptx_device void @t3(ptr byval(%struct.float2) %x) {
26 ; CHECK: .param .align 4 .b8 t3_param_0[8]
30 define ptx_device void @t4(ptr byval(i8) %x) {
32 ; NOALIGN4: .param .align 1 .b8 t4_param_0[1]
33 ; ALIGN4: .param .align 4 .b8 t4_param_0[1]
37 ;;; Make sure we adjust alignment at the call site as well.
38 define ptx_device void @t5(ptr align 2 byval(i8) %x) {
40 ; NOALIGN4: .param .align 2 .b8 t5_param_0[1]
41 ; ALIGN4: .param .align 4 .b8 t5_param_0[1]
43 ; NOALIGN4: .param .align 1 .b8 param0[1];
44 ; ALIGN4: .param .align 4 .b8 param0[1];
46 call void @t4(ptr byval(i8) %x)
50 ;;; Make sure we adjust alignment for a function prototype
51 ;;; in case of an inderect call.
53 declare ptr @getfp(i32 %n)
54 %struct.half2 = type { half, half }
55 define ptx_device void @t6() {
57 %fp = call ptr @getfp(i32 0)
58 ; CHECK: prototype_2 : .callprototype ()_ (.param .align 8 .b8 _[8]);
59 call void %fp(ptr byval(double) null);
61 %fp2 = call ptr @getfp(i32 1)
62 ; NOALIGN4: prototype_4 : .callprototype ()_ (.param .align 2 .b8 _[4]);
63 ; ALIGN4: prototype_4 : .callprototype ()_ (.param .align 4 .b8 _[4]);
64 call void %fp(ptr byval(%struct.half2) null);
66 %fp3 = call ptr @getfp(i32 2)
67 ; NOALIGN4: prototype_6 : .callprototype ()_ (.param .align 1 .b8 _[1]);
68 ; ALIGN4: prototype_6 : .callprototype ()_ (.param .align 4 .b8 _[1]);
69 call void %fp(ptr byval(i8) null);
73 ; CHECK-LABEL: .func check_ptr_align1(
74 ; CHECK: ld.param.u64 %rd1, [check_ptr_align1_param_0];
75 ; CHECK-NOT: ld.param.u8
76 ; CHECK: mov.b32 %r1, 0;
77 ; CHECK: st.u8 [%rd1+3], %r1;
78 ; CHECK: st.u8 [%rd1+2], %r1;
79 ; CHECK: st.u8 [%rd1+1], %r1;
80 ; CHECK: mov.b32 %r2, 1;
81 ; CHECK: st.u8 [%rd1], %r2;
83 define void @check_ptr_align1(ptr align 1 %_arg_ptr) {
85 store i32 1, ptr %_arg_ptr, align 1
89 ; CHECK-LABEL: .func check_ptr_align2(
90 ; CHECK: ld.param.u64 %rd1, [check_ptr_align2_param_0];
91 ; CHECK-NOT: ld.param.u16
92 ; CHECK: mov.b32 %r1, 0;
93 ; CHECK: st.u16 [%rd1+2], %r1;
94 ; CHECK: mov.b32 %r2, 2;
95 ; CHECK: st.u16 [%rd1], %r2;
97 define void @check_ptr_align2(ptr align 2 %_arg_ptr) {
99 store i32 2, ptr %_arg_ptr, align 2
103 ; CHECK-LABEL: .func check_ptr_align4(
104 ; CHECK: ld.param.u64 %rd1, [check_ptr_align4_param_0];
105 ; CHECK-NOT: ld.param.u32
106 ; CHECK: mov.b32 %r1, 4;
107 ; CHECK: st.u32 [%rd1], %r1;
109 define void @check_ptr_align4(ptr align 4 %_arg_ptr) {
111 store i32 4, ptr %_arg_ptr, align 4
115 ; CHECK-LABEL: .func check_ptr_align8(
116 ; CHECK: ld.param.u64 %rd1, [check_ptr_align8_param_0];
117 ; CHECK: mov.b32 %r1, 8;
118 ; CHECK: st.u32 [%rd1], %r1;
120 define void @check_ptr_align8(ptr align 8 %_arg_ptr) {
122 store i32 8, ptr %_arg_ptr, align 8