summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-08-03 10:00:54 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-08-03 10:00:54 +0000
commit94112ebc75c9f542ab6900a7808c7e14c30c502d (patch)
tree18d6e51c7b022ad9f75d208105c7488a6aa805b7 /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
parentec45bc2feaa43dffc5e2aa01825dee422487aac3 (diff)
downloadbcm5719-llvm-94112ebc75c9f542ab6900a7808c7e14c30c502d.tar.gz
bcm5719-llvm-94112ebc75c9f542ab6900a7808c7e14c30c502d.zip
[TargetLowering] Generalise BuildSDIV function
First step towards a BuildSDIV equivalent to D49248 for non-uniform vector support - this just pushes the splat detection down into TargetLowering::BuildSDIV where its still used. Differential Revision: https://reviews.llvm.org/D50185 llvm-svn: 338838
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index e317268fa5f..1b0818d3428 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -3463,8 +3463,8 @@ SDValue TargetLowering::BuildSDIVPow2(SDNode *N, const APInt &Divisor,
/// return a DAG expression to select that will generate the same value by
/// multiplying by a magic number.
/// Ref: "Hacker's Delight" or "The PowerPC Compiler Writer's Guide".
-SDValue TargetLowering::BuildSDIV(SDNode *N, const APInt &Divisor,
- SelectionDAG &DAG, bool IsAfterLegalization,
+SDValue TargetLowering::BuildSDIV(SDNode *N, SelectionDAG &DAG,
+ bool IsAfterLegalization,
SmallVectorImpl<SDNode *> &Created) const {
EVT VT = N->getValueType(0);
SDLoc dl(N);
@@ -3474,6 +3474,12 @@ SDValue TargetLowering::BuildSDIV(SDNode *N, const APInt &Divisor,
if (!isTypeLegal(VT))
return SDValue();
+ // TODO: Add non-uniform constant support.
+ ConstantSDNode *C = isConstOrConstSplat(N->getOperand(1));
+ if (!C || C->isNullValue())
+ return SDValue();
+ const APInt &Divisor = C->getAPIntValue();
+
// If the sdiv has an 'exact' bit we can use a simpler lowering.
if (N->getFlags().hasExact())
return BuildExactSDIV(*this, N->getOperand(0), Divisor, dl, DAG, Created);
OpenPOWER on IntegriCloud