diff options
author | Chris Lattner <sabre@nondot.org> | 2011-04-18 07:00:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-04-18 07:00:40 +0000 |
commit | 48f75ad67813037ea12d5d10d887ef1014d9c307 (patch) | |
tree | 5632def2d2cedc702d2505ddb664f478a99be9e6 /llvm/lib/CodeGen | |
parent | 562d6e82bdd5d7f3554c60709306e897b59d4f09 (diff) | |
download | bcm5719-llvm-48f75ad67813037ea12d5d10d887ef1014d9c307.tar.gz bcm5719-llvm-48f75ad67813037ea12d5d10d887ef1014d9c307.zip |
while we're at it, handle 'sdiv exact' of a power of 2 also,
this fixes a few rejects on c++ iterator loops.
llvm-svn: 129694
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index d3a721f8754..76e9a7cac2d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -360,6 +360,14 @@ bool FastISel::SelectBinaryOp(const User *I, unsigned ISDOpcode) { if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) { uint64_t Imm = CI->getZExtValue(); + // Transform "sdiv exact X, 8" -> "sra X, 3". + if (ISDOpcode == ISD::SDIV && isa<BinaryOperator>(I) && + cast<BinaryOperator>(I)->isExact() && + isPowerOf2_64(Imm)) { + Imm = Log2_64(Imm); + ISDOpcode = ISD::SRA; + } + unsigned ResultReg = FastEmit_ri_(VT.getSimpleVT(), ISDOpcode, Op0, Op0IsKill, Imm, VT.getSimpleVT()); if (ResultReg == 0) return false; |