public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC, rs6000, v2] Fix alignment of non-Altivec vector struct fields
@ 2014-07-14 19:01 Ulrich Weigand
  2014-07-14 19:22 ` Ulrich Weigand
  2014-07-15  8:32 ` Richard Biener
  0 siblings, 2 replies; 5+ messages in thread
From: Ulrich Weigand @ 2014-07-14 19:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc

Hello,

this is an attempt to update the prior patch:
https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00635.html
to add a -Wpsabi note as discussed.

However, this is causing a bit of difficulties.  First of all, the warning
triggers in a larger number of tests -- which was probably to be expected
since a number of tests in the suite explicitly work on GCC vectors defined
using various vector_size values, and any size except 16 will result in the
warning.  Note that the warning gets issued at the site of definition of
the structure type -- it does not have to be used in a function call.

More problematic is that this new warning causes four tests to fail
(it's actually 38 new FAILS since each of the tests fails in multiple
optimization levels):

FAIL: gcc.c-torture/execute/20050316-1.c compilation
gcc.c-torture/execute/20050316-1.c:53:9: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10
FAIL: gcc.c-torture/execute/20050316-3.c compilation
gcc.c-torture/execute/20050316-3.c:26:9: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10
FAIL: gcc.c-torture/execute/20050604-1.c compilation
gcc.c-torture/execute/20050604-1.c:12:1: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10
FAIL: gcc.c-torture/execute/pr23135.c compilation
gcc.c-torture/execute/pr23135.c:20:1: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10

Unfortunately, while most of the tests in the suite use the dg-test
framework which ignores "note" messages, the gcc.c-torture/execute
tests still use the old "torture" test framework, which does *not*.
(Also, in the old framework you cannot even add dg-... commands to
ignore those messages for a certain test, or add a -Wno-psabi option.)

Therefore, I'm not proposing to commit this patch as-is, but would
like to ask for feedback on how to best proceed with this.

One option might be to  move the affected tests to the dg-test framework.
Or else we might decide we don't actually need a warning for this change,
since it only affects GCC synthetic vectors, where we might not have made
strict ABI guarantees anyway ...

Thoughts?

Bye,
Ulrich


gcc/ChangeLog:

	* config/rs6000/rs6000-protos.h (rs6000_special_adjust_field_align_p):
	Add prototype.
	* config/rs6000/rs6000.c (rs6000_special_adjust_field_align_p): New
	function.
	* config/rs6000/sysv4.h (ADJUST_FIELD_ALIGN): Call it.
	* config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Likewise.
	* config/rs6000/freebsd64.h (ADJUST_FIELD_ALIGN): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/ppc64-abi-warn-3.c: New test.



Index: gcc/config/rs6000/rs6000-protos.h
===================================================================
--- gcc/config/rs6000/rs6000-protos.h	(revision 212147)
+++ gcc/config/rs6000/rs6000-protos.h	(working copy)
@@ -155,6 +155,7 @@
 
 #ifdef TREE_CODE
 extern unsigned int rs6000_data_alignment (tree, unsigned int, enum data_align);
+extern bool rs6000_special_adjust_field_align_p (tree, unsigned int);
 extern unsigned int rs6000_special_round_type_align (tree, unsigned int,
 						     unsigned int);
 extern unsigned int darwin_rs6000_special_round_type_align (tree, unsigned int,
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 212147)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -5878,6 +5878,32 @@
   return align;
 }
 
+/* Previous GCC releases forced all vector types to have 16-byte alignment.  */
+
+bool
+rs6000_special_adjust_field_align_p (tree field, unsigned int computed)
+{
+  if (TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (field)) == VECTOR_TYPE)
+    {
+      if (computed != 128)
+	{
+	  static bool warned;
+	  if (!warned && warn_psabi)
+	    {
+	      warned = true;
+	      inform (input_location,
+		      "the layout of aggregates containing vectors with"
+		      " %d-byte alignment has changed in GCC 4.10",
+		      computed / BITS_PER_UNIT);
+	    }
+	}
+      /* In current GCC there is no special case.  */
+      return false;
+    }
+
+  return false;
+}
+
 /* AIX increases natural record alignment to doubleword if the first
    field is an FP double while the FP fields remain word aligned.  */
 
Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h	(revision 212147)
+++ gcc/config/rs6000/sysv4.h	(working copy)
@@ -292,7 +292,7 @@
 /* An expression for the alignment of a structure field FIELD if the
    alignment computed in the usual way is COMPUTED.  */
 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED)				      \
-	((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)     \
+	(rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED))	      \
 	 ? 128 : COMPUTED)
 
 #undef  BIGGEST_FIELD_ALIGNMENT
Index: gcc/config/rs6000/linux64.h
===================================================================
--- gcc/config/rs6000/linux64.h	(revision 212147)
+++ gcc/config/rs6000/linux64.h	(working copy)
@@ -246,7 +246,7 @@
 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given.  */
 #undef  ADJUST_FIELD_ALIGN
 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
-  ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)	\
+  (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED))		\
    ? 128								\
    : (TARGET_64BIT							\
       && TARGET_ALIGN_NATURAL == 0					\
Index: gcc/config/rs6000/freebsd64.h
===================================================================
--- gcc/config/rs6000/freebsd64.h	(revision 212147)
+++ gcc/config/rs6000/freebsd64.h	(working copy)
@@ -367,7 +367,7 @@
 /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given.  */
 #undef  ADJUST_FIELD_ALIGN
 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
-  ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE)     \
+  (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED))		\
    ? 128                                                                \
    : (TARGET_64BIT                                                      \
       && TARGET_ALIGN_NATURAL == 0                                      \
Index: gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c
===================================================================
--- /dev/null
+++ gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c	(revision 0)
@@ -0,0 +1,9 @@
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec" } */
+
+struct test
+  {
+    int a __attribute__((vector_size (8)));
+  }; /* { dg-message "note: the layout of aggregates containing vectors with 8-byte alignment has changed" } */
+
-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-18 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-14 19:01 [RFC, rs6000, v2] Fix alignment of non-Altivec vector struct fields Ulrich Weigand
2014-07-14 19:22 ` Ulrich Weigand
2014-07-15  8:32 ` Richard Biener
2014-07-15 15:29   ` Ulrich Weigand
2014-07-18 18:21     ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).