diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-09-29 00:54:16 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-09-29 00:54:16 +0000 |
| commit | 0ac5ba5ade654f4eb9506e7f1d8ceaafd90ee1c1 (patch) | |
| tree | 7f5e0ce68843db340f343bdcd04599341ea5080a /llvm/lib/Transforms/Utils | |
| parent | f51e78017d8b334c019ca8b90d9d1f00886a416a (diff) | |
| download | bcm5719-llvm-0ac5ba5ade654f4eb9506e7f1d8ceaafd90ee1c1.tar.gz bcm5719-llvm-0ac5ba5ade654f4eb9506e7f1d8ceaafd90ee1c1.zip | |
Revert "[BypassSlowDivision] Improve our handling of divisions by constants"
This reverts commit r314253. It causes a miscompile on P100 in an internal
benchmark. Reverting while I investigate.
llvm-svn: 314482
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index 4aed897d641..d6c31f282e8 100644 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -339,6 +339,11 @@ Optional<QuotRemPair> FastDivInsertionTask::insertFastDivAndRem() { Value *Dividend = SlowDivOrRem->getOperand(0); Value *Divisor = SlowDivOrRem->getOperand(1); + if (isa<ConstantInt>(Divisor)) { + // Keep division by a constant for DAGCombiner. + return None; + } + VisitedSetTy SetL; ValueRange DividendRange = getValueRange(Dividend, SetL); if (DividendRange == VALRNG_LIKELY_LONG) @@ -354,9 +359,7 @@ Optional<QuotRemPair> FastDivInsertionTask::insertFastDivAndRem() { if (DividendShort && DivisorShort) { // If both operands are known to be short then just replace the long - // division with a short one in-place. Since we're not introducing control - // flow in this case, narrowing the division is always a win, even if the - // divisor is a constant (and will later get replaced by a multiplication). + // division with a short one in-place. IRBuilder<> Builder(SlowDivOrRem); Value *TruncDividend = Builder.CreateTrunc(Dividend, BypassType); @@ -366,16 +369,7 @@ Optional<QuotRemPair> FastDivInsertionTask::insertFastDivAndRem() { Value *ExtDiv = Builder.CreateZExt(TruncDiv, getSlowType()); Value *ExtRem = Builder.CreateZExt(TruncRem, getSlowType()); return QuotRemPair(ExtDiv, ExtRem); - } - - if (isa<ConstantInt>(Divisor)) { - // If the divisor is not a constant, DAGCombiner will convert it to a - // multiplication by a magic constant. It isn't clear if it is worth - // introducing control flow to get a narrower multiply. - return None; - } - - if (DividendShort && !isSignedOp()) { + } else if (DividendShort && !isSignedOp()) { // If the division is unsigned and Dividend is known to be short, then // either // 1) Divisor is less or equal to Dividend, and the result can be computed |

