Skip to content

Commit b895d10

Browse files
Claudiu Zissulescuartemiy-volkov
authored andcommitted
arc64: Add BRcc combiner patterns
1 parent de2a3a1 commit b895d10

File tree

4 files changed

+66
-12
lines changed

4 files changed

+66
-12
lines changed

gcc/config/arc64/arc64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,8 @@ get_arc64_condition_code (rtx comparison)
12101210
{
12111211
switch (GET_MODE (XEXP (comparison, 0)))
12121212
{
1213+
case E_DImode: /* brcc/bbit instructions. */
1214+
case E_SImode:
12131215
case E_CCmode:
12141216
switch (GET_CODE (comparison))
12151217
{
@@ -1236,8 +1238,6 @@ get_arc64_condition_code (rtx comparison)
12361238
default : gcc_unreachable ();
12371239
}
12381240
case E_CC_Zmode:
1239-
case E_DImode: /* bbit instructions. */
1240-
case E_SImode:
12411241
switch (GET_CODE (comparison))
12421242
{
12431243
case EQ : return ARC_CC_EQ;

gcc/config/arc64/arc64.md

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,17 @@
423423

424424
(define_attr "type" "abs, adcl, add, addhl, addl, and, andl, asl,
425425
asll, asr, asrl, atldop, atldlop, bbit, bclr, bic, bl, block, bmsk,
426-
branch, branchcc, brk, bset, bsetl, btst, bxor, bxorl, cmp, dbnz, dmb,
427-
dmpywh, ex, div, divl, ext, fadd, fcmp, fsub, fmul, fdiv, fh2s, fmin,
428-
fmax, fsgnj, fsgnjx, fsgnjn, fmadd, fmov, fmsub, fnmadd, fnmsub,
429-
fsqrt, frnd, fs2d, fs2h, fd2s, int2fp, uint2fp, fp2int, fp2uint, ffs,
430-
fls, flag, jl, jump, ld, llock, lsr, lsrl, lr, max, maxl, min, minl,
431-
move, movecc, mod, modl, neg, nop, norm, normh, norml, mac, mpy, mpyl,
432-
not, notl, or, orl, return, ror, rol, sbcl, scond, setcc, sex, sr, st,
433-
sub, subl, swap, swapl, swape, swapel, sync, tst, trap, qmach, qmpyh,
434-
udiv, udivl, umod, umodl, unknown, vadd, vsub, vmac2h, vmpy2h, vfadd,
435-
vfext, vfins, vfsub, vfmul, vfdiv, vfrep, vpack, xbfu, xor, xorl"
426+
branch, brcc, branchcc, brk, bset, bsetl, btst, bxor, bxorl, cmp,
427+
dbnz, dmb, dmpywh, ex, div, divl, ext, fadd, fcmp, fsub, fmul, fdiv,
428+
fh2s, fmin, fmax, fsgnj, fsgnjx, fsgnjn, fmadd, fmov, fmsub, fnmadd,
429+
fnmsub, fsqrt, frnd, fs2d, fs2h, fd2s, int2fp, uint2fp, fp2int,
430+
fp2uint, ffs, fls, flag, jl, jump, ld, llock, lsr, lsrl, lr, max,
431+
maxl, min, minl, move, movecc, mod, modl, neg, nop, norm, normh,
432+
norml, mac, mpy, mpyl, not, notl, or, orl, return, ror, rol, sbcl,
433+
scond, setcc, sex, sr, st, sub, subl, swap, swapl, swape, swapel,
434+
sync, tst, trap, qmach, qmpyh, udiv, udivl, umod, umodl, unknown,
435+
vadd, vsub, vmac2h, vmpy2h, vfadd, vfext, vfins, vfsub, vfmul, vfdiv,
436+
vfrep, vpack, xbfu, xor, xorl"
436437
(const_string "unknown"))
437438

438439
(define_attr "iscompact" "yes,no,maybe" (const_string "no"))
@@ -1410,6 +1411,47 @@ vfext, vfins, vfsub, vfmul, vfdiv, vfrep, vpack, xbfu, xor, xorl"
14101411
(const_int 4)
14111412
(const_int 8)))])
14121413

1414+
;; combiner patterns for BRcc instructions. We consider all BRcc
1415+
;; supported comparisons but compare with zero. The positive range
1416+
;; needs to take into account the limm size, and the pcl rounding.
1417+
;; This pattern is under an option as it may prohibit further
1418+
;; optimizations like if-conversion.
1419+
(define_insn "*brcc"
1420+
[(set (pc)
1421+
(if_then_else
1422+
(match_operator 3 "brcc_comparison_operator"
1423+
[(match_operand:GPI 1 "register_operand" "r,r")
1424+
(match_operand:GPI 2 "brcc_2ndoperand" "U06S0r,U32S0")])
1425+
(label_ref (match_operand 0 "" ""))
1426+
(pc)))
1427+
(clobber (reg:CC_ZN CC_REGNUM))]
1428+
"!CROSSING_JUMP_P (insn) && TARGET_BRCC"
1429+
{
1430+
switch (get_attr_length (insn))
1431+
{
1432+
case 4:
1433+
case 8:
1434+
return \"br%m3<sfxtab>\\t%1,%2,%l0\";
1435+
default:
1436+
return \"cmp<sfxtab>\\t%1,%2\\n\\tb%m3\\t%l0\";
1437+
}
1438+
}
1439+
[(set_attr "type" "brcc")
1440+
(set (attr "length")
1441+
(cond [(and (ge (minus (match_dup 0) (pc)) (const_int -254))
1442+
(le (minus (match_dup 0) (pc)) (const_int 248))
1443+
(eq (symbol_ref "which_alternative") (const_int 0)))
1444+
(const_int 4)
1445+
(and (ge (minus (match_dup 0) (pc)) (const_int -254))
1446+
(le (minus (match_dup 0) (pc)) (const_int 244))
1447+
(eq (symbol_ref "which_alternative") (const_int 1)))
1448+
(const_int 8)
1449+
;; This should be variable as well...
1450+
(eq (symbol_ref "which_alternative") (const_int 0))
1451+
(const_int 12)]
1452+
(const_int 12)))
1453+
])
1454+
14131455
;; -------------------------------------------------------------------
14141456
;; Sign/Zero extension
14151457
;; -------------------------------------------------------------------

gcc/config/arc64/arc64.opt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,7 @@ Enable wide floating point SIMD support.
107107
m128
108108
Target Report Mask(WIDE_LDST)
109109
Enable wide data transfer support.
110+
111+
mbrcc
112+
Target Report Mask(BRCC)
113+
Generate BRcc instructions during combiner step.

gcc/config/arc64/predicates.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,11 @@
208208
(define_predicate "bbitimm_operand"
209209
(and (match_code "const_int")
210210
(match_test "IS_POWEROF2_P (INTVAL (op))")))
211+
212+
(define_special_predicate "brcc_comparison_operator"
213+
(match_code "eq, ne, lt, ge, ltu, geu"))
214+
215+
(define_predicate "brcc_2ndoperand"
216+
(ior (match_operand 0 "register_operand")
217+
(and (match_code "const_int")
218+
(match_test "INTVAL (op) != 0"))))

0 commit comments

Comments
 (0)