[cfe-commits] r109700 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/x86_64-arguments.c

Chris Lattner sabre at nondot.org
Wed Jul 28 16:47:21 PDT 2010


Author: lattner
Date: Wed Jul 28 18:47:21 2010
New Revision: 109700

URL: http://llvm.org/viewvc/llvm-project?rev=109700&view=rev
Log:
pass argument vectors in a type that corresponds to the user type if
possible.  This improves the example to pass <4 x float> instead of
<2 x double> but we still get awful code, and still don't get the
return value right.

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGen/x86_64-arguments.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=109700&r1=109699&r2=109700&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 28 18:47:21 2010
@@ -1432,10 +1432,22 @@
 
     // AMD64-ABI 3.2.3p3: Rule 4. If the class is SSEUP, the
     // eightbyte is passed in the upper half of the last used SSE
-    // register.
+    // register.  This only happens when 128-bit vectors are passed. 
   case SSEUp:
-    assert(Lo == SSE && "Unexpected SSEUp classification.");
+    assert(Lo == SSE && "Unexpected SSEUp classification");
     ResType = llvm::VectorType::get(llvm::Type::getDoubleTy(VMContext), 2);
+      
+    // If the preferred type is a 16-byte vector, prefer to pass it.
+    if (const llvm::VectorType *VT =
+          dyn_cast_or_null<llvm::VectorType>(PrefType)) {
+      const llvm::Type *EltTy = VT->getElementType();
+      if (VT->getBitWidth() == 128 &&
+          (EltTy->isFloatTy() || EltTy->isDoubleTy() ||
+           EltTy->isIntegerTy(8) || EltTy->isIntegerTy(16) ||
+           EltTy->isIntegerTy(32) || EltTy->isIntegerTy(64) ||
+           EltTy->isIntegerTy(128)))
+        ResType = PrefType;
+    }
     break;
   }
 

Modified: cfe/trunk/test/CodeGen/x86_64-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-arguments.c?rev=109700&r1=109699&r2=109700&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_64-arguments.c (original)
+++ cfe/trunk/test/CodeGen/x86_64-arguments.c Wed Jul 28 18:47:21 2010
@@ -152,3 +152,11 @@
   // CHECK: define %struct.f24s @f24(%struct.f23S* %X, %struct.f24s* %P2)
 }
 
+typedef float v4f32 __attribute__((__vector_size__(16)));
+
+v4f32 f25(v4f32 X) {
+  // CHECK: define <2 x double> @f25(<4 x float> %X.coerce)
+  return X+X;
+}
+
+





More information about the cfe-commits mailing list