1 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_52 -mattr=+ptx64 -O0 | FileCheck %s --check-prefix=SM_52
2 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_70 -mattr=+ptx64 -O0 | FileCheck %s --check-prefix=SM_70
3 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_90 -mattr=+ptx72 -O0 | FileCheck %s --check-prefix=SM_90
5 @.str = private unnamed_addr constant [12 x i8] c"__CUDA_ARCH\00"
6 @.str1 = constant [11 x i8] c"__CUDA_FTZ\00"
8 declare i32 @__nvvm_reflect(ptr)
10 ; SM_52: .visible .func (.param .b32 func_retval0) foo()
11 ; SM_52: mov.b32 %[[REG:.+]], 3;
12 ; SM_52-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
15 ; SM_70: .visible .func (.param .b32 func_retval0) foo()
16 ; SM_70: mov.b32 %[[REG:.+]], 2;
17 ; SM_70-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
20 ; SM_90: .visible .func (.param .b32 func_retval0) foo()
21 ; SM_90: mov.b32 %[[REG:.+]], 1;
22 ; SM_90-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
26 %call = call i32 @__nvvm_reflect(ptr @.str)
27 %cmp = icmp uge i32 %call, 900
28 br i1 %cmp, label %if.then, label %if.else
34 %call1 = call i32 @__nvvm_reflect(ptr @.str)
35 %cmp2 = icmp uge i32 %call1, 700
36 br i1 %cmp2, label %if.then3, label %if.else4
42 %call5 = call i32 @__nvvm_reflect(ptr @.str)
43 %cmp6 = icmp uge i32 %call5, 520
44 br i1 %cmp6, label %if.then7, label %if.else8
53 %retval.0 = phi i32 [ 1, %if.then ], [ 2, %if.then3 ], [ 3, %if.then7 ], [ 4, %if.else8 ]
57 ; SM_52: .visible .func (.param .b32 func_retval0) bar()
58 ; SM_52: mov.b32 %[[REG:.+]], 2;
59 ; SM_52-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
62 ; SM_70: .visible .func (.param .b32 func_retval0) bar()
63 ; SM_70: mov.b32 %[[REG:.+]], 1;
64 ; SM_70-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
67 ; SM_90: .visible .func (.param .b32 func_retval0) bar()
68 ; SM_90: mov.b32 %[[REG:.+]], 1;
69 ; SM_90-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
73 %call = call i32 @__nvvm_reflect(ptr @.str)
74 %cmp = icmp uge i32 %call, 700
75 br i1 %cmp, label %if.then, label %if.else
84 %x = phi i32 [ 1, %if.then ], [ 2, %if.else ]
93 %call = call i32 @__nvvm_reflect(ptr @.str)
94 %cmp = icmp uge i32 %call, 700
95 br i1 %cmp, label %if.then, label %if.end
98 call void asm sideeffect "valid;\0A", ""()
105 ; SM_52: .visible .func (.param .b32 func_retval0) qux()
106 ; SM_52: mov.b32 %[[REG:.+]], 3;
107 ; SM_52-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
110 ; SM_70: .visible .func (.param .b32 func_retval0) qux()
111 ; SM_70: mov.b32 %[[REG:.+]], 2;
112 ; SM_70-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
115 ; SM_90: .visible .func (.param .b32 func_retval0) qux()
116 ; SM_90: mov.b32 %[[REG:.+]], 1;
117 ; SM_90-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
121 %call = call i32 @__nvvm_reflect(ptr noundef @.str)
122 switch i32 %call, label %sw.default [
123 i32 900, label %sw.bb
124 i32 700, label %sw.bb1
125 i32 520, label %sw.bb2
141 %retval = phi i32 [ 4, %sw.default ], [ 3, %sw.bb2 ], [ 2, %sw.bb1 ], [ 1, %sw.bb ]
145 ; SM_52: .visible .func (.param .b32 func_retval0) phi()
146 ; SM_52: mov.f32 %[[REG:.+]], 0f00000000;
147 ; SM_52-NEXT: st.param.f32 [func_retval0+0], %[[REG]];
149 ; SM_70: .visible .func (.param .b32 func_retval0) phi()
150 ; SM_70: mov.f32 %[[REG:.+]], 0f00000000;
151 ; SM_70-NEXT: st.param.f32 [func_retval0+0], %[[REG]];
153 ; SM_90: .visible .func (.param .b32 func_retval0) phi()
154 ; SM_90: mov.f32 %[[REG:.+]], 0f00000000;
155 ; SM_90-NEXT: st.param.f32 [func_retval0+0], %[[REG]];
157 define float @phi() {
159 %0 = call i32 @__nvvm_reflect(ptr @.str)
160 %1 = icmp eq i32 %0, 0
161 br i1 %1, label %if.then, label %if.else
167 %.08 = phi float [ 0.000000e+00, %if.then ], [ 1.000000e+00, %entry ]
168 %4 = fcmp ogt float %.08, 0.000000e+00
169 br i1 %4, label %exit, label %if.exit
175 ret float 0.000000e+00
178 ; SM_52: .visible .func (.param .b32 func_retval0) prop()
179 ; SM_52: mov.b32 %[[REG:.+]], 3;
180 ; SM_52-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
183 ; SM_70: .visible .func (.param .b32 func_retval0) prop()
184 ; SM_70: mov.b32 %[[REG:.+]], 2;
185 ; SM_70-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
188 ; SM_90: .visible .func (.param .b32 func_retval0) prop()
189 ; SM_90: mov.b32 %[[REG:.+]], 1;
190 ; SM_90-NEXT: st.param.b32 [func_retval0+0], %[[REG:.+]];
194 %call = call i32 @__nvvm_reflect(ptr @.str)
195 %conv = zext i32 %call to i64
196 %div = udiv i64 %conv, 100
197 %cmp = icmp eq i64 %div, 9
198 br i1 %cmp, label %if.then, label %if.else
204 %div2 = udiv i64 %conv, 100
205 %cmp3 = icmp eq i64 %div2, 7
206 br i1 %cmp3, label %if.then5, label %if.else6
212 %div7 = udiv i64 %conv, 100
213 %cmp8 = icmp eq i64 %div7, 5
214 br i1 %cmp8, label %if.then10, label %if.else11
223 %retval = phi i32 [ 1, %if.then ], [ 2, %if.then5 ], [ 3, %if.then10 ], [ 4, %if.else11 ]