Skip to content

Commit d13eceb

Browse files
Claudiu Zissulescuartemiy-volkov
authored andcommitted
arc64: Improve matching .f instructions
1 parent 7f15615 commit d13eceb

File tree

2 files changed

+114
-13
lines changed

2 files changed

+114
-13
lines changed

gcc/config/arc64/arc64.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,24 +1527,46 @@ vfins, vfsub, vfmul, vfdiv, vfrep, vpack, xbfu, xor, xorl"
15271527
(set_attr "predicable" "no,no,yes,yes,no,yes,no,no,no")
15281528
(set_attr "length" "*,*,4,4,4,4,4,8,8")])
15291529

1530-
(define_insn "*cmpsi_zn"
1530+
1531+
(define_insn "*cmp<mode>_ce"
1532+
[(cond_exec
1533+
(match_operator 2 "arc64_comparison_operator"
1534+
[(match_operand 3 "cc_register" "") (const_int 0)])
1535+
(set (reg:CC CC_REGNUM)
1536+
(compare:CC
1537+
(match_operand:GPI 0 "nonmemory_operand" "r, r,U06S0,S32S0,r")
1538+
(match_operand:GPI 1 "nonmemory_operand" "r,U06S0, r, r,S32S0"))))]
1539+
"register_operand (operands[0], <MODE>mode)
1540+
|| register_operand (operands[1], <MODE>mode)"
1541+
"@
1542+
cmp<sfxtab>.%m2\\t%0,%1
1543+
cmp<sfxtab>.%m2\\t%0,%1
1544+
rcmp<sfxtab>.%m2\\t%1,%0
1545+
rcmp<sfxtab>.%m2\\t%1,%0
1546+
cmp<sfxtab>.%m2\\t%0,%1"
1547+
[(set_attr "type" "cmp")
1548+
(set_attr "length" "4,4,4,8,8")])
1549+
1550+
(define_insn "*cmp<mode>_zn"
15311551
[(set (reg:CC_ZN CC_REGNUM)
1532-
(compare:CC_ZN (match_operand:SI 0 "register_operand" "q,r")
1552+
(compare:CC_ZN (match_operand:GPI 0 "register_operand" "q,r")
15331553
(const_int 0)))]
15341554
""
1535-
"tst%?\\t%0,%0"
1555+
"tst<mcctab>%?\\t%0,%0"
15361556
[(set_attr "type" "tst")
1537-
(set_attr "iscompact" "yes,no")
1538-
(set_attr "length" "2,4")])
1557+
(set_attr "iscompact" "maybe,no")
1558+
(set_attr "length" "*,4")])
15391559

1540-
(define_insn "*cmpdi_zn"
1541-
[(set (reg:CC_ZN CC_REGNUM)
1542-
(compare:CC_ZN (match_operand:DI 0 "register_operand" "r")
1543-
(const_int 0)))]
1560+
(define_insn "*cmp<mode>_znce"
1561+
[(cond_exec
1562+
(match_operator 2 "arc64_comparison_operator"
1563+
[(match_operand 1 "cc_register" "") (const_int 0)])
1564+
(set (reg:CC_ZN CC_REGNUM)
1565+
(compare:CC_ZN (match_operand:GPI 0 "register_operand" "r")
1566+
(const_int 0))))]
15441567
""
1545-
"tstl\\t%0,%0"
1568+
"tst<mcctab>.%m2\\t%0,%0"
15461569
[(set_attr "type" "tst")
1547-
(set_attr "iscompact" "no")
15481570
(set_attr "length" "4")])
15491571

15501572
(define_insn "fcmp<mode>"

gcc/config/arc64/arith.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,36 @@
7878
[(set_attr "iscompact" "maybe,no,no,no,no,no")
7979
(set_attr "predicable" "no,yes,no,no,no,no")
8080
(set_attr "length" "*,4,4,4,8,8")
81-
(set_attr "type" "<mntab>")]
82-
)
81+
(set_attr "type" "<mntab>")])
82+
83+
(define_insn "*<optab><mode>_cmp0"
84+
[(set (reg:CC_ZN CC_REGNUM)
85+
(compare:CC_ZN
86+
(ASHIFT:GPI
87+
(match_operand:GPI 1 "register_operand" " 0,0")
88+
(match_operand:GPI 2 "nonmemory_operand" "rU06S0,S32S0"))
89+
(const_int 0)))
90+
(set (match_operand:GPI 0 "register_operand" "= r,r")
91+
(ASHIFT:GPI (match_dup 1) (match_dup 2)))]
92+
""
93+
"<mntab><sfxtab>.f\\t%0,%1,%2"
94+
[(set_attr "iscompact" "no")
95+
(set_attr "length" "4,8")
96+
(set_attr "type" "<mntab>")])
97+
98+
(define_insn "*<optab><mode>_cmp0_noout"
99+
[(set (reg:CC_ZN CC_REGNUM)
100+
(compare:CC_ZN
101+
(ASHIFT:GPI
102+
(match_operand:GPI 0 "register_operand" " r,r")
103+
(match_operand:GPI 1 "nonmemory_operand" "rU06S0,S32S0"))
104+
(const_int 0)))]
105+
""
106+
"<mntab><sfxtab>.f\\t0,%0,%1"
107+
[(set_attr "iscompact" "no")
108+
(set_attr "length" "4,8")
109+
(set_attr "type" "<mntab>")])
110+
83111

84112
(define_insn "*sub<mode>_insn"
85113
[(set ( match_operand:GPI 0 "register_operand" "=q, q, q, r, r, r, r, r, r, r,r")
@@ -164,6 +192,24 @@
164192
(set_attr "length" "2,*,*,*,4,4,4,4,4,8")
165193
(set_attr "type" "add")])
166194

195+
;; This pattern is needed because the GT (pnz) is not reversible and I
196+
;; cannot convert CCmode to CC_ZNmode.
197+
(define_insn "*<ADDSUB:optab><GPI:mode>3_f"
198+
[(set (reg:CC CC_REGNUM)
199+
(compare:CC
200+
(ADDSUB:GPI
201+
(match_operand:GPI 1 "arc64_nonmem_operand" "0, 0, 0, r,r,S32S0, r")
202+
(match_operand:GPI 2 "arc64_nonmem_operand" "r,U06S0,S12S0,U06S0,r, r,S32S0"))
203+
(const_int 0)))
204+
(set (match_operand:GPI 0 "register_operand" "=r, r, r, r,r, r, r")
205+
(ADDSUB:GPI (match_dup 1) (match_dup 2)))]
206+
"register_operand (operands[1], <MODE>mode)
207+
|| register_operand (operands[2], <MODE>mode)"
208+
"<ADDSUB:optab><GPI:sfxtab>.f\\t%0,%1,%2"
209+
[(set_attr "predicable" "yes,yes,no,no,no,no,no")
210+
(set_attr "length" "4,4,4,4,4,8,8")
211+
(set_attr "type" "<ADDSUB:optab><GPI:sfxtab>")])
212+
167213
; Conditional execution
168214
(define_insn "*<optab><mode>_ce"
169215
[(cond_exec
@@ -315,6 +361,8 @@
315361
(set_attr "type" "<mntab>")]
316362
)
317363

364+
;; It may be worth to have a separate pattern for AND to take
365+
;; advantage of TST_S instruction.
318366
(define_insn "*<optab><mode>_cmp0_noout"
319367
[(set (reg:CC_ZN CC_REGNUM)
320368
(compare:CC_ZN
@@ -462,6 +510,37 @@
462510
(set_attr "type" "<optab><sfxtab>")]
463511
)
464512

513+
(define_insn "*<optab><mode>3_cmp0"
514+
[(set (reg:CC_ZN CC_REGNUM)
515+
(compare:CC_ZN
516+
(DIVREM:GPI
517+
(match_operand:GPI 1 "arc64_nonmem_operand" " 0,r,S32S0, r")
518+
(match_operand:GPI 2 "arc64_nonmem_operand" " r,r, r,S32S0"))
519+
(const_int 0)))
520+
(set (match_operand:GPI 0 "register_operand" "=r,r, r, r")
521+
(DIVREM:GPI (match_dup 1)
522+
(match_dup 2)))]
523+
"TARGET_ARC64_DIVREM
524+
&& (register_operand (operands[1], <MODE>mode)
525+
|| register_operand (operands[2], <MODE>mode))"
526+
"<mntab><sfxtab>.f\\t%0,%1,%2"
527+
[(set_attr "length" "4,4,8,8")
528+
(set_attr "type" "<optab><sfxtab>")])
529+
530+
(define_insn "*<optab><mode>3_cmp0_noout"
531+
[(set (reg:CC_ZN CC_REGNUM)
532+
(compare:CC_ZN
533+
(DIVREM:GPI
534+
(match_operand:GPI 0 "arc64_nonmem_operand" "r,S32S0, r")
535+
(match_operand:GPI 1 "arc64_nonmem_operand" "r, r,S32S0"))
536+
(const_int 0)))]
537+
"TARGET_ARC64_DIVREM
538+
&& (register_operand (operands[0], <MODE>mode)
539+
|| register_operand (operands[1], <MODE>mode))"
540+
"<mntab><sfxtab>.f\\t0,%0,%1"
541+
[(set_attr "length" "4,8,8")
542+
(set_attr "type" "<optab><sfxtab>")])
543+
465544
;; To be merged into adddi3
466545
(define_insn "*add_tls_off"
467546
[(set (match_operand:DI 0 "register_operand" "=r")

0 commit comments

Comments
 (0)