xref: /llvm-project/llvm/test/CodeGen/DirectX/sqrt.ll (revision 011b618644113996e2c0a8e57db40f89d20878e3)
1c05e29bfSFarzon Lotfi; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
24cea2d04SFarzon Lotfi
34cea2d04SFarzon Lotfi; Make sure dxil operation function calls for sqrt are generated for float and half.
44cea2d04SFarzon Lotfi
5c05e29bfSFarzon Lotfidefine noundef float @sqrt_float(float noundef %a) {
64cea2d04SFarzon Lotfientry:
7*011b6186SFinn Plummer; CHECK:call float @dx.op.unary.f32(i32 24, float %{{.*}}) #[[#ATTR:]]
84cea2d04SFarzon Lotfi  %elt.sqrt = call float @llvm.sqrt.f32(float %a)
94cea2d04SFarzon Lotfi  ret float %elt.sqrt
104cea2d04SFarzon Lotfi}
114cea2d04SFarzon Lotfi
12c05e29bfSFarzon Lotfidefine noundef half @sqrt_half(half noundef %a) {
134cea2d04SFarzon Lotfientry:
14*011b6186SFinn Plummer; CHECK:call half @dx.op.unary.f16(i32 24, half %{{.*}}) #[[#ATTR]]
154cea2d04SFarzon Lotfi  %elt.sqrt = call half @llvm.sqrt.f16(half %a)
164cea2d04SFarzon Lotfi  ret half %elt.sqrt
174cea2d04SFarzon Lotfi}
184cea2d04SFarzon Lotfi
19c05e29bfSFarzon Lotfidefine noundef <4 x float> @sqrt_float4(<4 x float> noundef %a) {
20c05e29bfSFarzon Lotfientry:
21c05e29bfSFarzon Lotfi  ; CHECK: [[ee0:%.*]] = extractelement <4 x float> %a, i64 0
22*011b6186SFinn Plummer  ; CHECK: [[ie0:%.*]] = call float @dx.op.unary.f32(i32 24, float [[ee0]]) #[[#ATTR]]
23c05e29bfSFarzon Lotfi  ; CHECK: [[ee1:%.*]] = extractelement <4 x float> %a, i64 1
24*011b6186SFinn Plummer  ; CHECK: [[ie1:%.*]] = call float @dx.op.unary.f32(i32 24, float [[ee1]]) #[[#ATTR]]
25c05e29bfSFarzon Lotfi  ; CHECK: [[ee2:%.*]] = extractelement <4 x float> %a, i64 2
26*011b6186SFinn Plummer  ; CHECK: [[ie2:%.*]] = call float @dx.op.unary.f32(i32 24, float [[ee2]]) #[[#ATTR]]
27c05e29bfSFarzon Lotfi  ; CHECK: [[ee3:%.*]] = extractelement <4 x float> %a, i64 3
28*011b6186SFinn Plummer  ; CHECK: [[ie3:%.*]] = call float @dx.op.unary.f32(i32 24, float [[ee3]]) #[[#ATTR]]
29c05e29bfSFarzon Lotfi  ; CHECK: insertelement <4 x float> poison, float [[ie0]], i64 0
30c05e29bfSFarzon Lotfi  ; CHECK: insertelement <4 x float> %{{.*}}, float [[ie1]], i64 1
31c05e29bfSFarzon Lotfi  ; CHECK: insertelement <4 x float> %{{.*}}, float [[ie2]], i64 2
32c05e29bfSFarzon Lotfi  ; CHECK: insertelement <4 x float> %{{.*}}, float [[ie3]], i64 3
33c05e29bfSFarzon Lotfi  %2 = call <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
34c05e29bfSFarzon Lotfi  ret <4 x float> %2
35c05e29bfSFarzon Lotfi}
36c05e29bfSFarzon Lotfi
37*011b6186SFinn Plummer; CHECK: attributes #[[#ATTR]] = {{{.*}} memory(none) {{.*}}}
38*011b6186SFinn Plummer
394cea2d04SFarzon Lotfideclare half @llvm.sqrt.f16(half)
404cea2d04SFarzon Lotfideclare float @llvm.sqrt.f32(float)
41c05e29bfSFarzon Lotfideclare <4 x float> @llvm.sqrt.v4f32(<4 x float>)
42