From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: richard.guenther@gmail.com (Richard Biener)
Cc: gcc-patches@gcc.gnu.org (GCC Patches), dje.gcc@gmail.com
Subject: Re: [RFC, rs6000, v2] Fix alignment of non-Altivec vector struct fields
Date: Tue, 15 Jul 2014 15:29:00 -0000 [thread overview]
Message-ID: <201407151523.s6FFN2Gb027457@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <CAFiYyc1YVQ7t=V0ApU4rk_9h5V78bwLO1XUzhe1Ht8_UT3vQzw@mail.gmail.com> from "Richard Biener" at Jul 15, 2014 10:30:52 AM
Richard Biener wrote:
> On Mon, Jul 14, 2014 at 8:55 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> > 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?
>
> cat gcc/testsuite/gcc.c-torture/execute/pr38151.x
> set additional_flags "-Wno-psabi"
> return 0
Ah, I had forgotten about the .x files. Thanks!
Here's a version with the -Wno-psabi added to the .x files. This now
passes regression testing.
OK for mainline?
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.
* gcc.c-torture/execute/20050316-1.x: Add -Wno-psabi.
* gcc.c-torture/execute/20050604-1.x: Add -Wno-psabi.
* gcc.c-torture/execute/20050316-3.x: New file. Add -Wno-psabi.
* gcc.c-torture/execute/pr23135.x: Likewise.
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" } */
+
Index: gcc/testsuite/gcc.c-torture/execute/pr23135.x
===================================================================
--- /dev/null
+++ gcc/testsuite/gcc.c-torture/execute/pr23135.x (revision 0)
@@ -0,0 +1,2 @@
+set additional_flags "-Wno-psabi"
+return 0
Index: gcc/testsuite/gcc.c-torture/execute/20050316-1.x
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20050316-1.x (revision 212147)
+++ gcc/testsuite/gcc.c-torture/execute/20050316-1.x (working copy)
@@ -4,4 +4,5 @@
return 1
}
+set additional_flags "-Wno-psabi"
return 0;
Index: gcc/testsuite/gcc.c-torture/execute/20050316-3.x
===================================================================
--- /dev/null
+++ gcc/testsuite/gcc.c-torture/execute/20050316-3.x (revision 0)
@@ -0,0 +1,2 @@
+set additional_flags "-Wno-psabi"
+return 0
Index: gcc/testsuite/gcc.c-torture/execute/20050604-1.x
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20050604-1.x (revision 212147)
+++ gcc/testsuite/gcc.c-torture/execute/20050604-1.x (working copy)
@@ -6,4 +6,5 @@
set additional_flags "-mno-mmx"
}
+set additional_flags "-Wno-psabi"
return 0
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com
next prev parent reply other threads:[~2014-07-15 15:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 19:01 Ulrich Weigand
2014-07-14 19:22 ` Ulrich Weigand
2014-07-15 8:32 ` Richard Biener
2014-07-15 15:29 ` Ulrich Weigand [this message]
2014-07-18 18:21 ` David Edelsohn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201407151523.s6FFN2Gb027457@d06av02.portsmouth.uk.ibm.com \
--to=uweigand@de.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).