]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Truncate x32 DImode TLS address to a SImode register
authorH.J. Lu <hongjiu.lu@intel.com>
Sat, 12 Oct 2013 14:55:28 +0000 (14:55 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Sat, 12 Oct 2013 14:55:28 +0000 (07:55 -0700)
gcc/

PR target/58690
* config/i386/i386.c (ix86_copy_addr_to_reg): New function.
(ix86_expand_movmem): Replace copy_addr_to_reg with
ix86_copy_addr_to_reg.
(ix86_expand_setmem): Likewise.

gcc/testsuite/

PR target/58690
* gcc.target/i386/pr58690.c: New test

From-SVN: r203486

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr58690.c [new file with mode: 0644]

index aace6c4f435150bc410f184fb4db78fc336b8c09..2d0761bbeee0e43078ea7b03078e4ba1df0b4d15 100644 (file)
@@ -1,3 +1,11 @@
+2013-10-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/58690
+       * config/i386/i386.c (ix86_copy_addr_to_reg): New function.
+       (ix86_expand_movmem): Replace copy_addr_to_reg with
+       ix86_copy_addr_to_reg.
+       (ix86_expand_setmem): Likewise.
+
 2013-10-12  Alexander Monakov  <amonakov@ispras.ru>
 
        * config/i386/i386.c (ix86_expand_sse_compare_and_jump): Use mode
index c35cb700b0449d06e3fdde4037a19c821f7b83eb..02cbbbde37e09ee2e12de49fe4eb31ede29be787 100644 (file)
@@ -22076,6 +22076,21 @@ counter_mode (rtx count_exp)
   return SImode;
 }
 
+/* Copy the address to a Pmode register.  This is used for x32 to
+   truncate DImode TLS address to a SImode register. */
+
+static rtx
+ix86_copy_addr_to_reg (rtx addr)
+{
+  if (GET_MODE (addr) == Pmode)
+    return copy_addr_to_reg (addr);
+  else
+    {
+      gcc_assert (GET_MODE (addr) == DImode && Pmode == SImode);
+      return gen_rtx_SUBREG (SImode, copy_to_mode_reg (DImode, addr), 0);
+    }
+}
+
 /* When SRCPTR is non-NULL, output simple loop to move memory
    pointer to SRCPTR to DESTPTR via chunks of MODE unrolled UNROLL times,
    overall size is COUNT specified in bytes.  When SRCPTR is NULL, output the
@@ -23032,8 +23047,8 @@ ix86_expand_movmem (rtx dst, rtx src, rtx count_exp, rtx align_exp,
 
   if (!count)
     count_exp = copy_to_mode_reg (GET_MODE (count_exp), count_exp);
-  destreg = copy_addr_to_reg (XEXP (dst, 0));
-  srcreg = copy_addr_to_reg (XEXP (src, 0));
+  destreg = ix86_copy_addr_to_reg (XEXP (dst, 0));
+  srcreg = ix86_copy_addr_to_reg (XEXP (src, 0));
 
   unroll_factor = 1;
   move_mode = word_mode;
@@ -23436,7 +23451,7 @@ ix86_expand_setmem (rtx dst, rtx count_exp, rtx val_exp, rtx align_exp,
 
   if (!count)
     count_exp = copy_to_mode_reg (counter_mode (count_exp), count_exp);
-  destreg = copy_addr_to_reg (XEXP (dst, 0));
+  destreg = ix86_copy_addr_to_reg (XEXP (dst, 0));
 
   move_mode = word_mode;
   unroll_factor = 1;
index 5ab49b471a349124eb8e374c8acee655fcc4b89b..9ff25b023cfeb8a8f756a23eeff370120a738743 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/58690
+       * gcc.target/i386/pr58690.c: New test
+
 2013-10-12  Alexander Monakov  <amonakov@ispras.ru>
 
        * gcc.target/i386/builtin-ucmp.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr58690.c b/gcc/testsuite/gcc.target/i386/pr58690.c
new file mode 100644 (file)
index 0000000..87a87cc
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-options "-O2 -mx32 -maddress-mode=short" } */
+
+struct gomp_thread
+{
+  char foo[41];
+};
+extern __thread struct gomp_thread gomp_tls_data;
+void
+foo (void)
+{
+  __builtin_memset (&gomp_tls_data, '\0', sizeof (gomp_tls_data));
+}