xref: /llvm-project/llvm/test/CodeGen/DirectX/degrees.ll (revision 2647505027d8c01fc920b04aced8cec742a4b2ed)
1; RUN: opt -S -dxil-intrinsic-expansion -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s
2
3; Make sure dxil op function calls for degrees are expanded and lowered as fmul for float and half.
4
5define noundef half @degrees_half(half noundef %a) {
6; CHECK-LABEL: define noundef half @degrees_half(
7; CHECK-SAME: half noundef [[A:%.*]]) {
8; CHECK-NEXT:  [[ENTRY:.*:]]
9; CHECK-NEXT:    [[DX_DEGREES1:%.*]] = fmul half [[A]], 0xH5329
10; CHECK-NEXT:    ret half [[DX_DEGREES1]]
11;
12entry:
13  %dx.degrees = call half @llvm.dx.degrees.f16(half %a)
14  ret half %dx.degrees
15}
16
17define noundef float @degrees_float(float noundef %a) #0 {
18; CHECK-LABEL: define noundef float @degrees_float(
19; CHECK-SAME: float noundef [[A:%.*]]) {
20; CHECK-NEXT:  entry:
21; CHECK-NEXT:    [[DEGREES:%.*]] = fmul float [[A]], 0x404CA5DC20000000
22; CHECK-NEXT:    ret float [[DEGREES]]
23;
24entry:
25  %dx.degrees = call float @llvm.dx.degrees.f32(float %a)
26  ret float %dx.degrees
27}
28
29define noundef <4 x float> @degrees_float4(<4 x float> noundef %a) #0 {
30; CHECK-LABEL: define noundef <4 x float> @degrees_float4(
31; CHECK-SAME: <4 x float> noundef [[A:%.*]]) {
32; CHECK-NEXT:  entry:
33; CHECK-NEXT:    [[A0:%.*]] = extractelement <4 x float> [[A]], i64 0
34; CHECK-NEXT:    [[DEGREES_A0:%.*]] = fmul float [[A0]], 0x404CA5DC20000000
35; CHECK-NEXT:    [[A1:%.*]] = extractelement <4 x float> [[A]], i64 1
36; CHECK-NEXT:    [[DEGREES_A1:%.*]] = fmul float [[A1]], 0x404CA5DC20000000
37; CHECK-NEXT:    [[A2:%.*]] = extractelement <4 x float> [[A]], i64 2
38; CHECK-NEXT:    [[DEGREES_A2:%.*]] = fmul float [[A2]], 0x404CA5DC20000000
39; CHECK-NEXT:    [[A3:%.*]] = extractelement <4 x float> [[A]], i64 3
40; CHECK-NEXT:    [[DEGREES_A3:%.*]] = fmul float [[A3]], 0x404CA5DC20000000
41; CHECK-NEXT:    [[INSERT_0:%.*]] = insertelement <4 x float> poison, float [[DEGREES_A0]], i64 0
42; CHECK-NEXT:    [[INSERT_1:%.*]] = insertelement <4 x float> [[INSERT_0]], float [[DEGREES_A1]], i64 1
43; CHECK-NEXT:    [[INSERT_2:%.*]] = insertelement <4 x float> [[INSERT_1]], float [[DEGREES_A2]], i64 2
44; CHECK-NEXT:    [[RES:%.*]] = insertelement <4 x float> [[INSERT_2]], float [[DEGREES_A3]], i64 3
45; CHECK-NEXT:    ret <4 x float> [[RES]]
46;
47entry:
48  %2 = call <4 x float> @llvm.dx.degrees.v4f32(<4 x float> %a)
49  ret <4 x float> %2
50}
51
52declare half  @llvm.dx.degrees.f16(half)
53declare float @llvm.dx.degrees.f32(float)
54declare <4 x float> @llvm.dx.degrees.v4f32(<4 x float>)
55