1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes='function(scalarizer<load-store>),dxil-op-lower' -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
4 ; Make sure dxil operation function calls for rsqrt are generated for float and half.
6 ; CHECK-LABEL: rsqrt_float
7 define noundef float @rsqrt_float(float noundef %a) {
8 ; CHECK-SAME: float noundef [[A:%.*]]) {
9 ; CHECK-NEXT: [[ENTRY:.*:]]
10 ; CHECK-NEXT: [[DX_RSQRT1:%.*]] = call float @dx.op.unary.f32(i32 25, float [[A]])
11 ; CHECK-NEXT: ret float [[DX_RSQRT1]]
14 %dx.rsqrt = call float @llvm.dx.rsqrt.f32(float %a)
18 ; CHECK-LABEL: rsqrt_half
19 define noundef half @rsqrt_half(half noundef %a) {
20 ; CHECK-SAME: half noundef [[A:%.*]]) {
21 ; CHECK-NEXT: [[ENTRY:.*:]]
22 ; CHECK-NEXT: [[DX_RSQRT1:%.*]] = call half @dx.op.unary.f16(i32 25, half [[A]])
23 ; CHECK-NEXT: ret half [[DX_RSQRT1]]
26 %dx.rsqrt = call half @llvm.dx.rsqrt.f16(half %a)
30 define noundef <4 x float> @rsqrt_float4(<4 x float> noundef %a) #0 {
31 ; CHECK-LABEL: define noundef <4 x float> @rsqrt_float4(
32 ; CHECK-SAME: <4 x float> noundef [[A:%.*]]) {
33 ; CHECK-NEXT: [[ENTRY:.*:]]
34 ; CHECK-NEXT: [[A_I0:%.*]] = extractelement <4 x float> [[A]], i64 0
35 ; CHECK-NEXT: [[DOTI04:%.*]] = call float @dx.op.unary.f32(i32 25, float [[A_I0]])
36 ; CHECK-NEXT: [[A_I1:%.*]] = extractelement <4 x float> [[A]], i64 1
37 ; CHECK-NEXT: [[DOTI13:%.*]] = call float @dx.op.unary.f32(i32 25, float [[A_I1]])
38 ; CHECK-NEXT: [[A_I2:%.*]] = extractelement <4 x float> [[A]], i64 2
39 ; CHECK-NEXT: [[DOTI22:%.*]] = call float @dx.op.unary.f32(i32 25, float [[A_I2]])
40 ; CHECK-NEXT: [[A_I3:%.*]] = extractelement <4 x float> [[A]], i64 3
41 ; CHECK-NEXT: [[DOTI31:%.*]] = call float @dx.op.unary.f32(i32 25, float [[A_I3]])
42 ; CHECK-NEXT: [[DOTUPTO0:%.*]] = insertelement <4 x float> poison, float [[DOTI04]], i64 0
43 ; CHECK-NEXT: [[DOTUPTO1:%.*]] = insertelement <4 x float> [[DOTUPTO0]], float [[DOTI13]], i64 1
44 ; CHECK-NEXT: [[DOTUPTO2:%.*]] = insertelement <4 x float> [[DOTUPTO1]], float [[DOTI22]], i64 2
45 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x float> [[DOTUPTO2]], float [[DOTI31]], i64 3
46 ; CHECK-NEXT: ret <4 x float> [[TMP0]]
49 %2 = call <4 x float> @llvm.dx.rsqrt.v4f32(<4 x float> %a)
54 declare half @llvm.dx.rsqrt.f16(half)
55 declare float @llvm.dx.rsqrt.f32(float)
56 declare <4 x float> @llvm.dx.rsqrt.v4f32(<4 x float>)