[RFC][4.4] PR rtl-optimization/3507 appalling optimization with sub/cmp

Rask Ingemann Lambertsen rask@sygehus.dk
Thu Nov 29 18:28:00 GMT 2007


On Thu, Nov 29, 2007 at 03:19:44PM +0100, Paolo Bonzini wrote:
> 
> >(insn 1 (set (reg C) (minus   (reg A) (reg B))))
> >
> >(insn 2 (set (reg D) (compare (reg A) (reg B))))
> >
> >(insn 3 (set ... (ltu (reg D) (const_int 0))))
> 
> So, I don't like your approach, but mine is probably infeasible -- 
> sorry.  Maybe combine would be the right place to fix it, by adding a 
> different way to do a 3 insn->2 insn combine (in find_split_point), but 
> I'm not asking you to try.

   But as pointed out by RTH in the audit trail, we don't set up LOG_LINKS
for insn 1 and 2, so combine never gets to see them in the first place. Even
if it did, you would also have to add insn patterns to recognize

(parallel [(set (reg D) (compare (reg A) (reg B)))
	   (set (reg C) (minus   (reg A) (reg B)))])

in addition to the usual (signed)

(parallel [(set (reg D) (compare (minus (reg A) (reg B)) (const_int 0)))
	   (set (reg C)		 (minus (reg A) (reg B)))])

or (unsigned)

(parallel [(set (reg D) (compare (minus (reg A) (reg B)) (reg A)))
	   (set (reg C)		 (minus (reg A) (reg B)))])

Adding the optimization to cse.c, I get the hash table, the LOG_LINKS and
the insn patterns for free. The only downside is that to optimize the signed
case with flag_wrapv || !flag_strict_overflow, the first insn form is needed
and I can't get it this way -- combine would have to detect it directly.

-- 
Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year



More information about the Gcc-patches mailing list