aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edelsohn <dje.gcc@gmail.com>2021-03-09 17:52:36 -0500
committerDavid Edelsohn <dje.gcc@gmail.com>2021-03-10 18:52:50 -0500
commit4fa6356be14414957be05bdf5e22037fe1bea283 (patch)
tree9633995df16c876eedf1b570016ed91be3698d56
parent8c21bc6646dbe3365d7f89843a79eee823aa3b52 (diff)
downloadgcc-4fa6356be14414957be05bdf5e22037fe1bea283.zip
gcc-4fa6356be14414957be05bdf5e22037fe1bea283.tar.gz
gcc-4fa6356be14414957be05bdf5e22037fe1bea283.tar.bz2
aix: align double complex
AIX word-aligns floating point doubles. This behavior also extends to double _Complex, which had been overlooked when compiler support for double _Complex was added. This patch adds DCmode to the modes whose alignment is adjusted and adds a testcase to confirm the correct alignment. gcc/ChangeLog: 2021-03-10 David Edelsohn <dje.gcc@gmail.com> PR target/99492 * config/rs6000/aix.h (ADJUST_FIELD_ALIGN): Add check for DCmode. * config/rs6000/rs6000.c (rs6000_special_round_type_align): Same. gcc/testsuite/ChangeLog: 2021-03-10 David Edelsohn <dje.gcc@gmail.com> PR target/99492 * gcc.target/powerpc/pr99492.c: New testcase.
-rw-r--r--gcc/config/rs6000/aix.h3
-rw-r--r--gcc/config/rs6000/rs6000.c3
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr99492.c50
3 files changed, 54 insertions, 2 deletions
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index 5e8743a..2db50c8 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -224,7 +224,8 @@
/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
#define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
((TARGET_ALIGN_NATURAL == 0 \
- && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \
+ && (TYPE_MODE (strip_array_types (TYPE)) == DFmode \
+ || TYPE_MODE (strip_array_types (TYPE)) == DCmode)) \
? MIN ((COMPUTED), 32) \
: (COMPUTED))
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c89fb6e..35ecf5a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -7855,7 +7855,8 @@ rs6000_special_round_type_align (tree type, unsigned int computed,
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
- if (type != error_mark_node && TYPE_MODE (type) == DFmode)
+ if (type != error_mark_node
+ && (TYPE_MODE (type) == DFmode || TYPE_MODE (type) == DCmode))
align = MAX (align, 64);
}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr99492.c b/gcc/testsuite/gcc.target/powerpc/pr99492.c
new file mode 100644
index 0000000..ae36cb3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr99492.c
@@ -0,0 +1,50 @@
+/* { dg-do run { target { powerpc*-ibm-aix* } } } */
+/* { dg-options "" } */
+
+void abort (void);
+
+struct A {
+ double _Complex a[64];
+};
+
+struct B {
+ double b[64];
+};
+
+struct C {
+ char c1;
+ double _Complex c2;
+};
+
+struct D {
+ char c1;
+ double c2;
+};
+
+int main() {
+ if (__alignof(double _Complex) != 8)
+ abort();
+
+ if (__alignof(struct A) != 8)
+ abort;
+
+ if (__alignof(struct C) != 4)
+ abort;
+
+ if (__builtin_offsetof(struct C, c2) != 4)
+ abort();
+
+ if (__alignof(double) != 8)
+ abort();
+
+ if (__alignof(struct B) != 8)
+ abort();
+
+ if (__alignof(struct D) != 4)
+ abort();
+
+ if (__builtin_offsetof(struct D, c2) != 4)
+ abort();
+
+ return 0;
+}