public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9262] IBM Z: Fix load-and-test peephole2 condition
Date: Mon, 22 Nov 2021 09:18:55 +0000 (GMT)	[thread overview]
Message-ID: <20211122091855.D70E83858415@sourceware.org> (raw)

https://gcc.gnu.org/g:f3c958196478351033ba2ab93d8341af6531f90b

commit r11-9262-gf3c958196478351033ba2ab93d8341af6531f90b
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date:   Fri Nov 19 16:56:56 2021 +0100

    IBM Z: Fix load-and-test peephole2 condition
    
    For a peephole2 condition variable insn points to the first matched
    insn.  In order to refer to the second matched insn use
    peep2_next_insn(1) instead.
    
    gcc/ChangeLog:
    
            * config/s390/s390.md (define_peephole2): Variable insn points
            to the first matched insn.  Use peep2_next_insn(1) to refer to
            the second matched insn.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/s390/20211119.c: New test.
    
    (cherry picked from commit f47870e6a272dfe740a38422030c6c68e0fc7ff8)

Diff:
---
 gcc/config/s390/s390.md                  |  2 +-
 gcc/testsuite/gcc.target/s390/20211119.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 21f902b143c..97a306768a5 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -1006,7 +1006,7 @@
 	(match_operand:GPR 2 "memory_operand"))
    (set (reg CC_REGNUM)
 	(compare (match_dup 0) (match_operand:GPR 1 "const0_operand")))]
-  "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM
+  "s390_match_ccmode (peep2_next_insn (1), CCSmode) && TARGET_EXTIMM
    && GENERAL_REG_P (operands[0])
    && satisfies_constraint_T (operands[2])
    && !contains_constant_pool_address_p (operands[2])"
diff --git a/gcc/testsuite/gcc.target/s390/20211119.c b/gcc/testsuite/gcc.target/s390/20211119.c
new file mode 100644
index 00000000000..b9d216389f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20211119.c
@@ -0,0 +1,12 @@
+/* { dg-do run { target { s390_useable_hw } } } */
+/* { dg-options "-Os -march=z10" } */
+signed char a;
+int b = -925974181, c;
+unsigned *d = &b;
+int *e = &c;
+int main() {
+  *e = ((217 ^ a) > 585) < *d;
+  if (c != 1)
+    __builtin_abort();
+  return 0;
+}


                 reply	other threads:[~2021-11-22  9:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211122091855.D70E83858415@sourceware.org \
    --to=stefansf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).