* [PATCH] IBM Z: Fix load-and-test peephole2 condition
@ 2021-11-18 9:51 Stefan Schulze Frielinghaus
2021-11-19 9:45 ` Stefan Schulze Frielinghaus
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Schulze Frielinghaus @ 2021-11-18 9:51 UTC (permalink / raw)
To: gcc-patches, krebbel
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.
Bootstrapped and regtested on IBM Z. Ok for mainline and gcc-{11,10,9}?
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/config/s390/s390.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 4debdcd1247..c4f92bde061 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -1003,7 +1003,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])"
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] IBM Z: Fix load-and-test peephole2 condition
2021-11-18 9:51 [PATCH] IBM Z: Fix load-and-test peephole2 condition Stefan Schulze Frielinghaus
@ 2021-11-19 9:45 ` Stefan Schulze Frielinghaus
2021-11-19 11:59 ` Andreas Krebbel
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Schulze Frielinghaus @ 2021-11-19 9:45 UTC (permalink / raw)
To: gcc-patches, krebbel
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.
Update: Added a test case
Bootstrapped and regtested on IBM Z. Ok for mainline and gcc-{11,10,9}?
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 | 2 +-
gcc/testsuite/gcc.target/s390/20211119.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/s390/20211119.c
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 4debdcd1247..c4f92bde061 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -1003,7 +1003,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..1a6df4f4b89
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20211119.c
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+/* { 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;
+}
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IBM Z: Fix load-and-test peephole2 condition
2021-11-19 9:45 ` Stefan Schulze Frielinghaus
@ 2021-11-19 11:59 ` Andreas Krebbel
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Krebbel @ 2021-11-19 11:59 UTC (permalink / raw)
To: Stefan Schulze Frielinghaus, gcc-patches
On 11/19/21 10:45, Stefan Schulze Frielinghaus wrote:
...
> diff --git a/gcc/testsuite/gcc.target/s390/20211119.c b/gcc/testsuite/gcc.target/s390/20211119.c
> new file mode 100644
> index 00000000000..1a6df4f4b89
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/s390/20211119.c
> @@ -0,0 +1,12 @@
> +/* { dg-do run } */
> +/* { dg-options "-Os -march=z10" } */
Although z10 is pretty old we will need an effective target check here. Ok with that change.
Thanks!
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-19 11:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 9:51 [PATCH] IBM Z: Fix load-and-test peephole2 condition Stefan Schulze Frielinghaus
2021-11-19 9:45 ` Stefan Schulze Frielinghaus
2021-11-19 11:59 ` Andreas Krebbel
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).