Fix scalarrepl to not 'miscompile' undefined code, part #2.
authorChris Lattner <sabre@nondot.org>
Sun, 10 Feb 2008 19:05:37 +0000 (19:05 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 10 Feb 2008 19:05:37 +0000 (19:05 +0000)
This fixes the store case, my previous patch just fixed the load
case.  rdar://5707076.

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

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index c80f050730a04073d6974643527058b0e9c46bc3..3929d0c91922c1240225b017d691a629b7652da1 100644 (file)
@@ -1150,7 +1150,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset) {
       // then 'or' into place.
       Value *SV = SI->getOperand(0);
       const Type *AllocaType = NewAI->getType()->getElementType();
-      if (SV->getType() == AllocaType) {
+      if (SV->getType() == AllocaType && Offset == 0) {
         // All is well.
       } else if (const VectorType *PTy = dyn_cast<VectorType>(AllocaType)) {
         Value *Old = new LoadInst(NewAI, NewAI->getName()+".in", SI);