Hi, The canonical form of subtract of immediate is (add op0 minus_imm), which is supported with addsi3_aarch64 pattern on aarch64. Unfortunately wrong cost (8 rather than 4) is computed by aarch64_rtx_cost because it doesn't honor the fact that it actually is a sub instruction. This patch fixes it, is this OK?
Thanks, bin 2015-06-25 Bin Cheng <bin.ch...@arm.com> * config/aarch64/aarch64.c (aarch64_rtx_costs): Handle addition of minus immediate.
Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c (revision 224930) +++ gcc/config/aarch64/aarch64.c (working copy) @@ -6049,6 +6049,14 @@ cost_plus: *cost += extra_cost->alu.arith; return true; } + else if (GET_MODE_CLASS (mode) == MODE_INT + && CONST_INT_P (op1) + && aarch64_uimm12_shift (- (INTVAL (op1)))) + { + /* ADD -(immediate). */ + op1 = gen_int_mode (- (INTVAL (op1)), mode); + goto cost_minus; + } *cost += rtx_cost (op1, PLUS, 1, speed);