Skip to content

Commit 5a144e5

Browse files
Claudiu Zissulescuartemiy-volkov
authored andcommitted
arc64: Update predicate commutative ops, add zero-ext predicate ops.
Improve if-conversion by extending the commutative ops pattern, and add zero-extend predicate patterns using bmsk instruction. Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
1 parent 60c08cc commit 5a144e5

File tree

2 files changed

+52
-51
lines changed

2 files changed

+52
-51
lines changed

gcc/config/arc64/arc64.md

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
;; Same as above but to be used by mov conditional
159159
(define_mode_attr mcctab [(QI "") (HI "") (SI "") (DI "l")])
160160

161+
;; Give the number of bits-1 in the mode
162+
(define_mode_attr sizen [(QI "7") (HI "15") (SI "31") (DI "63")])
163+
161164
;; -------------------------------------------------------------------
162165
;; Code Attributes
163166
;; -------------------------------------------------------------------
@@ -937,10 +940,10 @@ umod, umodl, unknown, xbfu, xor, xorl"
937940
;; ""
938941
;; )
939942

940-
(define_insn "*arc64_zero_extend_<mode>_to_si"
941-
[(set (match_operand:SI 0 "register_operand" "=q,r,q,r")
942-
(zero_extend:SI
943-
(match_operand:SHORT 1 "nonimmediate_operand" "q,r,Uldms,m")))]
943+
(define_insn "*zero_extend<mode>si2"
944+
[(set (match_operand:SI 0 "register_operand" "=q,r, q,r")
945+
(zero_extend:SI
946+
(match_operand:SHORT 1 "nonimmediate_operand" "q,r,Uldms,m")))]
944947
""
945948
"@
946949
ext<exttab>_s\\t%0,%1
@@ -950,60 +953,41 @@ umod, umodl, unknown, xbfu, xor, xorl"
950953
[(set_attr "type" "sex,sex,ld,ld")
951954
(set_attr "length" "2,4,2,*")])
952955

953-
(define_insn "*arc64_zero_extend_si_to_di"
954-
[(set (match_operand:DI 0 "register_operand" "=r,q,r")
955-
(zero_extend:DI
956-
(match_operand:SI 1 "nonimmediate_operand" "r,Uldms,m")))
957-
]
956+
(define_insn "*zero_extend<mode>di2"
957+
[(set (match_operand:DI 0 "register_operand" "=r, q,r")
958+
(zero_extend:DI
959+
(match_operand:EXT 1 "nonimmediate_operand" "r,Uldms,m")))]
958960
""
959961
"@
960-
bmskl\\t%0,%1,31
961-
ld_s\\t%0,%1
962-
ld%U1\\t%0,%1"
963-
[(set_attr "type" "and,ld,ld")
964-
(set_attr "length" "4,2,*")]
965-
)
966-
967-
(define_insn "*arc64_zero_extend_qi_to_di"
968-
[(set (match_operand:DI 0 "register_operand" "=r, q,r")
969-
(zero_extend:DI
970-
(match_operand:QI 1 "nonimmediate_operand" "r,Uldms,m")))
971-
]
972-
""
973-
"@
974-
bmskl\\t%0,%1,7
975-
ldb_s\\t%0,%1
976-
ldb%U1\\t%0,%1"
962+
bmskl\\t%0,%1,<sizen>
963+
ld<sfxtab>_s\\t%0,%1
964+
ld<sfxtab>%U1\\t%0,%1"
977965
[(set_attr "type" "and,ld,ld")
978966
(set_attr "length" "4,2,*")]
979967
)
980968

981-
(define_insn "*arc64_zero_extend_hi_to_di"
982-
[(set (match_operand:DI 0 "register_operand" "=r,q,r")
983-
(zero_extend:DI
984-
(match_operand:HI 1 "nonimmediate_operand" "r,Uldms,m")))
985-
]
986-
""
987-
"@
988-
bmskl\\t%0,%1,15
989-
ldh_s\\t%0,%1
990-
ldh%U1\\t%0,%1"
991-
[(set_attr "type" "and,ld,ld")
992-
(set_attr "length" "4,2,*")]
993-
)
969+
;; conditional execution for the above two patterns
970+
(define_insn "*zero_extend<SHORT:mode><GPI:mode>2_ce"
971+
[(cond_exec
972+
(match_operator 2 "ordered_comparison_operator"
973+
[(match_operand 3 "cc_register" "") (const_int 0)])
974+
(set (match_operand:GPI 0"register_operand" "=r")
975+
(zero_extend:GPI (match_operand:SHORT 1 "register_operand" "0"))))]
976+
""
977+
"bmsk<GPI:mcctab>.%m2\\t%0,%1,<SHORT:sizen>"
978+
[(set_attr "type" "and")
979+
(set_attr "length" "4")])
994980

995-
(define_insn "*arc64_sign_extend_<mode>_to_di"
981+
(define_insn "*sign_extend<mode>di2"
996982
[(set (match_operand:DI 0 "register_operand" "=r,r")
997983
(sign_extend:DI
998-
(match_operand:EXT 1 "nonimmediate_operand" "r,m")))
999-
]
984+
(match_operand:EXT 1 "nonimmediate_operand" "r,m")))]
1000985
""
1001986
"@
1002987
sex<exttab>l\\t%0,%1
1003988
ld<sfxtab>.x%U1\\t%0,%1"
1004-
[(set_attr "type" "sex,ld")
1005-
(set_attr "length" "4,*")]
1006-
)
989+
[(set_attr "type" "sex,ld")
990+
(set_attr "length" "4,*")])
1007991

1008992
(define_insn "*sign_extend<mode>si2"
1009993
[(set (match_operand:SI 0 "register_operand" "=q,r,r")

gcc/config/arc64/arith.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
(define_code_iterator COMMUTATIVEF [plus and ior xor])
2323

24-
;; Operations which can be predicated
25-
(define_code_iterator ARITHP [and ior xor plus minus ashift ashiftrt lshiftrt])
24+
;; Operations which can be predicated non commutative
25+
(define_code_iterator ARITHP [minus ashift ashiftrt lshiftrt])
2626

2727
(define_code_iterator BIT [ior xor])
2828

@@ -114,7 +114,6 @@
114114
sub%s2<sfxtab>%?\\t%0,%1,%N2
115115
add<sfxtab>%?\\t%0,%1,%2"
116116
[(set_attr "iscompact" "yes,maybe,maybe,maybe,no,no,no,no,no,no")
117-
(set_attr "predicable" "no,no,no,no,yes,yes,no,no,no,no")
118117
(set_attr "length" "2,*,*,*,4,4,4,4,4,8")
119118
(set_attr "type" "add")]
120119
)
@@ -124,15 +123,33 @@
124123
[(cond_exec
125124
(match_operator 3 "ordered_comparison_operator"
126125
[(match_operand 4 "cc_register" "") (const_int 0)])
127-
(set (match_operand:GPI 0 "register_operand" "= r,r")
128-
(ARITHP:GPI (match_operand:GPI 1 "register_operand" " 0,0")
129-
(match_operand:GPI 2 "nonmemory_operand" "rU06S0,S32S0"))))]
126+
(set (match_operand:GPI 0 "register_operand" "= r,r")
127+
(ARITHP:GPI (match_operand:GPI 1 "register_operand" " 0,0")
128+
(match_operand:GPI 2 "nonmemory_operand" "rU06S0,S32S0"))))]
130129
""
131130
"<arc64_code_map><sfxtab>.%m3\\t%0,%1,%2"
132131
[(set_attr "iscompact" "no")
133132
(set_attr "length" "4,8")
134133
(set_attr "type" "<arc64_code_map>")])
135134

135+
(define_insn "*<optab><mode>_ce"
136+
[(cond_exec
137+
(match_operator 3 "ordered_comparison_operator"
138+
[(match_operand 4 "cc_register" "") (const_int 0)])
139+
(set (match_operand:GPI 0 "register_operand" "= r, r,r")
140+
(COMMUTATIVEF:GPI
141+
(match_operand:GPI 1 "nonmemory_operand" " 0,S32S0,0")
142+
(match_operand:GPI 2 "nonmemory_operand" "rU06S0, 0,S32S0"))))]
143+
"register_operand (operands[1], <MODE>mode)
144+
|| register_operand (operands[2], <MODE>mode)"
145+
"@
146+
<arc64_code_map><sfxtab>.%m3\\t%0,%1,%2
147+
<arc64_code_map><sfxtab>.%m3\\t%0,%2,%1
148+
<arc64_code_map><sfxtab>.%m3\\t%0,%1,%2"
149+
[(set_attr "iscompact" "no")
150+
(set_attr "length" "4,8,8")
151+
(set_attr "type" "<arc64_code_map>")])
152+
136153
;; Arithmetic patterns used by the combiner.
137154
(define_insn "*bic<mode>3"
138155
[(set ( match_operand:GPI 0 "register_operand" "=q,r,r, r")

0 commit comments

Comments
 (0)