From: "Kewen.Lin" <linkw@linux.ibm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
David Edelsohn <dje.gcc@gmail.com>,
Peter Bergner <bergner@linux.ibm.com>
Subject: [PATCH 2/2] rs6000: Refactor genfusion.pl a bit further
Date: Wed, 18 Jan 2023 17:02:47 +0800 [thread overview]
Message-ID: <130a6f1b-9089-8cdc-8e0c-0870139df7c7@linux.ibm.com> (raw)
In-Reply-To: <55027326-ffe1-87e8-9e4b-08535425afdd@linux.ibm.com>
Hi,
To keep the previous refactoring patch not need to
re-generate fusion.md and make the review easier,
I didn't merge this patch into the previous one.
But I think this one can help to make the subroutine
gen_logical_addsubf_scalar more clear, by separating
logical-logical and add-logical handlings into two
different loops. It needs to regenerate fusion.md,
since add-logical type definitions would have their
own continuous area (it needs some rearrangments).
Bootstrapped and regtested on powerpc64le-linux-gnu P10.
Any comments are highly appreciated.
BR,
Kewen
-----
gcc/ChangeLog:
* config/rs6000/fusion.md : Regenerate.
* config/rs6000/genfusion.pl (gen_logical_addsubf_scalar): Split
logical-logical and add-logical handlings into two loops.
---
gcc/config/rs6000/fusion.md | 288 ++++++++++++++++-----------------
gcc/config/rs6000/genfusion.pl | 28 ++--
2 files changed, 162 insertions(+), 154 deletions(-)
diff --git a/gcc/config/rs6000/fusion.md b/gcc/config/rs6000/fusion.md
index d45fb138a70..0427505b7f7 100644
--- a/gcc/config/rs6000/fusion.md
+++ b/gcc/config/rs6000/fusion.md
@@ -499,42 +499,6 @@ (define_insn "*fuse_xor_and"
(set_attr "cost" "6")
(set_attr "length" "8")])
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar add -> and
-(define_insn "*fuse_add_and"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (and:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
- (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- add %3,%1,%0\;and %3,%3,%2
- add %3,%1,%0\;and %3,%3,%2
- add %3,%1,%0\;and %3,%3,%2
- add %4,%1,%0\;and %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar subf -> and
-(define_insn "*fuse_subf_and"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (and:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
- (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- subf %3,%1,%0\;and %3,%3,%2
- subf %3,%1,%0\;and %3,%3,%2
- subf %3,%1,%0\;and %3,%3,%2
- subf %4,%1,%0\;and %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
;; logical-logical fusion pattern generated by gen_logical_addsubf
;; scalar and -> andc
(define_insn "*fuse_and_andc"
@@ -967,42 +931,6 @@ (define_insn "*fuse_xor_nand"
(set_attr "cost" "6")
(set_attr "length" "8")])
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar add -> nand
-(define_insn "*fuse_add_nand"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (ior:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
- (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- add %3,%1,%0\;nand %3,%3,%2
- add %3,%1,%0\;nand %3,%3,%2
- add %3,%1,%0\;nand %3,%3,%2
- add %4,%1,%0\;nand %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar subf -> nand
-(define_insn "*fuse_subf_nand"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (ior:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
- (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- subf %3,%1,%0\;nand %3,%3,%2
- subf %3,%1,%0\;nand %3,%3,%2
- subf %3,%1,%0\;nand %3,%3,%2
- subf %4,%1,%0\;nand %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
;; logical-logical fusion pattern generated by gen_logical_addsubf
;; scalar and -> nor
(define_insn "*fuse_and_nor"
@@ -1147,42 +1075,6 @@ (define_insn "*fuse_xor_nor"
(set_attr "cost" "6")
(set_attr "length" "8")])
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar add -> nor
-(define_insn "*fuse_add_nor"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (and:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
- (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- add %3,%1,%0\;nor %3,%3,%2
- add %3,%1,%0\;nor %3,%3,%2
- add %3,%1,%0\;nor %3,%3,%2
- add %4,%1,%0\;nor %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar subf -> nor
-(define_insn "*fuse_subf_nor"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (and:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
- (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- subf %3,%1,%0\;nor %3,%3,%2
- subf %3,%1,%0\;nor %3,%3,%2
- subf %3,%1,%0\;nor %3,%3,%2
- subf %4,%1,%0\;nor %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
;; logical-logical fusion pattern generated by gen_logical_addsubf
;; scalar and -> or
(define_insn "*fuse_and_or"
@@ -1327,42 +1219,6 @@ (define_insn "*fuse_xor_or"
(set_attr "cost" "6")
(set_attr "length" "8")])
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar add -> or
-(define_insn "*fuse_add_or"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (ior:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
- (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- add %3,%1,%0\;or %3,%3,%2
- add %3,%1,%0\;or %3,%3,%2
- add %3,%1,%0\;or %3,%3,%2
- add %4,%1,%0\;or %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
-;; add-logical fusion pattern generated by gen_logical_addsubf
-;; scalar subf -> or
-(define_insn "*fuse_subf_or"
- [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
- (ior:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
- (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
- (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
- (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
- "(TARGET_P10_FUSION)"
- "@
- subf %3,%1,%0\;or %3,%3,%2
- subf %3,%1,%0\;or %3,%3,%2
- subf %3,%1,%0\;or %3,%3,%2
- subf %4,%1,%0\;or %3,%4,%2"
- [(set_attr "type" "fused_arith_logical")
- (set_attr "cost" "6")
- (set_attr "length" "8")])
-
;; logical-logical fusion pattern generated by gen_logical_addsubf
;; scalar and -> orc
(define_insn "*fuse_and_orc"
@@ -1651,6 +1507,150 @@ (define_insn "*fuse_xor_xor"
(set_attr "cost" "6")
(set_attr "length" "8")])
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar add -> and
+(define_insn "*fuse_add_and"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (and:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
+ (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ add %3,%1,%0\;and %3,%3,%2
+ add %3,%1,%0\;and %3,%3,%2
+ add %3,%1,%0\;and %3,%3,%2
+ add %4,%1,%0\;and %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar subf -> and
+(define_insn "*fuse_subf_and"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (and:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
+ (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ subf %3,%1,%0\;and %3,%3,%2
+ subf %3,%1,%0\;and %3,%3,%2
+ subf %3,%1,%0\;and %3,%3,%2
+ subf %4,%1,%0\;and %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar add -> nand
+(define_insn "*fuse_add_nand"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (ior:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
+ (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ add %3,%1,%0\;nand %3,%3,%2
+ add %3,%1,%0\;nand %3,%3,%2
+ add %3,%1,%0\;nand %3,%3,%2
+ add %4,%1,%0\;nand %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar subf -> nand
+(define_insn "*fuse_subf_nand"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (ior:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
+ (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ subf %3,%1,%0\;nand %3,%3,%2
+ subf %3,%1,%0\;nand %3,%3,%2
+ subf %3,%1,%0\;nand %3,%3,%2
+ subf %4,%1,%0\;nand %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar add -> nor
+(define_insn "*fuse_add_nor"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (and:GPR (not:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
+ (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ add %3,%1,%0\;nor %3,%3,%2
+ add %3,%1,%0\;nor %3,%3,%2
+ add %3,%1,%0\;nor %3,%3,%2
+ add %4,%1,%0\;nor %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar subf -> nor
+(define_insn "*fuse_subf_nor"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (and:GPR (not:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r")))
+ (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r"))))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ subf %3,%1,%0\;nor %3,%3,%2
+ subf %3,%1,%0\;nor %3,%3,%2
+ subf %3,%1,%0\;nor %3,%3,%2
+ subf %4,%1,%0\;nor %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar add -> or
+(define_insn "*fuse_add_or"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (ior:GPR (plus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
+ (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ add %3,%1,%0\;or %3,%3,%2
+ add %3,%1,%0\;or %3,%3,%2
+ add %3,%1,%0\;or %3,%3,%2
+ add %4,%1,%0\;or %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
+;; add-logical fusion pattern generated by gen_logical_addsubf
+;; scalar subf -> or
+(define_insn "*fuse_subf_or"
+ [(set (match_operand:GPR 3 "gpc_reg_operand" "=&0,&1,&r,r")
+ (ior:GPR (minus:GPR (match_operand:GPR 0 "gpc_reg_operand" "r,r,r,r")
+ (match_operand:GPR 1 "gpc_reg_operand" "r,r,r,r"))
+ (match_operand:GPR 2 "gpc_reg_operand" "r,r,r,r")))
+ (clobber (match_scratch:GPR 4 "=X,X,X,&r"))]
+ "(TARGET_P10_FUSION)"
+ "@
+ subf %3,%1,%0\;or %3,%3,%2
+ subf %3,%1,%0\;or %3,%3,%2
+ subf %3,%1,%0\;or %3,%3,%2
+ subf %4,%1,%0\;or %3,%4,%2"
+ [(set_attr "type" "fused_arith_logical")
+ (set_attr "cost" "6")
+ (set_attr "length" "8")])
+
;; logical-add fusion pattern generated by gen_logical_addsubf
;; scalar and -> add
(define_insn "*fuse_and_add"
diff --git a/gcc/config/rs6000/genfusion.pl b/gcc/config/rs6000/genfusion.pl
index 487e662ce05..6002a3af578 100755
--- a/gcc/config/rs6000/genfusion.pl
+++ b/gcc/config/rs6000/genfusion.pl
@@ -335,22 +335,30 @@ sub gen_logical_addsubf_scalar
my $constraint = 'r';
my @logicals = ( 'and', 'andc', 'eqv', 'nand', 'nor', 'or', 'orc', 'xor' );
+
+ # logical-logical
+ foreach my $outer_op ( @logicals ) {
+ foreach my $inner_op ( @logicals ) {
+ my $exp = logical_addsubf_make_exp ($outer_op, $inner_op, $mode,
+ $pred, $constraint);
+ logical_addsubf_emit_define ('logical-logical', 'scalar', $outer_op,
+ $inner_op, $mode, $pred, $constraint,
+ $exp, $fuse_type);
+ }
+ }
+
# logical ops which can fuse with add/subf/rsubf
my @logicals2 = ( 'and', 'nand', 'nor', 'or' );
my @add_subf = ( 'add', 'subf' );
- # {logical, add}-logical
- foreach my $outer_op ( @logicals ) {
- foreach my $inner_op ( @logicals, @add_subf ) {
- my $ftype = 'logical-logical';
- if (grep (/^$inner_op$/, @add_subf)) {
- next unless grep (/^$outer_op$/, @logicals2);
- $ftype = 'add-logical';
- }
+ # add-logical
+ foreach my $outer_op ( @logicals2 ) {
+ foreach my $inner_op ( @add_subf ) {
my $exp = logical_addsubf_make_exp ($outer_op, $inner_op, $mode,
$pred, $constraint);
- logical_addsubf_emit_define ($ftype, 'scalar', $outer_op, $inner_op,
- $mode, $pred, $constraint, $exp, $fuse_type);
+ logical_addsubf_emit_define ('add-logical', 'scalar', $outer_op,
+ $inner_op, $mode, $pred, $constraint,
+ $exp, $fuse_type);
}
}
--
2.37.0
prev parent reply other threads:[~2023-01-18 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 8:50 [PATCH 1/2] rs6000: Refactor script genfusion.pl Kewen.Lin
2023-01-18 9:02 ` Kewen.Lin [this message]
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=130a6f1b-9089-8cdc-8e0c-0870139df7c7@linux.ibm.com \
--to=linkw@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.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).