xref: /llvm-project/llvm/test/CodeGen/DirectX/sin.ll (revision 011b618644113996e2c0a8e57db40f89d20878e3)
1c05e29bfSFarzon Lotfi; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
285285be9SXiang Li
385285be9SXiang Li; Make sure dxil operation function calls for sin are generated for float and half.
485285be9SXiang Li
5c05e29bfSFarzon Lotfidefine noundef float @sin_float(float noundef %a) {
685285be9SXiang Lientry:
7*011b6186SFinn Plummer  ; CHECK:call float @dx.op.unary.f32(i32 13, float %{{.*}}) #[[#ATTR:]]
8c05e29bfSFarzon Lotfi  %1 = call float @llvm.sin.f32(float %a)
985285be9SXiang Li  ret float %1
1085285be9SXiang Li}
1185285be9SXiang Li
12c05e29bfSFarzon Lotfidefine noundef half @sin_half(half noundef %a) {
1385285be9SXiang Lientry:
14*011b6186SFinn Plummer  ; CHECK:call half @dx.op.unary.f16(i32 13, half %{{.*}}) #[[#ATTR]]
15c05e29bfSFarzon Lotfi  %1 = call half @llvm.sin.f16(half %a)
1685285be9SXiang Li  ret half %1
1785285be9SXiang Li}
18c05e29bfSFarzon Lotfi
19c05e29bfSFarzon Lotfidefine noundef <4 x float> @sin_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 13, 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 13, 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 13, 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 13, 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.sin.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
39c05e29bfSFarzon Lotfideclare half @llvm.sin.f16(half)
40c05e29bfSFarzon Lotfideclare float @llvm.sin.f32(float)
41c05e29bfSFarzon Lotfideclare <4 x float> @llvm.sin.v4f32(<4 x float>)
42