[llvm-commits] [llvm-gcc-4.2] r83229 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Bob Wilson bob.wilson at apple.com
Thu Oct 1 17:33:15 PDT 2009


Author: bwilson
Date: Thu Oct  1 19:33:14 2009
New Revision: 83229

URL: http://llvm.org/viewvc/llvm-project?rev=83229&view=rev
Log:
When copying an aggregate, always copy it element-by-element instead of using
memcpy when the aggregate contains a single element, regardless of the size.
For ARM, we set the size limit low (4 bytes) but the <arm_neon.h> header
uses wrapper structs around NEON vector types, and then uses unions to
convert those structs to and from the underlying vector types.  Those structs
and unions should not be expanded to memcpy calls.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=83229&r1=83228&r2=83229&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Oct  1 19:33:14 2009
@@ -1317,10 +1317,12 @@
     return;  // noop copy.
 
   // If the type is small, copy the elements instead of using a block copy.
-  if (TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST &&
-      TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) <
-          TARGET_LLVM_MIN_BYTES_COPY_BY_MEMCPY) {
-    const Type *LLVMTy = ConvertType(type);
+  const Type *LLVMTy = ConvertType(type);
+  unsigned NumElts = CountAggregateElements(LLVMTy);
+  if (NumElts == 1 ||
+      (TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST &&
+       TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) <
+       TARGET_LLVM_MIN_BYTES_COPY_BY_MEMCPY)) {
 
     // Some targets (x87) cannot pass non-floating-point values using FP
     // instructions.  The LLVM type for a union may include FP elements,
@@ -1332,7 +1334,7 @@
     if ((TREE_CODE(type) != UNION_TYPE || !containsFPField(LLVMTy)) &&
         !TheTypeConverter->GCCTypeOverlapsWithLLVMTypePadding(type, LLVMTy) &&
         // Don't copy tons of tiny elements.
-        CountAggregateElements(LLVMTy) <= 8) {
+        NumElts <= 8) {
       DestLoc.Ptr = BitCastToType(DestLoc.Ptr,
                                   PointerType::getUnqual(LLVMTy));
       SrcLoc.Ptr = BitCastToType(SrcLoc.Ptr,





More information about the llvm-commits mailing list