aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-23 23:39:43 +0000
committerChris Lattner <sabre@nondot.org>2002-09-23 23:39:43 +0000
commitd06451f920a8927cd87d0a4af730015365151ffe (patch)
tree6a74a7625371a89d8289778e1cf0c6982e3e0847
parenta30b70f381e2a7342cdfdee05fba25c1b77a56eb (diff)
Optimize away cases like:
%cast109 = cast uint %cast212 to short ; <short> [#uses=1] %cast214 = cast short %cast109 to uint ; <uint> [#uses=1] %cast215 = cast uint %cast214 to short ; <short> [#uses=1] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3897 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 082dc020b0..b60d1fa972 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -536,6 +536,12 @@ static inline bool isEliminableCastOfCast(const CastInst &CI,
if (SrcSize >= MidSize && MidSize >= DstSize)
return true;
+ // Cases where the source and destination type are the same, but the middle
+ // type is bigger are noops.
+ //
+ if (SrcSize == DstSize && MidSize > SrcSize)
+ return true;
+
// If we are monotonically growing, things are more complex.
//
if (SrcSize <= MidSize && MidSize <= DstSize) {