summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2014-06-23 18:28:28 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2014-06-23 18:28:28 +0000
commitf2b0aebb8af0c4161171ac5afc21b6da171b1f43 (patch)
tree553a9f9c72a244fdd9b639755d12b26d7cde9bd9 /llvm/lib/Target/R600/AMDGPUISelLowering.cpp
parent1f83db17c0f931217ff7af961a4fd50990344117 (diff)
downloadbcm5719-llvm-f2b0aebb8af0c4161171ac5afc21b6da171b1f43.tar.gz
bcm5719-llvm-f2b0aebb8af0c4161171ac5afc21b6da171b1f43.zip
R600/SI: Fix div_scale intrinsic.
The operand that must match one of the others does matter, and implement selecting for it. llvm-svn: 211523
Diffstat (limited to 'llvm/lib/Target/R600/AMDGPUISelLowering.cpp')
-rw-r--r--llvm/lib/Target/R600/AMDGPUISelLowering.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
index 6ff1703c919..ca8d0a1626b 100644
--- a/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
+++ b/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
@@ -771,9 +771,21 @@ SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
return DAG.getNode(AMDGPUISD::CLAMP, DL, VT,
Op.getOperand(1), Op.getOperand(2), Op.getOperand(3));
- case Intrinsic::AMDGPU_div_scale:
+ case Intrinsic::AMDGPU_div_scale: {
+ // 3rd parameter required to be a constant.
+ const ConstantSDNode *Param = dyn_cast<ConstantSDNode>(Op.getOperand(3));
+ if (!Param)
+ return DAG.getUNDEF(VT);
+
+ // Translate to the operands expected by the machine instruction. The
+ // first parameter must be the same as the first instruction.
+ SDValue Numerator = Op.getOperand(1);
+ SDValue Denominator = Op.getOperand(2);
+ SDValue Src0 = Param->isAllOnesValue() ? Numerator : Denominator;
+
return DAG.getNode(AMDGPUISD::DIV_SCALE, DL, VT,
- Op.getOperand(1), Op.getOperand(2));
+ Src0, Denominator, Numerator);
+ }
case Intrinsic::AMDGPU_div_fmas:
return DAG.getNode(AMDGPUISD::DIV_FMAS, DL, VT,
OpenPOWER on IntegriCloud