diff options
author | Chris Lattner <sabre@nondot.org> | 2001-10-02 03:41:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-10-02 03:41:24 +0000 |
commit | b00c582b6d40e6b9ff2d1ed4f5eaf7930e792ace (patch) | |
tree | 44b5f879c16e7ecb2e9334ad120e3454270e1bb3 /lib/Transforms/Scalar/ConstantProp.cpp | |
parent | 1d87bcf4909b06dcd86320722653341f08b8b396 (diff) |
Commit more code over to new cast style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@697 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/ConstantProp.cpp')
-rw-r--r-- | lib/Transforms/Scalar/ConstantProp.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index d43f693dd1..61c026a139 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -82,8 +82,7 @@ ConstantFoldBinaryInst(Method *M, Method::inst_iterator &DI, // bool opt::ConstantFoldTerminator(TerminatorInst *T) { // Branch - See if we are conditional jumping on constant - if (T->getOpcode() == Instruction::Br) { - BranchInst *BI = (BranchInst*)T; + if (BranchInst *BI = dyn_cast<BranchInst>(T)) { if (BI->isUnconditional()) return false; // Can't optimize uncond branch BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0)); BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1)); @@ -136,22 +135,22 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) { inline static bool ConstantFoldInstruction(Method *M, Method::inst_iterator &II) { Instruction *Inst = *II; - if (Inst->isBinaryOp()) { + if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) { ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0)); ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1)); if (D1 && D2) - return ConstantFoldBinaryInst(M, II, (BinaryOperator*)Inst, D1, D2); + return ConstantFoldBinaryInst(M, II, cast<BinaryOperator>(Inst), D1, D2); - } else if (Inst->isUnaryOp()) { - ConstPoolVal *D = dyn_cast<ConstPoolVal>(Inst->getOperand(0)); - if (D) return ConstantFoldUnaryInst(M, II, (UnaryOperator*)Inst, D); - } else if (Inst->isTerminator()) { - return opt::ConstantFoldTerminator((TerminatorInst*)Inst); + } else if (UnaryOperator *UInst = dyn_cast<UnaryOperator>(Inst)) { + ConstPoolVal *D = dyn_cast<ConstPoolVal>(UInst->getOperand(0)); + if (D) return ConstantFoldUnaryInst(M, II, UInst, D); + } else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) { + return opt::ConstantFoldTerminator(TInst); - } else if (Inst->isPHINode()) { - PHINode *PN = (PHINode*)Inst; // If it's a PHI node and only has one operand - // Then replace it directly with that operand. + } else if (PHINode *PN = dyn_cast<PHINode>(Inst)) { + // If it's a PHI node and only has one operand + // Then replace it directly with that operand. assert(PN->getOperand(0) && "PHI Node must have at least one operand!"); if (PN->getNumOperands() == 1) { // If the PHI Node has exactly 1 operand Value *V = PN->getOperand(0); |