mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
R600/SI: implement range reduction for sin/cos
These instructions can only take a limited input range, and return the constant value 1 out of range. We should do range reduction to be able to process arbitrary values. Use a FRACT instruction after normalization to achieve this. Also add a test for constant folding with the lowered code with unsafe-fp-math enabled. v2: use DAG lowering instead of intrinsic, adapt test v3: calculate constant, fold pattern into instruction definition v4: misc style fixes, add sin-fold testcase, cosmetics Patch by Grigori Goronzy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213458 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s -check-prefix=EG -check-prefix=FUNC
|
||||
;RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s -check-prefix=SI -check-prefix=FUNC
|
||||
;RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
||||
;RUN: llc -march=r600 -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=SI-SAFE -check-prefix=FUNC %s
|
||||
;RUN: llc -march=r600 -mcpu=SI -enable-unsafe-fp-math < %s | FileCheck -check-prefix=SI -check-prefix=SI-UNSAFE -check-prefix=FUNC %s
|
||||
|
||||
;FUNC-LABEL: test
|
||||
;EG: MULADD_IEEE *
|
||||
@@ -8,6 +9,7 @@
|
||||
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
|
||||
;EG-NOT: SIN
|
||||
;SI: V_MUL_F32
|
||||
;SI: V_FRACT_F32
|
||||
;SI: V_SIN_F32
|
||||
;SI-NOT: V_SIN_F32
|
||||
|
||||
@@ -17,6 +19,22 @@ define void @test(float addrspace(1)* %out, float %x) #1 {
|
||||
ret void
|
||||
}
|
||||
|
||||
;FUNC-LABEL: testf
|
||||
;SI-UNSAFE: 4.774
|
||||
;SI-UNSAFE: V_MUL_F32
|
||||
;SI-SAFE: V_MUL_F32
|
||||
;SI-SAFE: V_MUL_F32
|
||||
;SI: V_FRACT_F32
|
||||
;SI: V_SIN_F32
|
||||
;SI-NOT: V_SIN_F32
|
||||
|
||||
define void @testf(float addrspace(1)* %out, float %x) #1 {
|
||||
%y = fmul float 3.0, %x
|
||||
%sin = call float @llvm.sin.f32(float %y)
|
||||
store float %sin, float addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
|
||||
;FUNC-LABEL: testv
|
||||
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
|
||||
;EG: SIN * T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
|
||||
|
||||
Reference in New Issue
Block a user