Hi, I'd like to know if there a way to express 'add' and 'compare' insn so that the combiner transform it in and 'add_and_compare' insn.
I watch arm backend and it seems possible when I look at 'addsi3', 'cbranchsi4' and '*addsi3_compare0'. In my backend I have written the following insn/expand : (define_expand "addsi3" [(set (match_operand:SI 0 "register_operand" "") (plus:SI (match_operand:SI 1 "general_operand" "") (match_operand:SI 2 "off1post_general_op" "")))] "" "" ) (define_insn "add_and_compare" [(set (reg:CC CCI_REG) (compare:CC (plus:SI (match_operand:SI 1 "register_operand" "%r") (match_operand:SI 2 "register_operand" "r")) (const_int 0))) (set (match_operand:SI 0 "register_operand" "=r") (plus:SI (match_dup 1) (match_dup 2)))] "" "add %1,%2,%0" ) (define_insn "add" [(set (match_operand:SI 0 "register_operand" "=r") (plus:SI (match_operand:SI 1 "register_operand" "%r") (match_operand:SI 2 "register_operand" "r")))] "" "addk %1,%2,%0" ) (define_expand "cbranchsi4" [(set (pc) (if_then_else (match_operator 0 "comparison_operator" [(match_operand:SI 1 "register_operand" "") (match_operand:SI 2 "register_operand" "")]) (label_ref (match_operand 3 "" "")) (pc)))] { emit_insn(gen_comparesi (operands[1], operands[2])); operands[1] = gen_rtx_REG (CCmode, CCI_REG); operands[2] = const0_rtx; } ) (define_insn "comparesi" [(set (reg:CC CCI_REG) (compare:CC (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "register_operand" "r")))] "" "cmp %1,%0" ) (define_insn "jmpifsi" [(set (pc) (if_then_else (match_operator 0 "comparison_operator" [(reg:CC CCI_REG) (const_int 0)]) (label_ref (match_operand 1 "" "")) (pc)))] "" "jmp.if %c0 %1" ) When I compile : c = a + b; if (c) {...} No combination occurs between "add" and "comparesi" insn. I was expecting to see my "add_and_compare" pattern. The resulting assembler is addk cmp jmp.if instead of add jmp.if Do someone see why combination fails ? (gcc 4.5.2) Thanks, Selim