public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH: PR target/20020: 128 bit structs not targeted to TImode
@ 2012-08-16 17:42 H.J. Lu
  2012-08-17 19:35 ` Uros Bizjak
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2012-08-16 17:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Gary Funck, Richard Henderson, Uros Bizjak, jh

Hi,

My email sent to gcc-patches@gcc.gnu.org was bounced as spam.  I am
resending it.  This patch defines both MAX_FIXED_MODE_SIZE and
MEMBER_TYPE_FORCES_BLK for i386.  MEMBER_TYPE_FORCES_BLK is needed so
that we always put union with XFmode field in BLKmode.  This patch
doesn't change any ABI since both MAX_FIXED_MODE_SIZE and
MEMBER_TYPE_FORCES_BLK aren't ABI macros.  They only change code
quality.  Tested on Linux/x86-64.  OK to install?

Thanks.


H.J.
---
gcc/

2012-08-16  H.J. Lu  <hongjiu.lu@intel.com>
	    Gary Funck <gary@intrepid.com>

	PR target/20020
	* config/i386/i386.h (MAX_FIXED_MODE_SIZE): New macro.
	(MEMBER_TYPE_FORCES_BLK): Likewise.

gcc/testsuite/

2012-08-16  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.

diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 5ff82ab..4046a9a 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1816,6 +1816,16 @@ do {							\
 #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)
+
+/* Union with XFmode must be in BLKmode.  */
+#define MEMBER_TYPE_FORCES_BLK(FIELD, MODE)				\
+  ((MODE) == XFmode							\
+   && (TREE_CODE (DECL_FIELD_CONTEXT (FIELD)) == UNION_TYPE		\
+       || TREE_CODE (DECL_FIELD_CONTEXT (FIELD)) == QUAL_UNION_TYPE))
+
 /* 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
diff --git a/gcc/testsuite/gcc.target/i386/pr20020-1.c b/gcc/testsuite/gcc.target/i386/pr20020-1.c
new file mode 100644
index 0000000..3f10970
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-1.c
@@ -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
index 0000000..e8c5b3d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-2.c
@@ -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
index 0000000..b1cc926
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-3.c
@@ -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" } } */

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

* Re: PATCH: PR target/20020: 128 bit structs not targeted to TImode
  2012-08-16 17:42 PATCH: PR target/20020: 128 bit structs not targeted to TImode H.J. Lu
@ 2012-08-17 19:35 ` Uros Bizjak
  2012-08-17 19:57   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2012-08-17 19:35 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Gary Funck, Richard Henderson, jh

On Thu, Aug 16, 2012 at 7:41 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:

> My email sent to gcc-patches@gcc.gnu.org was bounced as spam.  I am
> resending it.  This patch defines both MAX_FIXED_MODE_SIZE and
> MEMBER_TYPE_FORCES_BLK for i386.  MEMBER_TYPE_FORCES_BLK is needed so
> that we always put union with XFmode field in BLKmode.  This patch
> doesn't change any ABI since both MAX_FIXED_MODE_SIZE and
> MEMBER_TYPE_FORCES_BLK aren't ABI macros.  They only change code
> quality.  Tested on Linux/x86-64.  OK to install?

> gcc/
>
> 2012-08-16  H.J. Lu  <hongjiu.lu@intel.com>
>             Gary Funck <gary@intrepid.com>
>
>         PR target/20020
>         * config/i386/i386.h (MAX_FIXED_MODE_SIZE): New macro.
>         (MEMBER_TYPE_FORCES_BLK): Likewise.
>
> gcc/testsuite/
>
> 2012-08-16  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.

OK, but please check for possible xmm vs. integer reg pair code
regressions and similar for mm vs. int reg pair on 32bit targets.

Thanks,
Uros.

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

* Re: PATCH: PR target/20020: 128 bit structs not targeted to TImode
  2012-08-17 19:35 ` Uros Bizjak
@ 2012-08-17 19:57   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2012-08-17 19:57 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches, Gary Funck, Richard Henderson, jh

On Fri, Aug 17, 2012 at 12:35 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Aug 16, 2012 at 7:41 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>
>> My email sent to gcc-patches@gcc.gnu.org was bounced as spam.  I am
>> resending it.  This patch defines both MAX_FIXED_MODE_SIZE and
>> MEMBER_TYPE_FORCES_BLK for i386.  MEMBER_TYPE_FORCES_BLK is needed so
>> that we always put union with XFmode field in BLKmode.  This patch
>> doesn't change any ABI since both MAX_FIXED_MODE_SIZE and
>> MEMBER_TYPE_FORCES_BLK aren't ABI macros.  They only change code
>> quality.  Tested on Linux/x86-64.  OK to install?
>
>> gcc/
>>
>> 2012-08-16  H.J. Lu  <hongjiu.lu@intel.com>
>>             Gary Funck <gary@intrepid.com>
>>
>>         PR target/20020
>>         * config/i386/i386.h (MAX_FIXED_MODE_SIZE): New macro.
>>         (MEMBER_TYPE_FORCES_BLK): Likewise.
>>
>> gcc/testsuite/
>>
>> 2012-08-16  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.
>
> OK, but please check for possible xmm vs. integer reg pair code
> regressions and similar for mm vs. int reg pair on 32bit targets.
>
> Thanks,
> Uros.

This is the path I am checking in since MEMBER_TYPE_FORCES_BLK
has been converted to a target hook.  Tested on Linux/x86-64.

Thanks.

-- 
H.J.
---
gcc/

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.

gcc/testsuite/

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.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 976bbb4..5da4da2 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7545,6 +7545,18 @@ ix86_promote_function_mode (const_tree type,
enum machine_mode mode,
 					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)
 {
@@ -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_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

diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 5ff82ab..11f79e3 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1816,6 +1816,10 @@ do {							\
 #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
diff --git a/gcc/testsuite/gcc.target/i386/pr20020-1.c
b/gcc/testsuite/gcc.target/i386/pr20020-1.c
new file mode 100644
index 0000000..3f10970
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-1.c
@@ -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
index 0000000..e8c5b3d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-2.c
@@ -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
index 0000000..b1cc926
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr20020-3.c
@@ -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" } } */
-- 
1.7.11.2

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

end of thread, other threads:[~2012-08-17 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 17:42 PATCH: PR target/20020: 128 bit structs not targeted to TImode H.J. Lu
2012-08-17 19:35 ` Uros Bizjak
2012-08-17 19:57   ` H.J. Lu

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).