[PATCH] D33786: [ARM] Fix Neon vector type alignment to 64-bit

Javed Absar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 10:09:09 PDT 2017


javed.absar created this revision.
Herald added subscribers: kristof.beyls, aemerson.

This is restricted version of patch - https://reviews.llvm.org/D33205
that I reverted as it was leading to ABI breaks on darwin etc.
This patch restricts the fix to AAPCS only.


https://reviews.llvm.org/D33786

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/neon-aapcs-align.c


Index: test/CodeGen/neon-aapcs-align.c
===================================================================
--- /dev/null
+++ test/CodeGen/neon-aapcs-align.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple armv7a--none-eabi -target-abi aapcs  \
+// RUN: -target-feature +neon -emit-llvm -w -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS
+
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-abi darwinpcs \
+// RUN: -target-feature +neon -emit-llvm -w -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=OTHERS
+
+// RUN: %clang_cc1 -triple armv7-none-linux-androideabi -target-abi aapcs-linux \
+// RUN: -target-feature +neon -emit-llvm -w -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=OTHERS
+
+#include <arm_neon.h>
+// Neon types have 64-bit alignment
+int32x4_t gl_b;
+void t3(int32x4_t *src) {
+// CHECK: @t3
+  gl_b = *src;
+// AAPCS: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 8
+// OTHERS: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 16
+}
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5385,6 +5385,10 @@
     // ARM has atomics up to 8 bytes
     setAtomic();
 
+    // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS)
+    if (getABI() =="aapcs")
+      MaxVectorAlign = 64;
+
     // Do force alignment of members that follow zero length bitfields.  If
     // the alignment of the zero-length bitfield is greater than the member
     // that follows it, `bar', `bar' will be aligned as the  type of the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33786.101042.patch
Type: text/x-patch
Size: 1581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170601/34b904d2/attachment.bin>


More information about the llvm-commits mailing list