vector casts of casts are eliminable. Transform this:
authorChris Lattner <sabre@nondot.org>
Sun, 2 Apr 2006 05:43:13 +0000 (05:43 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 2 Apr 2006 05:43:13 +0000 (05:43 +0000)
        %tmp = cast <4 x uint> %tmp to <4 x int>                ; <<4 x int>> [#uses=1]
        %tmp = cast <4 x int> %tmp to <4 x float>               ; <<4 x float>> [#uses=1]

into:

        %tmp = cast <4 x uint> %tmp to <4 x float>              ; <<4 x float>> [#uses=1]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27355 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 82e70073e83845ef7e3f6b6c4d53e6c9aac044cc..65548aff0452fa07d0522d7fce6bbe97a72095aa 100644 (file)
@@ -4539,6 +4539,10 @@ static bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy,
       SrcTy->getPrimitiveSize() < MidTy->getPrimitiveSize())
     return true;
   
+  // Packed type conversions don't modify bits.
+  if (isa<PackedType>(SrcTy) && isa<PackedType>(MidTy) &&isa<PackedType>(DstTy))
+    return true;
+  
   return false;
 }