This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Need advice: x86 redudant compare to zero
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: evan dot cheng at apple dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 13 Oct 05 21:04:26 EDT
- Subject: 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")])
But I do not see a peephole2 that would generate this insn. Does
anyone know how this pattern is used?
This is the sort of thing you'd expect combine.c to make when it
combines an scc insn with arithmetic when the arithmetic result
is also used.