Define MAX_FIXED_MODE_SIZE/TARGET_MEMBER_TYPE_FORCES_BLK for i386
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 17 Aug 2012 19:59:46 +0000 (19:59 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Fri, 17 Aug 2012 19:59:46 +0000 (12:59 -0700)
gcc/

PR target/20020
* config/i386/i386.c (ix86_member_type_forces_blk): New function.
(TARGET_MEMBER_TYPE_FORCES_BLK): New macro.

* config/i386/i386.h (MAX_FIXED_MODE_SIZE): New macro.

gcc/testsuite/

PR target/20020
* gcc.target/i386/pr20020-1.c: New test.
* gcc.target/i386/pr20020-2.c: Likewise.
* gcc.target/i386/pr20020-3.c: Likewise.

Co-Authored-By: Gary Funck <gary@intrepid.com>
From-SVN: r190492

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr20020-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr20020-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr20020-3.c [new file with mode: 0644]

index 3f74243c00b955551222a611aa61fcc7a7deade1..ce7c0e07f177a3c150df4c454d7645f89a839fda 100644 (file)
@@ -1,3 +1,12 @@
+2012-08-17  H.J. Lu  <hongjiu.lu@intel.com>
+           Gary Funck <gary@intrepid.com>
+
+       PR target/20020
+       * config/i386/i386.c (ix86_member_type_forces_blk): New function.
+       (TARGET_MEMBER_TYPE_FORCES_BLK): New macro.
+
+       * config/i386/i386.h (MAX_FIXED_MODE_SIZE): New macro.
+
 2012-08-17  Marc Glisse  <marc.glisse@inria.fr>
 
        * simplify-rtx.c (simplify_binary_operation_1): Optimize shuffle of
 2012-08-17  Marc Glisse  <marc.glisse@inria.fr>
 
        * simplify-rtx.c (simplify_binary_operation_1): Optimize shuffle of
index 976bbb4514c5db4462e4e26d98d79e273952a499..5da4da2b8a9f0640f70642ed30275e1f286e80f9 100644 (file)
@@ -7545,6 +7545,18 @@ ix86_promote_function_mode (const_tree type, enum machine_mode mode,
                                        for_return);
 }
 
                                        for_return);
 }
 
+/* Return true if a structure, union or array with MODE containing FIELD
+   should be accessed using BLKmode.  */
+
+static bool
+ix86_member_type_forces_blk (const_tree field, enum machine_mode mode)
+{
+  /* Union with XFmode must be in BLKmode.  */
+  return (mode == XFmode
+         && (TREE_CODE (DECL_FIELD_CONTEXT (field)) == UNION_TYPE
+             || TREE_CODE (DECL_FIELD_CONTEXT (field)) == QUAL_UNION_TYPE));
+}
+
 rtx
 ix86_libcall_value (enum machine_mode mode)
 {
 rtx
 ix86_libcall_value (enum machine_mode mode)
 {
@@ -40725,6 +40737,9 @@ ix86_memmodel_check (unsigned HOST_WIDE_INT val)
 #undef TARGET_PROMOTE_FUNCTION_MODE
 #define TARGET_PROMOTE_FUNCTION_MODE ix86_promote_function_mode
 
 #undef TARGET_PROMOTE_FUNCTION_MODE
 #define TARGET_PROMOTE_FUNCTION_MODE ix86_promote_function_mode
 
+#undef TARGET_MEMBER_TYPE_FORCES_BLK
+#define TARGET_MEMBER_TYPE_FORCES_BLK ix86_member_type_forces_blk
+
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD ix86_secondary_reload
 
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD ix86_secondary_reload
 
index 5ff82abe93e7a7a4ff8de64801ac1737f7150d2c..11f79e3f670afa0e56c16b58ff32ccf87b572469 100644 (file)
@@ -1816,6 +1816,10 @@ do {                                                     \
 #define BRANCH_COST(speed_p, predictable_p) \
   (!(speed_p) ? 2 : (predictable_p) ? 0 : ix86_branch_cost)
 
 #define BRANCH_COST(speed_p, predictable_p) \
   (!(speed_p) ? 2 : (predictable_p) ? 0 : ix86_branch_cost)
 
+/* An integer expression for the size in bits of the largest integer machine
+   mode that should actually be used.  We allow pairs of registers.  */
+#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
+
 /* Define this macro as a C expression which is nonzero if accessing
    less than a word of memory (i.e. a `char' or a `short') is no
    faster than accessing a word of memory, i.e., if such access
 /* Define this macro as a C expression which is nonzero if accessing
    less than a word of memory (i.e. a `char' or a `short') is no
    faster than accessing a word of memory, i.e., if such access
index 6f561b86039568565c4a21234e0c947367337341..8dccf8bc48f0077688ef780fe8ed40512ecdf42a 100644 (file)
@@ -1,3 +1,11 @@
+2012-08-17  H.J. Lu  <hongjiu.lu@intel.com>
+           Gary Funck <gary@intrepid.com>
+
+       PR target/20020
+       * gcc.target/i386/pr20020-1.c: New test.
+       * gcc.target/i386/pr20020-2.c: Likewise.
+       * gcc.target/i386/pr20020-3.c: Likewise.
+
 2012-08-17  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.target/i386/perm-concat.c: New test.
 2012-08-17  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.target/i386/perm-concat.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr20020-1.c b/gcc/testsuite/gcc.target/i386/pr20020-1.c
new file mode 100644 (file)
index 0000000..3f10970
--- /dev/null
@@ -0,0 +1,26 @@
+/* Check that 128-bit struct's are represented as TImode values.  */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fdump-rtl-expand" } */
+
+struct shared_ptr_struct
+{
+  unsigned long long phase:48;
+  unsigned short thread:16;
+  union
+    {
+      void *addr;
+      unsigned long long pad;
+    };
+};
+typedef struct shared_ptr_struct sptr_t;
+
+sptr_t S;
+
+sptr_t
+sptr_result (void)
+{
+  return S;
+}
+/* { dg-final { scan-rtl-dump "\\\(set \\\(reg:TI \[0-9\]* \\\[ <retval> \\\]\\\)" "expand" } } */
+/* { dg-final { scan-rtl-dump "\\\(set \\\(reg/i:TI 0 ax\\\)" "expand" } } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr20020-2.c b/gcc/testsuite/gcc.target/i386/pr20020-2.c
new file mode 100644 (file)
index 0000000..e8c5b3d
--- /dev/null
@@ -0,0 +1,24 @@
+/* Check that 128-bit struct's are represented as TImode values.  */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fdump-rtl-expand" } */
+
+struct shared_ptr_struct
+{
+  unsigned long long phase:48;
+  unsigned short thread:16;
+  union
+    {
+      void *addr;
+      unsigned long long pad;
+    };
+};
+typedef struct shared_ptr_struct sptr_t;
+
+void
+copy_sptr (sptr_t *dest, sptr_t src)
+{
+  *dest = src;
+}
+
+/* { dg-final { scan-rtl-dump "\\\(set \\\(reg:TI \[0-9\]*" "expand" } } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr20020-3.c b/gcc/testsuite/gcc.target/i386/pr20020-3.c
new file mode 100644 (file)
index 0000000..b1cc926
--- /dev/null
@@ -0,0 +1,27 @@
+/* Check that 128-bit struct's are represented as TImode values.  */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fdump-rtl-expand" } */
+
+struct shared_ptr_struct
+{
+  unsigned long long phase:48;
+  unsigned short thread:16;
+  union
+    {
+      void *addr;
+      unsigned long long pad;
+    };
+};
+typedef struct shared_ptr_struct sptr_t;
+
+sptr_t sptr_1, sptr_2;
+
+void
+copy_sptr (void)
+{
+  sptr_1 = sptr_2;  
+}
+
+/* { dg-final { scan-rtl-dump "\\\(set \\\(reg:TI \[0-9\]*" "expand" } } */
+/* { dg-final { scan-rtl-dump "\\\(set \\\(mem/c:TI" "expand" } } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */