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 | 8d70cd9607d75cec914090345136b9d49cc1fdac (patch) | |
tree | 8a9f7e6657aec42cc6c63f65a573018b86439c65 /lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 7296e93f08f7495dbe3f25e35bff0b616b438e19 (diff) | |
download | external_llvm-8d70cd9607d75cec914090345136b9d49cc1fdac.zip external_llvm-8d70cd9607d75cec914090345136b9d49cc1fdac.tar.gz external_llvm-8d70cd9607d75cec914090345136b9d49cc1fdac.tar.bz2 |
Eliminate cast of same type instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index fcf3707..0bcd6f1 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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; |