+2014-05-16 Oleg Endo <olegendo@gcc.gnu.org>
+
+ PR target/51244
+ * config/sh/sh.c (sh_eval_treg_value): Handle t_reg_operand and
+ negt_reg_operand cases.
+ * config/sh/sh.md (*cset_zero): Likewise by using cbranch_treg_value
+ predicate.
+ * config/sh/predicates.md (cbranch_treg_value): Simplify.
+
2014-05-16 Oleg Endo <olegendo@gcc.gnu.org>
* config/sh/sh.c (sh_option_override): Set branch cost to 2 for all
;; A predicate that returns true if OP is a valid construct around the T bit
;; that can be used as an operand for conditional branches.
(define_predicate "cbranch_treg_value"
- (match_code "eq,ne,reg,subreg,xor,sign_extend,zero_extend")
-{
- return sh_eval_treg_value (op) >= 0;
-})
+ (and (match_code "eq,ne,reg,subreg,xor,sign_extend,zero_extend")
+ (match_test "sh_eval_treg_value (op) >= 0")))
;; Returns true if OP is arith_reg_operand or t_reg_operand.
(define_predicate "arith_reg_or_t_reg_operand"
int
sh_eval_treg_value (rtx op)
{
- enum rtx_code code = GET_CODE (op);
+ if (t_reg_operand (op, GET_MODE (op)))
+ return 1;
+ if (negt_reg_operand (op, GET_MODE (op)))
+ return 0;
+
+ rtx_code code = GET_CODE (op);
if ((code != EQ && code != NE) || !CONST_INT_P (XEXP (op, 1)))
return -1;
(define_insn "*cset_zero"
[(set (match_operand:SI 0 "arith_reg_dest" "=r")
- (if_then_else:SI (match_operand:SI 1 "t_reg_operand")
+ (if_then_else:SI (match_operand:SI 1 "cbranch_treg_value")
(match_operand:SI 2 "arith_reg_operand" "0")
(const_int 0)))]
"TARGET_SH1 && TARGET_ZDCBRANCH"
{
- return "bt 0f" "\n"
- " mov #0,%0" "\n"
- "0:";
+ int tval = sh_eval_treg_value (operands[1]);
+ if (tval == true)
+ return "bt 0f" "\n"
+ " mov #0,%0" "\n"
+ "0:";
+ else if (tval == false)
+ return "bf 0f" "\n"
+ " mov #0,%0" "\n"
+ "0:";
+ else
+ gcc_unreachable ();
}
[(set_attr "type" "arith") ;; poor approximation
(set_attr "length" "4")])