diff options
author | Chris Lattner <sabre@nondot.org> | 2002-04-15 19:45:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-04-15 19:45:29 +0000 |
commit | 3a60d04722f483ba7361591eb0e390763e9fd7f1 (patch) | |
tree | 462a21a03a2b947e5e441eb6df66760d04bb8ba5 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | ffe541feb252f03aa63fa2d5c64b2c7ca4c1987c (diff) | |
download | bcm5719-llvm-3a60d04722f483ba7361591eb0e390763e9fd7f1.tar.gz bcm5719-llvm-3a60d04722f483ba7361591eb0e390763e9fd7f1.zip |
Eliminate cast of same type instructions.
llvm-svn: 2251
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index fcf3707bac1..0bcd6f1534a 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -18,6 +18,7 @@ #include "llvm/ConstantHandling.h" #include "llvm/Function.h" #include "llvm/iMemory.h" +#include "llvm/iOther.h" #include "llvm/InstrTypes.h" #include "llvm/Pass.h" #include "llvm/Support/InstIterator.h" @@ -138,6 +139,13 @@ static bool CombineInstruction(Instruction *I) { Result = CombineBinOp(BOP); else if (MemAccessInst *MAI = dyn_cast<MemAccessInst>(I)) Result = CombineIndicies(MAI); + else if (CastInst *CI = dyn_cast<CastInst>(I)) { + if (CI->getType() == CI->getOperand(0)->getType() && !CI->use_empty()) { + CI->replaceAllUsesWith(CI->getOperand(0)); + return true; + } + + } if (!Result) return false; if (Result == I) return true; |