public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9837] IBM Z: Fix load-and-test peephole2 condition
@ 2021-11-22  9:22 Stefan Schulze Frielinghaus
  0 siblings, 0 replies; only message in thread
From: Stefan Schulze Frielinghaus @ 2021-11-22  9:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:25cb228160dda23837db36a72ce418f79e5054a7

commit r9-9837-g25cb228160dda23837db36a72ce418f79e5054a7
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 5a3496ac92e..68392da4acd 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -973,7 +973,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;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-22  9:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  9:22 [gcc r9-9837] IBM Z: Fix load-and-test peephole2 condition Stefan Schulze Frielinghaus

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).