This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Need advice: x86 redudant compare to zero



My question is: where and how would you suggest we do this optimization. With peephole2? Or in combine? In i386.md, I see pattern *subsi_2 looks like what I'd like to combine these two insn into:

(define_insn "*subsi_2"
  [(set (reg FLAGS_REG)
    (compare
      (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
            (match_operand:SI 2 "general_operand" "ri,rm"))
      (const_int 0)))
   (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
    (minus:SI (match_dup 1) (match_dup 2)))]
  "ix86_match_ccmode (insn, CCGOCmode)
   && ix86_binary_operator_ok (MINUS, SImode, operands)"
  "sub{l}\t{%2, %0|%0, %2}"
  [(set_attr "type" "alu")
   (set_attr "mode" "SI")])

That's quite similar to several PPC patterns for andi. , and they work.
If you've got two other insns that look like the set's I'd expect combine
to merge them, and would look to see why it doesn't.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]