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)
commitad14ce84b7091aa81eb75d0df0f0ce6788688fb3
treea0b6f426de4d48992ea5dfefd7bdc0ce4da34392
parent8ca36815eec998bbc21d2749fe6029812d60725a
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

llvm-svn: 213458
llvm/lib/Target/R600/AMDGPUInstrInfo.td
llvm/lib/Target/R600/SIISelLowering.cpp
llvm/lib/Target/R600/SIISelLowering.h
llvm/lib/Target/R600/SIInstructions.td
llvm/test/CodeGen/R600/llvm.sin.ll