Yet more testing showed that compare insns too, were prone to catching
double-memory operands, for example with
c-c++-common/vector-compare-3.c -O2, from gcc.dg. So, better try to
fix them, helping current and future optimization passes that are
reluctant or unable to operate on patterns with two memory operands.
This just happens at expansion time by hacking the force_reg stuff to
conveniently happen in the operand-massaging function
cris_reduce_compare. Together, this and the two previous CRIS patches
did improve coremark results, but by a miniscule factor: speed by
0.002% (from
4887074 to
4886993 cycles) and size by 0.1% (code from
58199 to 58143 bytes) and as you can see, with rounding doing heavy
lifting.
* config/cris/cris.cc (cris_reduce_compare): Add forcing the first
operand to be a register, unless the second operand is 0, to scope.
* config/cris/cris.md ("*cstore<mode><code>4")
("*cbranch<mode><code>4"): Add guards to condition, for either operand
to be a register unless the last operand is zero.
/* Try to change a comparison against a constant to be against zero, and
an unsigned compare against zero to be an equality test. Beware:
- only valid for compares of integer-type operands. Also, note that we
- don't use operand 0 at the moment. */
+ only valid for compares of integer-type operands. Also forces one operand
+ to be a register, unless either is 0. */
void
-cris_reduce_compare (rtx *relp, rtx *, rtx *op1p)
+cris_reduce_compare (rtx *relp, rtx *op0p, rtx *op1p)
{
rtx op1 = *op1p;
rtx_code code = GET_CODE (*relp);
if (code != GET_CODE (*relp))
{
- *op1p = const0_rtx;
+ op1 = const0_rtx;
+ *op1p = op1;
PUT_CODE (*relp, code);
}
+
+ if (op1 != const0_rtx && *op0p != const0_rtx)
+ {
+ machine_mode op1mode = GET_MODE (op1);
+
+ *op0p = force_reg (op1mode != VOIDmode ? op1mode : GET_MODE (*op0p),
+ *op0p);
+ }
}
/* The expander for the prologue pattern name. */
(label_ref (match_operand 2 ""))
(pc)))
(clobber (reg:CC CRIS_CC0_REGNUM))]
- ""
+ "(register_operand (operands[0], <MODE>mode)
+ || register_operand (operands[1], <MODE>mode)
+ || operands[1] == const0_rtx)"
"#"
"&& reload_completed"
[(set (reg:<xCC> CRIS_CC0_REGNUM)
(match_operand:BWDD 1 "nonimmediate_operand" "<cmp_op0c>")
(match_operand:BWDD 2 "general_operand" "<cmp_op1c>")))
(clobber (reg:CC CRIS_CC0_REGNUM))]
- ""
+ "(register_operand (operands[1], <MODE>mode)
+ || register_operand (operands[2], <MODE>mode)
+ || operands[2] == const0_rtx)"
"#"
"&& reload_completed"
[(set (reg:<xCC> CRIS_CC0_REGNUM)