In a couple of places we open-code a special case of this pattern into the more specific sub<GPI>3_compare1_imm. Centralize that special case into an expander.
* config/aarch64/aarch64.md (*sub<GPI>3_compare1): Rename from sub<GPI>3_compare1. (sub<GPI>3_compare1): New expander. --- gcc/config/aarch64/aarch64.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 076158b0071..47eeba7311c 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -3120,7 +3120,7 @@ [(set_attr "type" "alus_imm")] ) -(define_insn "sub<mode>3_compare1" +(define_insn "*sub<mode>3_compare1" [(set (reg:CC CC_REGNUM) (compare:CC (match_operand:GPI 1 "aarch64_reg_or_zero" "rkZ") @@ -3132,6 +3132,26 @@ [(set_attr "type" "alus_sreg")] ) +(define_expand "sub<mode>3_compare1" + [(parallel + [(set (reg:CC CC_REGNUM) + (compare:CC + (match_operand:GPI 1 "aarch64_reg_or_zero") + (match_operand:GPI 2 "aarch64_reg_or_imm"))) + (set (match_operand:GPI 0 "register_operand") + (minus:GPI (match_dup 1) (match_dup 2)))])] + "" +{ + if (aarch64_plus_immediate (operands[2], <MODE>mode)) + { + emit_insn (gen_sub<mode>3_compare1_imm + (operands[0], operands[1], operands[2], + GEN_INT (-INTVAL (operands[2])))); + DONE; + } + operands[2] = force_reg (<MODE>mode, operands[2]); +}) + (define_peephole2 [(set (match_operand:GPI 0 "aarch64_general_reg") (minus:GPI (match_operand:GPI 1 "aarch64_reg_or_zero") -- 2.20.1