On 09/27/2010 03:37 PM, DJ Delorie wrote:
>> I think it's probably a mistake to have the default ADD
>> instruction SET the flags, rather than CLOBBER them.
>
> How else would we optimize away compares?
By having a separate ADD that looks like your current one.
Combine will put them together for you. Compare i386
(define_insn "*add<mode>_1"
[(set (match_operand:SWI48 0 "nonimmediate_operand" "=r,rm,r,r")
(plus:SWI48
(match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r")
(match_operand:SWI48 2 "<general_operand>" "<g>,r<i>,0,l<i>")))
(clobber (reg:CC FLAGS_REG))]
"ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
...
(define_insn "*add<mode>_2"
[(set (reg FLAGS_REG)
(compare
(plus:SWI
(match_operand:SWI 1 "nonimmediate_operand" "%0,0")
(match_operand:SWI 2 "<general_operand>" "<g>,<r><i>"))
(const_int 0)))
(set (match_operand:SWI 0 "nonimmediate_operand" "=<r>,<r>m")
(plus:SWI (match_dup 1) (match_dup 2)))]
"ix86_match_ccmode (insn, CCGOCmode)
&& ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
...
r~