[PATCH] S/390: Run %a0:DI splitters only after reload
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 15 Oct 2019 10:22:35 +0000 (10:22 +0000)
committerIlya Leoshkevich <iii@gcc.gnu.org>
Tue, 15 Oct 2019 10:22:35 +0000 (10:22 +0000)
gcc/ChangeLog:

2019-10-15  Ilya Leoshkevich  <iii@linux.ibm.com>

* config/s390/s390.md: Run %a0:DI splitters only after reload.

gcc/testsuite/ChangeLog:

2019-10-15  Ilya Leoshkevich  <iii@linux.ibm.com>

* gcc.target/s390/load-thread-pointer-once.c: New test.

From-SVN: r276989

gcc/ChangeLog
gcc/config/s390/s390.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c [new file with mode: 0644]

index 6e16ee81e5397ff69ae31c00e6b5c366c7dd9420..23213c75c690d31d79e1321a12edda40a11b51e8 100644 (file)
@@ -1,3 +1,7 @@
+2019-10-15  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+       * config/s390/s390.md: Run %a0:DI splitters only after reload.
+
 2019-10-15  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92094
index 4f7bde6616b241c3df695f522390b327c6172ec5..1e6439d5fd6408acb7a14cbccbbabcaad0e87b3a 100644 (file)
                               *,*,yes")
 ])
 
+; Splitters for loading/storing TLS pointers from/to %a0:DI.
+; Do this only during split2, which runs after reload. At the point when split1
+; runs, some of %a0:DI occurrences might be nested inside other rtxes and thus
+; not matched. As a result, only some occurrences will be split, which will
+; prevent CSE. At the point when split2 runs, reload will have ensured that no
+; nested references exist.
+
 (define_split
   [(set (match_operand:DI 0 "register_operand" "")
         (match_operand:DI 1 "register_operand" ""))]
-  "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
+  "TARGET_ZARCH && ACCESS_REG_P (operands[1]) && reload_completed"
   [(set (match_dup 2) (match_dup 3))
    (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
    (set (strict_low_part (match_dup 2)) (match_dup 4))]
 (define_split
   [(set (match_operand:DI 0 "register_operand" "")
         (match_operand:DI 1 "register_operand" ""))]
-  "TARGET_ZARCH && ACCESS_REG_P (operands[0])
+  "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed
    && dead_or_set_p (insn, operands[1])"
   [(set (match_dup 3) (match_dup 2))
    (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
 (define_split
   [(set (match_operand:DI 0 "register_operand" "")
         (match_operand:DI 1 "register_operand" ""))]
-  "TARGET_ZARCH && ACCESS_REG_P (operands[0])
+  "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed
    && !dead_or_set_p (insn, operands[1])"
   [(set (match_dup 3) (match_dup 2))
    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
index 7fbb8dd64e85f9efeaa3bfa466403f113c3d3d44..d70012a8386782018a566b15a6aafad5e26351b3 100644 (file)
@@ -1,3 +1,7 @@
+2019-10-15  Ilya Leoshkevich  <iii@linux.ibm.com>
+
+       * gcc.target/s390/load-thread-pointer-once.c: New test.
+
 2019-10-15  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92094
diff --git a/gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c b/gcc/testsuite/gcc.target/s390/load-thread-pointer-once.c
new file mode 100644 (file)
index 0000000..21a5bfa
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+__thread void *foo;
+
+void *bar()
+{
+  return (foo = __builtin_thread_pointer());
+}
+
+/* { dg-final { scan-assembler-times {\n\tear\t} 2 { target { lp64 } } } } */
+/* { dg-final { scan-assembler-times {\n\tear\t} 1 { target { ! lp64 } } } } */