r246230 - [X86] Bump Darwin MaxVectorAlign to 64 when AVX512 is enabled.

Ahmed Bougacha via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 15:42:12 PDT 2015


Author: ab
Date: Thu Aug 27 17:42:12 2015
New Revision: 246230

URL: http://llvm.org/viewvc/llvm-project?rev=246230&view=rev
Log:
[X86] Bump Darwin MaxVectorAlign to 64 when AVX512 is enabled.

Without this, 64-byte vector types (__m512), specified to be 64-byte
aligned in the AVX512 draft SysV ABI, will only be 32-byte aligned.

This is analoguous to AVX, for which we accept 32-byte max alignment.

Differential Revision: http://reviews.llvm.org/D10724

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/CodeGen/vector-alignment.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=246230&r1=246229&r2=246230&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 27 17:42:12 2015
@@ -3640,8 +3640,9 @@ public:
     if (!DarwinTargetInfo<X86_32TargetInfo>::handleTargetFeatures(Features,
                                                                   Diags))
       return false;
-    // Now that we know if we have AVX, we can decide how to align vectors.
-    MaxVectorAlign = hasFeature("avx") ? 256 : 128;
+    // We now know the features we have: we can decide how to align vectors.
+    MaxVectorAlign =
+        hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
     return true;
   }
 };
@@ -4006,8 +4007,9 @@ public:
     if (!DarwinTargetInfo<X86_64TargetInfo>::handleTargetFeatures(Features,
                                                                   Diags))
       return false;
-    // Now that we know if we have AVX, we can decide how to align vectors.
-    MaxVectorAlign = hasFeature("avx") ? 256 : 128;
+    // We now know the features we have: we can decide how to align vectors.
+    MaxVectorAlign =
+        hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
     return true;
   }
 };

Modified: cfe/trunk/test/CodeGen/vector-alignment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vector-alignment.c?rev=246230&r1=246229&r2=246230&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/vector-alignment.c (original)
+++ cfe/trunk/test/CodeGen/vector-alignment.c Thu Aug 27 17:42:12 2015
@@ -6,6 +6,10 @@
 // RUN:  -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX
 // RUN: %clang_cc1 -w -triple   i386-apple-darwin10 -target-feature +avx \
 // RUN:  -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX
+// RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 -target-feature +avx512f \
+// RUN:  -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX512
+// RUN: %clang_cc1 -w -triple   i386-apple-darwin10 -target-feature +avx512f \
+// RUN:  -emit-llvm -o - %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX512
 // rdar://11759609
 
 // At or below target max alignment with no aligned attribute should align based
@@ -13,18 +17,22 @@
 double __attribute__((vector_size(16))) v1;
 // SSE: @v1 {{.*}}, align 16
 // AVX: @v1 {{.*}}, align 16
+// AVX512: @v1 {{.*}}, align 16
 double __attribute__((vector_size(32))) v2;
 // SSE: @v2 {{.*}}, align 16
 // AVX: @v2 {{.*}}, align 32
+// AVX512: @v2 {{.*}}, align 32
 
 // Alignment above target max alignment with no aligned attribute should align
 // based on the target max.
 double __attribute__((vector_size(64))) v3;
 // SSE: @v3 {{.*}}, align 16
 // AVX: @v3 {{.*}}, align 32
+// AVX512: @v3 {{.*}}, align 64
 double __attribute__((vector_size(1024))) v4;
 // SSE: @v4 {{.*}}, align 16
 // AVX: @v4 {{.*}}, align 32
+// AVX512: @v4 {{.*}}, align 64
 
 // Aliged attribute should always override.
 double __attribute__((vector_size(16), aligned(16))) v5;
@@ -40,9 +48,11 @@ double __attribute__((vector_size(32), a
 double __attribute__((vector_size(24))) v9;
 // SSE: @v9 {{.*}}, align 16
 // AVX: @v9 {{.*}}, align 32
+// AVX512: @v9 {{.*}}, align 32
 double __attribute__((vector_size(40))) v10;
 // SSE: @v10 {{.*}}, align 16
 // AVX: @v10 {{.*}}, align 32
+// AVX512: @v10 {{.*}}, align 64
 
 // Check non-power of 2 widths with aligned attribute.
 double __attribute__((vector_size(24), aligned(64))) v11;




More information about the cfe-commits mailing list