diff options
Diffstat (limited to 'lib/Transforms/Utils/BypassSlowDivision.cpp')
-rw-r--r-- | lib/Transforms/Utils/BypassSlowDivision.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/BypassSlowDivision.cpp b/lib/Transforms/Utils/BypassSlowDivision.cpp index ac18b7d5a0..821b588112 100644 --- a/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -238,14 +238,24 @@ bool llvm::bypassSlowDivision(Function &F, if (!UseDivOp && !UseRemOp) continue; + // Skip division on vector types, only optimize integer instructions + if (!J->getType()->isIntegerTy()) + continue; + + // Get same type in global context + IntegerType *T = cast<IntegerType>(J->getType()); + IntegerType *GT = IntegerType::get(getGlobalContext(), T->getBitWidth()); + // Continue if div/rem type is not bypassed - DenseMap<Type *, Type *>::const_iterator BT = - BypassTypeMap.find(J->getType()); - if (BT == BypassTypeMap.end()) + DenseMap<Type *, Type *>::const_iterator BI = BypassTypeMap.find(GT); + if (BI == BypassTypeMap.end()) continue; - IntegerType *BypassType = cast<IntegerType>(BT->second); - MadeChange |= reuseOrInsertFastDiv(F, I, J, BypassType, UseDivOp, + // Get the bypass type in the original context + IntegerType *GBT = cast<IntegerType>(BI->second); + IntegerType *BT = IntegerType::get(J->getContext(), GBT->getBitWidth()); + + MadeChange |= reuseOrInsertFastDiv(F, I, J, BT, UseDivOp, UseSignedOp, DivCache); } |