if (optimize > 1 && !optimize_size)
target_flags |= MASK_SAVE_ALL_TARGET_REGS;
- /* Set default values of TARGET_CBRANCHDI4 and TARGET_CMPEQDI_T. */
- TARGET_CBRANCHDI4 = 1;
- TARGET_CMPEQDI_T = 0;
-
sh_cpu = PROCESSOR_SH1;
assembler_dialect = 0;
if (TARGET_SH2)
prepare_cbranch_operands (rtx *operands, machine_mode mode,
enum rtx_code comparison)
{
- /* The scratch reg is only available when this is invoked from within
- the cbranchdi4_i splitter, through expand_cbranchdi4. */
- rtx scratch = NULL_RTX;
+ gcc_assert (can_create_pseudo_p ());
if (comparison == LAST_AND_UNUSED_RTX_CODE)
comparison = GET_CODE (operands[0]);
- else
- scratch = operands[4];
sh_canonicalize_comparison (comparison, operands[1], operands[2],
mode, false);
- /* Notice that this function is also invoked after reload by
- the cbranchdi4_i pattern, through expand_cbranchdi4. */
rtx op1 = operands[1];
+ operands[1] = force_reg (mode, op1);
- if (can_create_pseudo_p ())
- operands[1] = force_reg (mode, op1);
/* When we are handling DImode comparisons, we want to keep constants so
that we can optimize the component comparisons; however, memory loads
are better issued as a whole so that they can be scheduled well.
&& ((comparison != EQ && comparison != NE)
|| (REG_P (op1) && REGNO (op1) != R0_REG)
|| !satisfies_constraint_I08 (operands[2])))))
- {
- if (scratch && GET_MODE (scratch) == mode)
- {
- emit_move_insn (scratch, operands[2]);
- operands[2] = scratch;
- }
- else if (can_create_pseudo_p ())
- operands[2] = force_reg (mode, operands[2]);
- }
+ operands[2] = force_reg (mode, operands[2]);
+
return comparison;
}
int num_branches;
int prob, rev_prob;
int msw_taken_prob = -1, msw_skip_prob = -1, lsw_taken_prob = -1;
- rtx scratch = operands[4];
comparison = prepare_cbranch_operands (operands, DImode, comparison);
op1h = gen_highpart_mode (SImode, DImode, operands[1]);
rev_prob = REG_BR_PROB_BASE - prob;
switch (comparison)
{
- /* ??? Should we use the cmpeqdi_t pattern for equality comparisons?
- That costs 1 cycle more when the first branch can be predicted taken,
- but saves us mispredicts because only one branch needs prediction.
- It also enables generating the cmpeqdi_t-1 pattern. */
case EQ:
- if (TARGET_CMPEQDI_T)
- {
- emit_insn (gen_cmpeqdi_t (operands[1], operands[2]));
- emit_jump_insn (gen_branch_true (operands[3]));
- return true;
- }
msw_skip = NE;
lsw_taken = EQ;
if (prob >= 0)
}
break;
case NE:
- if (TARGET_CMPEQDI_T)
- {
- emit_insn (gen_cmpeqdi_t (operands[1], operands[2]));
- emit_jump_insn (gen_branch_false (operands[3]));
- return true;
- }
msw_taken = NE;
msw_taken_prob = prob;
lsw_taken = NE;
operands[1] = op1h;
operands[2] = op2h;
operands[4] = NULL_RTX;
- if (reload_completed
- && ! arith_reg_or_0_operand (op2h, SImode)
- && (true_regnum (op1h) || (comparison != EQ && comparison != NE))
- && (msw_taken != LAST_AND_UNUSED_RTX_CODE
- || msw_skip != LAST_AND_UNUSED_RTX_CODE))
- {
- emit_move_insn (scratch, operands[2]);
- operands[2] = scratch;
- }
+
if (msw_taken != LAST_AND_UNUSED_RTX_CODE)
expand_cbranchsi4 (operands, msw_taken, msw_taken_prob);
if (msw_skip != LAST_AND_UNUSED_RTX_CODE)
{
operands[1] = op1h;
operands[2] = op2h;
- if (reload_completed
- && ! arith_reg_or_0_operand (op2h, SImode)
- && (true_regnum (op1h) || (comparison != EQ && comparison != NE)))
- {
- emit_move_insn (scratch, operands[2]);
- operands[2] = scratch;
- }
}
operands[3] = skip_label = gen_label_rtx ();
operands[1] = op1l;
operands[2] = op2l;
if (lsw_taken != LAST_AND_UNUSED_RTX_CODE)
- {
- if (reload_completed
- && ! arith_reg_or_0_operand (op2l, SImode)
- && (true_regnum (op1l) || (lsw_taken != EQ && lsw_taken != NE)))
- {
- emit_move_insn (scratch, operands[2]);
- operands[2] = scratch;
- }
- expand_cbranchsi4 (operands, lsw_taken, lsw_taken_prob);
- }
+ expand_cbranchsi4 (operands, lsw_taken, lsw_taken_prob);
if (msw_skip != LAST_AND_UNUSED_RTX_CODE)
emit_label (skip_label);
return true;
(label_ref (match_operand 3 "" ""))
(pc)))
(clobber (reg:SI T_REG))]
- ""
+ "can_create_pseudo_p ()"
{
expand_cbranchsi4 (operands, LAST_AND_UNUSED_RTX_CODE, -1);
DONE;
(label_ref (match_dup 2))
(pc)))])
-;; FIXME: These could probably use code iterators for the compare op.
+;; FIXME: These don't seem to have any effect on the generated cbranch code
+;; anymore, but only on some register allocation choices.
(define_split
[(set (pc)
(if_then_else (le (match_operand:SI 0 "arith_reg_operand" "")
(define_expand "cbranchdi4"
[(set (pc)
(if_then_else (match_operator 0 "comparison_operator"
- [(match_operand:DI 1 "arith_operand" "")
- (match_operand:DI 2 "arith_operand" "")])
- (label_ref (match_operand 3 "" ""))
- (pc)))
- (clobber (match_dup 4))
- (clobber (reg:SI T_REG))]
- "TARGET_CBRANCHDI4 || TARGET_SH2"
-{
- enum rtx_code comparison;
-
- if (!TARGET_CBRANCHDI4)
- {
- sh_emit_compare_and_branch (operands, DImode);
- DONE;
- }
- else
- {
- if (expand_cbranchdi4 (operands, LAST_AND_UNUSED_RTX_CODE))
- DONE;
-
- comparison = prepare_cbranch_operands (operands, DImode,
- LAST_AND_UNUSED_RTX_CODE);
- if (comparison != GET_CODE (operands[0]))
- operands[0]
- = gen_rtx_fmt_ee (comparison, VOIDmode, operands[1], operands[2]);
- operands[4] = gen_rtx_SCRATCH (SImode);
- }
-})
-
-(define_insn_and_split "cbranchdi4_i"
- [(set (pc)
- (if_then_else (match_operator 0 "comparison_operator"
- [(match_operand:DI 1 "arith_operand" "r,r")
- (match_operand:DI 2 "arith_operand" "rN,I08")])
- (label_ref (match_operand 3 "" ""))
+ [(match_operand:DI 1 "arith_operand")
+ (match_operand:DI 2 "arith_operand")])
+ (label_ref (match_operand 3))
(pc)))
- (clobber (match_scratch:SI 4 "=X,&r"))
(clobber (reg:SI T_REG))]
- "TARGET_CBRANCHDI4"
- "#"
- "&& reload_completed"
- [(pc)]
+ "TARGET_SH2 && can_create_pseudo_p ()"
{
if (!expand_cbranchdi4 (operands, GET_CODE (operands[0])))
FAIL;