$ svn merge -c 92108 https://llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r92108 into '.':
U    gcc/llvm-convert.cpp

llvm-svn: 92479
diff --git a/llvm-gcc-4.2/gcc/llvm-convert.cpp b/llvm-gcc-4.2/gcc/llvm-convert.cpp
index 5d98220..ca541d7 100644
--- a/llvm-gcc-4.2/gcc/llvm-convert.cpp
+++ b/llvm-gcc-4.2/gcc/llvm-convert.cpp
@@ -2999,9 +2999,13 @@
     if (ValTy->isSingleValueType()) {
       // Non-bitfield, scalar value.  Just emit a store.
       Value *RHS = Emit(rhs, 0);
-      // Convert RHS to the right type if we can, otherwise convert the pointer.
+      // Convert RHS to the right type if we can.  If LHS is bigger than RHS
+      // we must convert; all the bits of LHS must be stored into.  Otherwise
+      // convert the pointer.
       const PointerType *PT = cast<PointerType>(LV.Ptr->getType());
-      if (PT->getElementType()->canLosslesslyBitCastTo(RHS->getType()))
+      if (PT->getElementType()->canLosslesslyBitCastTo(RHS->getType()) ||
+          (PT->getElementType()->getPrimitiveSizeInBits() >
+           RHS->getType()->getPrimitiveSizeInBits()))
         RHS = CastToAnyType(RHS, RHSSigned, PT->getElementType(), LHSSigned);
       else
         LV.Ptr = BitCastToType(LV.Ptr, RHS->getType()->getPointerTo());