diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-02 08:20:51 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-02 08:20:51 +0000 |
| commit | b1567bd58427c66c0c17cd4e7b628adb42de4c52 (patch) | |
| tree | 69d8e3d4f398659c96ea8141f8e2c644c858d6c6 /llvm/lib/Transforms/Scalar | |
| parent | a061859ccc17ced9829a51670bd34dc97a56cdea (diff) | |
| download | bcm5719-llvm-b1567bd58427c66c0c17cd4e7b628adb42de4c52.tar.gz bcm5719-llvm-b1567bd58427c66c0c17cd4e7b628adb42de4c52.zip | |
enhance the previous optimization to work with fcmp in addition
to icmp.
llvm-svn: 92412
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 1fcc64efe90..05da044e389 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -6180,7 +6180,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { if (Instruction *NV = FoldFCmp_IntToFP_Cst(I, LHSI, RHSC)) return NV; break; - case Instruction::Select: + case Instruction::Select: { // If either operand of the select is a constant, we can fold the // comparison into the select arms, which will cause one to be // constant folded and the select turned into a bitwise or. @@ -6205,6 +6205,20 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { return SelectInst::Create(LHSI->getOperand(0), Op1, Op2); break; } + case Instruction::Load: + if (GetElementPtrInst *GEP = + dyn_cast<GetElementPtrInst>(LHSI->getOperand(0))) { + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0))) + if (GV->isConstant() && GV->hasDefinitiveInitializer() && + !cast<LoadInst>(LHSI)->isVolatile()) + if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV, I)) + return Res; + //errs() << "NOT HANDLED: " << *GV << "\n"; + //errs() << "\t" << *GEP << "\n"; + //errs() << "\t " << I << "\n\n\n"; + } + break; + } } return Changed ? &I : 0; @@ -6586,13 +6600,16 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { case Instruction::Load: if (GetElementPtrInst *GEP = - dyn_cast<GetElementPtrInst>(LHSI->getOperand(0))) + dyn_cast<GetElementPtrInst>(LHSI->getOperand(0))) { if (GlobalVariable *GV = dyn_cast<GlobalVariable>(GEP->getOperand(0))) if (GV->isConstant() && GV->hasDefinitiveInitializer() && - !cast<LoadInst>(LHSI)->isVolatile()) { + !cast<LoadInst>(LHSI)->isVolatile()) if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV, I)) return Res; - } + //errs() << "NOT HANDLED: " << *GV << "\n"; + //errs() << "\t" << *GEP << "\n"; + //errs() << "\t " << I << "\n\n\n"; + } break; } } |

