add another case of undefined behavior without crashing, PR3466.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63620 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 83572d6..c67c67a 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -1431,8 +1431,9 @@
   // Finally, unconditionally truncate the integer to the right width.
   unsigned LIBitWidth = TD->getTypeSizeInBits(LI->getType());
   if (LIBitWidth < NTy->getBitWidth())
-    NV = new TruncInst(NV, IntegerType::get(LIBitWidth),
-                       LI->getName(), LI);
+    NV = new TruncInst(NV, IntegerType::get(LIBitWidth), LI->getName(), LI);
+  else if (LIBitWidth > NTy->getBitWidth())
+    NV = new ZExtInst(NV, IntegerType::get(LIBitWidth), LI->getName(), LI);
 
   // If the result is an integer, this is a trunc or bitcast.
   if (isa<IntegerType>(LI->getType())) {