Skip to content

Commit 3dbf1f8

Browse files
committed
R600: Expand vector sin and cos.
v2: move code to AMDGPUISelLowering.cpp squash with tests (both EG and SI) Signed-off-by: Jan Vesely <[email protected]> llvm-svn: 207845
1 parent 605e116 commit 3dbf1f8

File tree

3 files changed

+67
-22
lines changed

3 files changed

+67
-22
lines changed

llvm/lib/Target/R600/AMDGPUISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,15 @@ AMDGPUTargetLowering::AMDGPUTargetLowering(TargetMachine &TM) :
246246
MVT::SimpleValueType VT = FloatTypes[x];
247247
setOperationAction(ISD::FABS, VT, Expand);
248248
setOperationAction(ISD::FADD, VT, Expand);
249+
setOperationAction(ISD::FCOS, VT, Expand);
249250
setOperationAction(ISD::FDIV, VT, Expand);
250251
setOperationAction(ISD::FPOW, VT, Expand);
251252
setOperationAction(ISD::FFLOOR, VT, Expand);
252253
setOperationAction(ISD::FTRUNC, VT, Expand);
253254
setOperationAction(ISD::FMUL, VT, Expand);
254255
setOperationAction(ISD::FRINT, VT, Expand);
255256
setOperationAction(ISD::FSQRT, VT, Expand);
257+
setOperationAction(ISD::FSIN, VT, Expand);
256258
setOperationAction(ISD::FSUB, VT, Expand);
257259
setOperationAction(ISD::SELECT, VT, Expand);
258260
}

llvm/test/CodeGen/R600/llvm.cos.ll

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1-
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
1+
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s -check-prefix=EG -check-prefix=FUNC
2+
;RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s -check-prefix=SI -check-prefix=FUNC
23

3-
;CHECK: MULADD_IEEE *
4-
;CHECK: FRACT *
5-
;CHECK: ADD *
6-
;CHECK: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
4+
;FUNC-LABEL: test
5+
;EG: MULADD_IEEE *
6+
;EG: FRACT *
7+
;EG: ADD *
8+
;EG: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
9+
;EG-NOT: COS
10+
;SI: V_COS_F32
11+
;SI-NOT: V_COS_F32
712

8-
define void @test(<4 x float> inreg %reg0) #0 {
9-
%r0 = extractelement <4 x float> %reg0, i32 0
10-
%r1 = call float @llvm.cos.f32(float %r0)
11-
%vec = insertelement <4 x float> undef, float %r1, i32 0
12-
call void @llvm.R600.store.swizzle(<4 x float> %vec, i32 0, i32 0)
13+
define void @test(float addrspace(1)* %out, float %x) #1 {
14+
%cos = call float @llvm.cos.f32(float %x)
15+
store float %cos, float addrspace(1)* %out
16+
ret void
17+
}
18+
19+
;FUNC-LABEL: testv
20+
;EG: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
21+
;EG: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
22+
;EG: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
23+
;EG: COS * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
24+
;EG-NOT: COS
25+
;SI: V_COS_F32
26+
;SI: V_COS_F32
27+
;SI: V_COS_F32
28+
;SI: V_COS_F32
29+
;SI-NOT: V_COS_F32
30+
31+
define void @testv(<4 x float> addrspace(1)* %out, <4 x float> inreg %vx) #1 {
32+
%cos = call <4 x float> @llvm.cos.v4f32(<4 x float> %vx)
33+
store <4 x float> %cos, <4 x float> addrspace(1)* %out
1334
ret void
1435
}
1536

1637
declare float @llvm.cos.f32(float) readnone
17-
declare void @llvm.R600.store.swizzle(<4 x float>, i32, i32)
38+
declare <4 x float> @llvm.cos.v4f32(<4 x float>) readnone
1839

1940
attributes #0 = { "ShaderType"="0" }

llvm/test/CodeGen/R600/llvm.sin.ll

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
1+
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s -check-prefix=EG -check-prefix=FUNC
2+
;RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s -check-prefix=SI -check-prefix=FUNC
23

3-
;CHECK: MULADD_IEEE *
4-
;CHECK: FRACT *
5-
;CHECK: ADD *
6-
;CHECK: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
4+
;FUNC-LABEL: test
5+
;EG: MULADD_IEEE *
6+
;EG: FRACT *
7+
;EG: ADD *
8+
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
9+
;EG-NOT: SIN
10+
;SI: V_MUL_F32
11+
;SI: V_SIN_F32
12+
;SI-NOT: V_SIN_F32
713

8-
define void @test(<4 x float> inreg %reg0) #0 {
9-
%r0 = extractelement <4 x float> %reg0, i32 0
10-
%r1 = call float @llvm.sin.f32( float %r0)
11-
%vec = insertelement <4 x float> undef, float %r1, i32 0
12-
call void @llvm.R600.store.swizzle(<4 x float> %vec, i32 0, i32 0)
14+
define void @test(float addrspace(1)* %out, float %x) #1 {
15+
%sin = call float @llvm.sin.f32(float %x)
16+
store float %sin, float addrspace(1)* %out
17+
ret void
18+
}
19+
20+
;FUNC-LABEL: testv
21+
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
22+
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
23+
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
24+
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
25+
;EG-NOT: SIN
26+
;SI: V_SIN_F32
27+
;SI: V_SIN_F32
28+
;SI: V_SIN_F32
29+
;SI: V_SIN_F32
30+
;SI-NOT: V_SIN_F32
31+
32+
define void @testv(<4 x float> addrspace(1)* %out, <4 x float> %vx) #1 {
33+
%sin = call <4 x float> @llvm.sin.v4f32( <4 x float> %vx)
34+
store <4 x float> %sin, <4 x float> addrspace(1)* %out
1335
ret void
1436
}
1537

1638
declare float @llvm.sin.f32(float) readnone
17-
declare void @llvm.R600.store.swizzle(<4 x float>, i32, i32)
39+
declare <4 x float> @llvm.sin.v4f32(<4 x float>) readnone
1840

1941
attributes #0 = { "ShaderType"="0" }

0 commit comments

Comments
 (0)