IBM Z: Use the dedicated NOP instructions for "nop"
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Fri, 6 Apr 2018 07:45:42 +0000 (07:45 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Fri, 6 Apr 2018 07:45:42 +0000 (07:45 +0000)
We still use lr r0,r0 as a NOP instruction although we have some kind
of dedicated NOP instruction (nopr) which maps to a "branch never".

As a side-effect this fixes testcases scanning for NOPs
e.g. patchable_function_entry-*.

As another side-effect this makes it difficult to distingiush NOPs
generated for hotpatching from NOPs added when using -O0 to attach
location information to it.  Hence I had to make sure that the hotpatch
testcases get skipped when compiling without optimization.

gcc/ChangeLog:

2018-04-06  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/s390/s390.c (s390_z10_optimize_cmp): Expand dedicated NOP
instructions.
* config/s390/s390.md (UNSPECV_NOP_LR_0, UNSPECV_NOP_LR_1): New
constant definitions.
("nop"): lr 0,0 -> nopr r0
("nop_lr0", "nop_lr1"): New insn definitions.

gcc/testsuite/ChangeLog:

2018-04-06  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gcc.target/s390/s390.exp: Remove -O0 from list of torture
options.
* gcc.target/s390/hotpatch-1.c: Skip when building without
optimization.
* gcc.target/s390/hotpatch-10.c: Likewise.
* gcc.target/s390/hotpatch-11.c: Likewise.
* gcc.target/s390/hotpatch-12.c: Likewise.
* gcc.target/s390/hotpatch-13.c: Likewise.
* gcc.target/s390/hotpatch-14.c: Likewise.
* gcc.target/s390/hotpatch-15.c: Likewise.
* gcc.target/s390/hotpatch-16.c: Likewise.
* gcc.target/s390/hotpatch-17.c: Likewise.
* gcc.target/s390/hotpatch-18.c: Likewise.
* gcc.target/s390/hotpatch-19.c: Likewise.
* gcc.target/s390/hotpatch-2.c: Likewise.
* gcc.target/s390/hotpatch-3.c: Likewise.
* gcc.target/s390/hotpatch-4.c: Likewise.
* gcc.target/s390/hotpatch-5.c: Likewise.
* gcc.target/s390/hotpatch-6.c: Likewise.
* gcc.target/s390/hotpatch-7.c: Likewise.
* gcc.target/s390/hotpatch-8.c: Likewise.
* gcc.target/s390/hotpatch-9.c: Likewise.

From-SVN: r259164

24 files changed:
gcc/ChangeLog
gcc/config/s390/s390.c
gcc/config/s390/s390.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/hotpatch-1.c
gcc/testsuite/gcc.target/s390/hotpatch-10.c
gcc/testsuite/gcc.target/s390/hotpatch-11.c
gcc/testsuite/gcc.target/s390/hotpatch-12.c
gcc/testsuite/gcc.target/s390/hotpatch-13.c
gcc/testsuite/gcc.target/s390/hotpatch-14.c
gcc/testsuite/gcc.target/s390/hotpatch-15.c
gcc/testsuite/gcc.target/s390/hotpatch-16.c
gcc/testsuite/gcc.target/s390/hotpatch-17.c
gcc/testsuite/gcc.target/s390/hotpatch-18.c
gcc/testsuite/gcc.target/s390/hotpatch-19.c
gcc/testsuite/gcc.target/s390/hotpatch-2.c
gcc/testsuite/gcc.target/s390/hotpatch-3.c
gcc/testsuite/gcc.target/s390/hotpatch-4.c
gcc/testsuite/gcc.target/s390/hotpatch-5.c
gcc/testsuite/gcc.target/s390/hotpatch-6.c
gcc/testsuite/gcc.target/s390/hotpatch-7.c
gcc/testsuite/gcc.target/s390/hotpatch-8.c
gcc/testsuite/gcc.target/s390/hotpatch-9.c
gcc/testsuite/gcc.target/s390/s390.exp

index 092927022334a1bb538a81a48605413497fa0217..f96b375cc4240d03224b061775e0d38484962fc4 100644 (file)
@@ -1,3 +1,12 @@
+2018-04-06  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * config/s390/s390.c (s390_z10_optimize_cmp): Expand dedicated NOP
+       instructions.
+       * config/s390/s390.md (UNSPECV_NOP_LR_0, UNSPECV_NOP_LR_1): New
+       constant definitions.
+       ("nop"): lr 0,0 -> nopr r0
+       ("nop_lr0", "nop_lr1"): New insn definitions.
+
 2018-04-06  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.md (*stack_push, *stack_pop): Use
index 51adb0df480d75e206de155f9c8a1c0d854cdb2e..59f5de9bd7e261656e46aaf247bb9608774c36c2 100644 (file)
@@ -14376,9 +14376,9 @@ s390_z10_optimize_cmp (rtx_insn *insn)
          && s390_non_addr_reg_read_p (*op0, prev_insn))
        {
          if (REGNO (*op1) == 0)
-           emit_insn_after (gen_nop1 (), insn);
+           emit_insn_after (gen_nop_lr1 (), insn);
          else
-           emit_insn_after (gen_nop (), insn);
+           emit_insn_after (gen_nop_lr0 (), insn);
          insn_added_p = true;
        }
       else
index 5481f1375efdce4e4e0d9a1277f26856038072cb..c4d391bc9b599621f879c082507ca6751d31acca 100644 (file)
    UNSPECV_CAS
    UNSPECV_ATOMIC_OP
 
+   ; Non-branch nops used for compare-and-branch adjustments on z10
+   UNSPECV_NOP_LR_0
+   UNSPECV_NOP_LR_1
+
    ; Hotpatching (unremovable NOPs)
    UNSPECV_NOP_2_BYTE
    UNSPECV_NOP_4_BYTE
 (define_insn "nop"
   [(const_int 0)]
   ""
+  "nopr\t%%r0"
+  [(set_attr "op_type" "RR")])
+
+; non-branch NOPs required for optimizing compare-and-branch patterns
+; on z10
+
+(define_insn "nop_lr0"
+  [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_0)]
+  ""
   "lr\t0,0"
   [(set_attr "op_type" "RR")
    (set_attr "z10prop"  "z10_fr_E1")])
 
-(define_insn "nop1"
-  [(const_int 1)]
+(define_insn "nop_lr1"
+  [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_1)]
   ""
   "lr\t1,1"
   [(set_attr "op_type" "RR")])
index 7e47998d3233a8d7122ad2646b3a78fbb5b5da6b..9755321e3c18662d6c1a281ea174b254a31a5722 100644 (file)
@@ -1,3 +1,28 @@
+2018-04-06  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * gcc.target/s390/s390.exp: Remove -O0 from list of torture
+       options.
+       * gcc.target/s390/hotpatch-1.c: Skip when building without
+       optimization.
+       * gcc.target/s390/hotpatch-10.c: Likewise.
+       * gcc.target/s390/hotpatch-11.c: Likewise.
+       * gcc.target/s390/hotpatch-12.c: Likewise.
+       * gcc.target/s390/hotpatch-13.c: Likewise.
+       * gcc.target/s390/hotpatch-14.c: Likewise.
+       * gcc.target/s390/hotpatch-15.c: Likewise.
+       * gcc.target/s390/hotpatch-16.c: Likewise.
+       * gcc.target/s390/hotpatch-17.c: Likewise.
+       * gcc.target/s390/hotpatch-18.c: Likewise.
+       * gcc.target/s390/hotpatch-19.c: Likewise.
+       * gcc.target/s390/hotpatch-2.c: Likewise.
+       * gcc.target/s390/hotpatch-3.c: Likewise.
+       * gcc.target/s390/hotpatch-4.c: Likewise.
+       * gcc.target/s390/hotpatch-5.c: Likewise.
+       * gcc.target/s390/hotpatch-6.c: Likewise.
+       * gcc.target/s390/hotpatch-7.c: Likewise.
+       * gcc.target/s390/hotpatch-8.c: Likewise.
+       * gcc.target/s390/hotpatch-9.c: Likewise.
+
 2018-04-06  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * c-c++-common/Wattributes.c: Disable warning for s390* target and
index 5f0f2e193495171a0b144b97c91912482fdddd33..67e101ee318c6e81e4899dbcafed74485c056cb0 100644 (file)
@@ -3,6 +3,13 @@
 /* { dg-do compile } */
 /* { dg-options "-mzarch" } */
 
+/* Without optimization extra NOPs will be added just to attach
+   location info to it.  Don't run the test in that case.  The torture
+   framework always appears to run the testcase without -O option
+   first.  */
+
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
+
 #include <stdio.h>
 
 void hp1(void)
index 2308d3331a0f3e441fe1b9950d2421d67b2953ae..21d499e6204763d834075cf7c7e3ba4cac3c1804 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,0" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 56b3596d49707e18e6da04176f7abe151c9ac139..a37f3117c64b6c0c5931f0129e41425c48102ef5 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=1,0" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 8a91c1b8b060c762547366c28c4013413383516c..cb8d1521bfa94742b429a0ce794f11fb35ac346c 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=999,0" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 70fab74d18dc6a098b588ea2ec735e41584ef9bd..fb037c2040f8354dec7fef9026f8cbef2c473d04 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 389bf42aee8d465e8be4f87f355ae4f01a7fdec9..fd0368a55ae5c8b833209183a5d7e1db7d94f45e 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 0b10fb18b4144648493da2c40af6fc05acd89418..a1c3e7c694b43efa9fef34c935fe7837fa9139d7 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 2fcdf1ce7657612a0996602d3934dad4a78ee1cd..737c3a1c0719609a28644708b7db64119a36c700 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,0" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 299f82505eefebad8cb68936ce849c3fb85e048a..6d8c40c65c03249be3276fe9ce15798a10a081ca 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=1,2" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index fd44d1183237b1ecd053bab2543bd554813679af..02807ff7b6ea1af3c7e994d96206715bc55f9d8d 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=1,2 -mhotpatch=0,0" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 899e000a71fbdc952eed1049d7c2cd5eb577b191..71c2ed13d183f2af3055270ed885f268299fa7c4 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=1,2" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 99fe9114f24731f2bbfc721e63e75ef5e1c2e737..ece6cb37e57d6e95590fba32083d0c0d8b474ecc 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,1" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 20f43c6b4586761cd2e8170d74dd9f843737e019..65ebe353688a9dcfa1f58a985c275a335663bb7e 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,2" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 32a3c032d65e77dca1c8eacad1572670cf7eb183..d0956f14240e30cf1c93a86e364d0545e4978c38 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,3" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 72ee5a30056854fc5c43f9b83a82bcc2dbcdefa0..64d49eecb135ee50f5391fff448728cdf79dd20f 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,4" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 1e1d0e6973a0f7074b0cd5185fa72e2cff087aff..e6753c8385d7355811a8025ed50dc8be0d298304 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,5" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 3f60e61e7e2eed114d0a0107531fa9cb199b0a5d..3f1c9f0e2948f71e35c2abfa1081db17b2941bb1 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-mzarch -mhotpatch=0,6" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 012a4ebd44d8eec47cb3208c7d317b95a9423baa..a2fb83f29777197dded99f6405c466f18f4b0b80 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile { target { ! lp64 } } } */
 /* { dg-options "-mesa -march=g5 -Wno-deprecated -mhotpatch=0,3" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index b7d557e43a28ed78cb75a200e8afc69fe6cc978b..34fae55d3ada7402865255db226aaf277e8139bf 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do compile { target { ! lp64 } } } */
 /* { dg-options "-mesa -march=g5 -Wno-deprecated -mhotpatch=0,4" } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */
 
 #include <stdio.h>
 
index 63e1a4c8e07562801dc1dea0894f864eeddd7907..bb13bfd33d254789b5f3e343b3030a931b4329de 100644 (file)
@@ -220,7 +220,7 @@ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/md/*.{c,S,C}]] \
 
 # Additional hotpatch torture tests.
 torture-init
-set-torture-options [list -Os -O0 -O1 -O2 -O3]
+set-torture-options [list -Os -O1 -O2 -O3]
 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/hotpatch-\[0-9\]*.c]] \
        "" $DEFAULT_CFLAGS
 torture-finish