diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-08-08 10:00:54 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-08-08 10:00:54 +0000 |
commit | a10cfcc1dba2cd8be5c52cf28f4664e7ef523d77 (patch) | |
tree | 967bbe4accc5eac1a0a4d69d78ef7172cf647358 /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | |
parent | b33a4c02cc24bcc79c00f16dfb61f43e7f4bb2e3 (diff) | |
download | bcm5719-llvm-a10cfcc1dba2cd8be5c52cf28f4664e7ef523d77.tar.gz bcm5719-llvm-a10cfcc1dba2cd8be5c52cf28f4664e7ef523d77.zip |
[TargetLowering] BuildUDIV - Early out for divide by one (PR38477)
We're not handling the UDIV by one special case properly - for now just early out.
llvm-svn: 339229
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index d3d13a21043..58b9f450f57 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -3561,6 +3561,7 @@ SDValue TargetLowering::BuildUDIV(SDNode *N, SelectionDAG &DAG, auto BuildUDIVPattern = [](const APInt &Divisor, unsigned &PreShift, APInt &Magic, unsigned &PostShift) { + assert(!Divisor.isOneValue() && "UDIV by one not supported"); // FIXME: We should use a narrower constant when the upper // bits are known to be zero. APInt::mu magics = Divisor.magicu(); @@ -3606,6 +3607,9 @@ SDValue TargetLowering::BuildUDIV(SDNode *N, SelectionDAG &DAG, auto *C = dyn_cast<ConstantSDNode>(N1.getOperand(i)); if (!C || C->isNullValue() || C->getAPIntValue().getBitWidth() != EltBits) return SDValue(); + // TODO: Handle udiv by one. + if (C->isOne()) + return SDValue(); APInt MagicVal; unsigned PreShiftVal, PostShiftVal; bool SelNPQ = BuildUDIVPattern(C->getAPIntValue(), PreShiftVal, MagicVal, |