Fix Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll
authorChris Lattner <sabre@nondot.org>
Tue, 24 Oct 2006 06:26:32 +0000 (06:26 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Oct 2006 06:26:32 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31151 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index 496449f49468c6bb95f8955702d402b45816f714..ffb095a0481ccb5bc3614489a56005720cf8b398 100644 (file)
@@ -611,11 +611,16 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
           NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt),
                                       "tmp", LI);
         } else {
-          assert(NV->getType()->isInteger() && "Unknown promotion!");
-          if (Offset && Offset < TD.getTypeSize(NV->getType())*8)
-            NV = new ShiftInst(Instruction::Shr, NV,
-                               ConstantInt::get(Type::UByteTy, Offset),
-                               LI->getName(), LI);
+          if (Offset) {
+            assert(NV->getType()->isInteger() && "Unknown promotion!");
+            if (Offset < TD.getTypeSize(NV->getType())*8)
+              NV = new ShiftInst(Instruction::Shr, NV,
+                                 ConstantInt::get(Type::UByteTy, Offset),
+                                 LI->getName(), LI);
+          } else {
+            assert((NV->getType()->isInteger() ||
+                    isa<PointerType>(NV->getType())) && "Unknown promotion!");
+          }
           NV = new CastInst(NV, LI->getType(), LI->getName(), LI);
         }
       }