diff options
Diffstat (limited to 'gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp')
| -rw-r--r-- | gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index f711b192f60..e7828af648a 100644 --- a/gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/gnu/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -21,6 +21,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Transforms/Utils/Local.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constants.h" @@ -34,7 +35,6 @@ #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" #include "llvm/Support/KnownBits.h" -#include "llvm/Transforms/Utils/Local.h" #include <cassert> #include <cstdint> @@ -173,7 +173,7 @@ Value *FastDivInsertionTask::getReplacement(DivCacheTy &Cache) { return isDivisionOp() ? Value.Quotient : Value.Remainder; } -/// \brief Check if a value looks like a hash. +/// Check if a value looks like a hash. /// /// The routine is expected to detect values computed using the most common hash /// algorithms. Typically, hash computations end with one of the following @@ -388,6 +388,15 @@ Optional<QuotRemPair> FastDivInsertionTask::insertFastDivAndRem() { return None; } + // After Constant Hoisting pass, long constants may be represented as + // bitcast instructions. As a result, some constants may look like an + // instruction at first, and an additional check is necessary to find out if + // an operand is actually a constant. + if (auto *BCI = dyn_cast<BitCastInst>(Divisor)) + if (BCI->getParent() == SlowDivOrRem->getParent() && + isa<ConstantInt>(BCI->getOperand(0))) + return None; + if (DividendShort && !isSignedOp()) { // If the division is unsigned and Dividend is known to be short, then // either |
