[PATCH][AArch64] Use CC_Z and CC_NZ with csinc and similar instructions
Tue Sep 2 15:34:00 GMT 2014
Sorry for the delay.
On 19/08/14 17:09, Richard Henderson wrote:
>> (define_special_predicate "cc_register_zero"
>> (match_code "reg")
>> return (REGNO (op) == CC_REGNUM
>> && (GET_MODE (op) == CCmode
>> || GET_MODE (op) == CC_Zmode
>> || GET_MODE (op) == CC_NZmode));
> ... and now that I read the backend more closely, I see "_zero" was a bad name.
> But more importantly, I see no connection between the comparison used and the
> CCmode being accepted. And if we fix that, why are you restricting to just Z
> and NZ? What's wrong with e.g. CFPmode?
I'm not sure why restricted the modes for csinc.
> In the i386 backend, we check comparison+mode correspondence like
> (match_operator 4 "ix86_carry_flag_operator"
> [(match_operand 3 "flags_reg_operand") (const_int 0)])
> I think you'll want something similar. In the case of CSINC, we can accept all
> conditions, so let's start with the most general:
> (match_operator:GPI 2 "aarch64_comparison_operation"
> [(reg CC_REGNUM) (const_int 0)]
> or even
> (match_operand:GPI 2 "aarch64_comparison_operation" "")
> (define_predicate "aarch64_comparison_operation"
> (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu,"
> if (XEXP (op, 1) != const0_rtx)
> return false;
> rtx op0 = XEXP (op, 0);
> if (!REG_P (op0) || REGNO (op0) != CC_REGNUM)
> return false;
> return aarch64_get_condition_code (op) >= 0;
> where aarch64_get_condition_code is
> (1) exported
> (2) adjusted to return "int" not "unsigned"
> (3) adjusted to not abort, but return -1 for invalid combinations.
> and the two existing users of aarch64_get_condition_code are adjusted to
> gcc_assert that the return value is valid.
Implementing that seems to work fine. Bootstrap and testing were successful.
How's this version then?
2014-09-02 Kyrylo Tkachov <email@example.com>
* config/aarch64/predicates.md (aarch64_comparison_operation):
New special predicate.
* config/aarch64/aarch64.md (*csinc2<mode>_insn): Use
aarch64_comparison_operation instead of matching an operator.
Update operand numbers.
(ffs<mode>2): Update gen_csinc3<mode>_insn callsite.
* config/aarch64/aarch64.c (aarch64_get_condition_code): Export.
Return -1 instead of aborting on invalid condition codes.
(aarch64_print_operand): Update aarch64_get_condition_code callsites
to assert that the returned condition code is valid.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 8294 bytes
Desc: not available
More information about the Gcc-patches