diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 53747e3..de0cba6 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -3415,10 +3415,21 @@ static bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
     const Type *TyPtr = Ty.getTypePtr();
     if (!Base)
       Base = TyPtr;
+
     if (Base != TyPtr &&
         (!Base->isVectorType() || !TyPtr->isVectorType() ||
-         Context.getTypeSize(Base) != Context.getTypeSize(TyPtr)))
-      return false;
+         Context.getTypeSize(Base) != Context.getTypeSize(TyPtr))) {
+      // "double" and "long double" have the same machine type in the 32-bit
+      // ABI, so they are considered to be the same type for the purpose of
+      // classifying homogeneous aggregates.
+      if (((!Base->isSpecificBuiltinType(BuiltinType::Double) ||
+             !TyPtr->isSpecificBuiltinType(BuiltinType::LongDouble)) &&
+            (!Base->isSpecificBuiltinType(BuiltinType::LongDouble) ||
+             !TyPtr->isSpecificBuiltinType(BuiltinType::Double))) ||
+           (Context.getTypeSize(Base) != Context.getTypeSize(TyPtr))) {
+        return false;
+      }
+    }
   }
 
   // Homogeneous Aggregates can have at most 4 members of the base type.
diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c
index 0b6f9a5..7737399 100644
--- a/test/CodeGen/arm-homogenous.c
+++ b/test/CodeGen/arm-homogenous.c
@@ -205,6 +205,17 @@ void test_struct_of_vecs(void) {
   takes_struct_of_vecs(3.0, g_vec, g_vec, 4.0);
 }
 
+typedef struct {
+  double a;
+  long double b;
+} struct_of_double_and_long_double;
+struct_of_double_and_long_double g_dld;
+
+struct_of_double_and_long_double test_struct_of_double_and_long_double(void) {
+  return g_dld;
+}
+// CHECK: define arm_aapcs_vfpcc %struct.struct_of_double_and_long_double @test_struct_of_double_and_long_double()
+
 // FIXME: Tests necessary:
 //         - Vectors
 //         - C++ stuff
