]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
IBM Z: Fix load-and-test peephole2 condition
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Fri, 19 Nov 2021 15:56:56 +0000 (16:56 +0100)
committerStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Fri, 19 Nov 2021 15:56:56 +0000 (16:56 +0100)
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.

gcc/config/s390/s390.md
gcc/testsuite/gcc.target/s390/20211119.c [new file with mode: 0644]

index 4debdcd12478d270005048911acb875d829a5758..c4f92bde06136bb4ab4d5db2a9c60364854dc02f 100644 (file)
        (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 (file)
index 0000000..b9d2163
--- /dev/null
@@ -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;
+}