* [PATCH] IBM Z: Remove match_scratch workaround
@ 2021-06-02 2:21 Ilya Leoshkevich
2021-06-02 5:18 ` Jeff Law
2021-06-02 6:56 ` Andreas Krebbel
0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2021-06-02 2:21 UTC (permalink / raw)
To: Andreas Krebbel; +Cc: gcc-patches, Joern Rennecke, Ilya Leoshkevich
Bootstrapped and regtested on s390x-redhat-linux. Ok for master?
Since commit dd1ef00c45ba ("Fix bug in the define_subst handling that
made match_scratch unusable for multi-alternative patterns.") the
workaround for that bug in *ashrdi3_31<setcc><cconly> is not only no
longer necessary, but actually breaks the build.
Get rid of it by using only one alternative in (match_scratch). It
will be replicated as many times as needed in order to match the
pattern with which (define_subst) is used.
gcc/ChangeLog:
* config/s390/s390.md(*ashrdi3_31<setcc><cconly>): Use a single
constraint.
* config/s390/subst.md(cconly_subst): Use a single constraint
in (match_scratch).
gcc/testsuite/ChangeLog:
* gcc.target/s390/ashr.c: New test.
---
gcc/config/s390/s390.md | 14 ++++----------
gcc/config/s390/subst.md | 2 +-
gcc/testsuite/gcc.target/s390/ashr.c | 11 +++++++++++
3 files changed, 16 insertions(+), 11 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/s390/ashr.c
diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 7faf775fbf2..0c5b4dc9029 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -9328,19 +9328,13 @@
""
"")
-; FIXME: The number of alternatives is doubled here to match the fix
-; number of 2 in the subst pattern for the (clobber (match_scratch...
-; The right fix should be to support match_scratch in the output
-; pattern of a define_subst.
(define_insn "*ashrdi3_31<setcc><cconly>"
- [(set (match_operand:DI 0 "register_operand" "=d, d")
- (ashiftrt:DI (match_operand:DI 1 "register_operand" "0, 0")
- (match_operand:QI 2 "shift_count_operand" "jsc,jsc")))
+ [(set (match_operand:DI 0 "register_operand" "=d")
+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
+ (match_operand:QI 2 "shift_count_operand" "jsc")))
(clobber (reg:CC CC_REGNUM))]
"!TARGET_ZARCH"
- "@
- srda\t%0,%Y2
- srda\t%0,%Y2"
+ "srda\t%0,%Y2"
[(set_attr "op_type" "RS")
(set_attr "atype" "reg")])
diff --git a/gcc/config/s390/subst.md b/gcc/config/s390/subst.md
index 384af11c198..3ea6fc40ba8 100644
--- a/gcc/config/s390/subst.md
+++ b/gcc/config/s390/subst.md
@@ -45,7 +45,7 @@
"s390_match_ccmode(insn, CCSmode)"
[(set (reg CC_REGNUM)
(compare (match_dup 1) (const_int 0)))
- (clobber (match_scratch:DSI 0 "=d,d"))])
+ (clobber (match_scratch:DSI 0 "=d"))])
(define_subst_attr "cconly" "cconly_subst" "" "_cconly")
diff --git a/gcc/testsuite/gcc.target/s390/ashr.c b/gcc/testsuite/gcc.target/s390/ashr.c
new file mode 100644
index 00000000000..8cffdfa9a1d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/ashr.c
@@ -0,0 +1,11 @@
+/* Test the arithmetic shift right pattern. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int e(void);
+
+int f (long c, int b)
+{
+ return (c >> b) && e ();
+}
--
2.31.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IBM Z: Remove match_scratch workaround
2021-06-02 2:21 [PATCH] IBM Z: Remove match_scratch workaround Ilya Leoshkevich
@ 2021-06-02 5:18 ` Jeff Law
2021-06-02 6:56 ` Andreas Krebbel
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2021-06-02 5:18 UTC (permalink / raw)
To: Ilya Leoshkevich, Andreas Krebbel; +Cc: Joern Rennecke, gcc-patches
On 6/1/2021 8:21 PM, Ilya Leoshkevich via Gcc-patches wrote:
> Bootstrapped and regtested on s390x-redhat-linux. Ok for master?
>
>
>
> Since commit dd1ef00c45ba ("Fix bug in the define_subst handling that
> made match_scratch unusable for multi-alternative patterns.") the
> workaround for that bug in *ashrdi3_31<setcc><cconly> is not only no
> longer necessary, but actually breaks the build.
>
> Get rid of it by using only one alternative in (match_scratch). It
> will be replicated as many times as needed in order to match the
> pattern with which (define_subst) is used.
>
> gcc/ChangeLog:
>
> * config/s390/s390.md(*ashrdi3_31<setcc><cconly>): Use a single
> constraint.
> * config/s390/subst.md(cconly_subst): Use a single constraint
> in (match_scratch).
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/s390/ashr.c: New test.
Presumably this fixes:
../../../gcc/gcc/config/s390/s390.md:9335:1: alternative number mismatch: operand 0 has 4, operand 1 has 2
../../../gcc/gcc/config/s390/s390.md:9335:1: alternative number mismatch: operand 0 has 4, operand 2 has 2
../../../gcc/gcc/config/s390/s390.md:9335:1: wrong number of alternatives in the output template
../../../gcc/gcc/config/s390/s390.md:9349:1: alternative number mismatch: operand 0 has 4, operand 1 has 2
../../../gcc/gcc/config/s390/s390.md:9349:1: alternative number mismatch: operand 0 has 4, operand 2 has 2
../../../gcc/gcc/config/s390/s390.md:9349:1: wrong number of alternatives in the output template
../../../gcc/gcc/config/s390/s390.md:9349:1: alternative number mismatch: operand 0 has 4, operand 1 has 2
../../../gcc/gcc/config/s390/s390.md:9349:1: alternative number mismatch: operand 0 has 4, operand 2 has 2
../../../gcc/gcc/config/s390/s390.md:9349:1: wrong number of alternatives in the output template
The tester has been tripping over that for about a week.
I'll let the s390 maintainers chime in on the correctness of the change.
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IBM Z: Remove match_scratch workaround
2021-06-02 2:21 [PATCH] IBM Z: Remove match_scratch workaround Ilya Leoshkevich
2021-06-02 5:18 ` Jeff Law
@ 2021-06-02 6:56 ` Andreas Krebbel
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Krebbel @ 2021-06-02 6:56 UTC (permalink / raw)
To: Ilya Leoshkevich, Andreas Krebbel; +Cc: gcc-patches, Joern Rennecke
On 6/2/21 4:21 AM, Ilya Leoshkevich wrote:
> Bootstrapped and regtested on s390x-redhat-linux. Ok for master?
>
>
>
> Since commit dd1ef00c45ba ("Fix bug in the define_subst handling that
> made match_scratch unusable for multi-alternative patterns.") the
> workaround for that bug in *ashrdi3_31<setcc><cconly> is not only no
> longer necessary, but actually breaks the build.
>
> Get rid of it by using only one alternative in (match_scratch). It
> will be replicated as many times as needed in order to match the
> pattern with which (define_subst) is used.
>
> gcc/ChangeLog:
>
> * config/s390/s390.md(*ashrdi3_31<setcc><cconly>): Use a single
> constraint.
> * config/s390/subst.md(cconly_subst): Use a single constraint
> in (match_scratch).
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/s390/ashr.c: New test.
Ok. Thanks!
Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-02 6:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 2:21 [PATCH] IBM Z: Remove match_scratch workaround Ilya Leoshkevich
2021-06-02 5:18 ` Jeff Law
2021-06-02 6:56 ` 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).