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]

llvm-svn: 3897
This commit is contained in:
Chris Lattner 2002-09-23 23:39:43 +00:00
parent bacc51a4e3
commit b6c408778a

View File

@ -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) {