mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 23:18:58 +00:00
Expand SCEVUDiv of power of 2 to a lshr instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53217 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
77c8f7674d
commit
6177fd4fce
@ -102,11 +102,7 @@ namespace llvm {
|
||||
|
||||
Value *visitMulExpr(SCEVMulExpr *S);
|
||||
|
||||
Value *visitUDivExpr(SCEVUDivExpr *S) {
|
||||
Value *LHS = expand(S->getLHS());
|
||||
Value *RHS = expand(S->getRHS());
|
||||
return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt);
|
||||
}
|
||||
Value *visitUDivExpr(SCEVUDivExpr *S);
|
||||
|
||||
Value *visitAddRecExpr(SCEVAddRecExpr *S);
|
||||
|
||||
|
@ -129,6 +129,20 @@ Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
|
||||
return V;
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitUDivExpr(SCEVUDivExpr *S) {
|
||||
Value *LHS = expand(S->getLHS());
|
||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getRHS())) {
|
||||
const APInt &RHS = SC->getValue()->getValue();
|
||||
if (RHS.isPowerOf2())
|
||||
return InsertBinop(Instruction::LShr, LHS,
|
||||
ConstantInt::get(S->getType(), RHS.logBase2()),
|
||||
InsertPt);
|
||||
}
|
||||
|
||||
Value *RHS = expand(S->getRHS());
|
||||
return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt);
|
||||
}
|
||||
|
||||
Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) {
|
||||
const Type *Ty = S->getType();
|
||||
const Loop *L = S->getLoop();
|
||||
|
Loading…
Reference in New Issue
Block a user