Hi,

r231152 added a splitter which might invoke gen_reg_rtx after reload.
Fixed with the attached patch.

Bootstrapped and regtested on s390 and s390x.
Committed to mainline.

Bye,

-Andreas-

gcc/ChangeLog:

2016-01-13  Andreas Krebbel  <kreb...@linux.vnet.ibm.com>

        PR target/69247
        * config/s390/s390.md (bswaphi splitter): Use simplify_gen_subreg.

gcc/testsuite/ChangeLog:

2016-01-13  Jakub Jelinek  <ja...@redhat.com>

        PR target/69247
        * gcc.dg/pr69247.c: New test.


diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index d6097c1..3e340c3 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -10522,11 +10522,9 @@
   (bswap:HI (match_operand:HI 1 "register_operand" "")))]
   "TARGET_CPU_ZARCH"
   [(set (match_dup 2) (bswap:SI (match_dup 3)))
-   (set (match_dup 2) (lshiftrt:SI (match_dup 2)
-                         (const_int 16)))
-   (set (match_dup 0) (subreg:HI (match_dup 2) 2))]
+   (set (match_dup 2) (lshiftrt:SI (match_dup 2) (const_int 16)))]
 {
-  operands[2] = gen_reg_rtx (SImode);
+  operands[2] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
   operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
 })
 
diff --git a/gcc/testsuite/gcc.dg/pr69247.c b/gcc/testsuite/gcc.dg/pr69247.c
new file mode 100644
index 0000000..b7406e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr69247.c
@@ -0,0 +1,14 @@
+/* PR target/69247 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-march=zEC12" { target s390*-*-* } } */
+
+void foo (short *);
+
+void
+bar (short x, int y)
+{
+  if (y)
+    x = x << 8 | (unsigned short) x >> 8;
+  foo (&x);
+}

Reply via email to