R600/SI: implement range reduction for sin/cos
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 19 Jul 2014 18:44:39 +0000 (18:44 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 19 Jul 2014 18:44:39 +0000 (18:44 +0000)
commit18ecf3fff3ce9790fdcc357e936475552545bc36
tree16d3e7f67a82affe85daa74174f226b4385a051b
parent5e1c96a6324f6fdeda1457d114886db37ef0c803
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
lib/Target/R600/AMDGPUInstrInfo.td
lib/Target/R600/SIISelLowering.cpp
lib/Target/R600/SIISelLowering.h
lib/Target/R600/SIInstructions.td
test/CodeGen/R600/llvm.sin.ll