Allow negative offset for UNSPEC_DTPOFF/UNSPEC_NTPOFF
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 12 Sep 2012 18:08:59 +0000 (18:08 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 12 Sep 2012 18:08:59 +0000 (11:08 -0700)
gcc/

PR target/54445
* config/i386/predicates.md (x86_64_immediate_operand): Allow
negative offset for UNSPEC_DTPOFF/UNSPEC_NTPOFF.

gcc/testsuite/

PR target/54445
* gcc.target/i386/pr54445-1.c: New file.
* gcc.target/i386/pr54445-2.c: Likewise.

From-SVN: r191230

gcc/ChangeLog
gcc/config/i386/predicates.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr54445-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr54445-2.c [new file with mode: 0644]

index 3fb65fe1adc310295a0363d5de1e002e28afc29f..a7b950ab79a892929d87738f846ee7a33fca79c5 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/54445
+       * config/i386/predicates.md (x86_64_immediate_operand): Allow
+       negative offset for UNSPEC_DTPOFF/UNSPEC_NTPOFF.
+
 2012-09-12  Jan Hubicka  <jh@suse.cz>
 
        * common.opt (flto-partition): Add "max".
index d4f40b1e8e25bee61197045a8d10e3a92535c7b1..5234decc9784d9a87bf0b5e2501880548d3c6b97 100644 (file)
                {
                case UNSPEC_DTPOFF:
                case UNSPEC_NTPOFF:
-                 if (offset > 0
-                     && trunc_int_for_mode (offset, SImode) == offset)
+                 if (trunc_int_for_mode (offset, SImode) == offset)
                    return true;
                }
              break;
index a72e8efcdc651a32cf78ab69cc729c61264dc6af..62f96b55f86baceae0cccf02dd5a60de180f5afe 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/54445
+       * gcc.target/i386/pr54445-1.c: New file.
+       * gcc.target/i386/pr54445-2.c: Likewise.
+
 2012-09-12  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54225
diff --git a/gcc/testsuite/gcc.target/i386/pr54445-1.c b/gcc/testsuite/gcc.target/i386/pr54445-1.c
new file mode 100644 (file)
index 0000000..72ef84e
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+__thread unsigned char tls_array[64];
+
+unsigned char
+__attribute__ ((noinline))
+tls_array_lookup_with_negative_constant(long long int position) {
+  return tls_array[position - 1];
+}
+
+int
+main ()
+{
+  int i;
+
+  for (i = 0; i < sizeof (tls_array) / sizeof (tls_array[0]); i++)
+    tls_array[i] = i;
+
+  for (i = 0; i < sizeof (tls_array) / sizeof (tls_array[0]); i++)
+    if (i != tls_array_lookup_with_negative_constant (i + 1))
+      __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr54445-2.c b/gcc/testsuite/gcc.target/i386/pr54445-2.c
new file mode 100644 (file)
index 0000000..5151c13
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile { target { *-*-linux* && { ! { ia32 } } } } } */
+/* { dg-options "-O2 -fno-pic" } */
+
+__thread unsigned char tls_array[64];
+
+unsigned char
+tls_array_lookup_with_negative_constant(long long int position) {
+  return tls_array[position - 1];
+}
+
+/* { dg-final { scan-assembler "mov(b|zbl)\[ \t\](%fs:)?tls_array@tpoff-1\\(%" } } */