Am Samstag, 14. Mai 2005 21:39 schrieb Alexandre Oliva:
> On May 14, 2005, BjÃrn Haase <[EMAIL PROTECTED]> wrote:
> > I.e. expand
> > would insert two instructions after the double-set instruction that
> > contain the two individual sets and an additional "use" statement. I.e.
> > above sequence after expand then would look like
> >
> > (parallel[
> >     (set reg:SI 100) (minus:SI (reg:SI 101) (reg:SI 102))
> >     (set reg:CC CC_xxx) (compare (reg:SI 101) (reg:SI 102)))])
> > (parallel[ (set reg:SI 100) (minus:SI (reg:SI 101) (reg:SI 102))
> >            (use (reg:SI 100) ])
> > (parallel[ (set reg:CC_xxx CC) (compare (reg:SI 101) (reg:SI 102)))
> >            (use (reg:CC])
>
> You'd then have to some how arrange for the second and third insns to
> not be removed as redundant, and come up with some additional work
> around for the case when there's an overlap between output and input.
Yes. I agree with both of your remarks. 

Concerning removal of the redundant expressions: It seems that the fact that 
condition codes could be reused is identified already during CSE or GCSE, and 
at this time the passes removing dead code seem not to have removed the 
redundant patterns. At least, since this worked for the case of "divmod", I 
am having hope that this would work as well for condition codes.

Concerning your second remark: Indeed one probably would need to rewrite the 
third pattern as 
 (parallel[ (set reg:CC_xxx CC) (compare (reg:SI 100) (const_int 0)))
            (use (reg:CC])
. For the divmod issue, I have observed a very similar difficulty (there 
however there is no problem with overlapping in- and outputs due to a couple 
of additional moves, but the problem there is that the register allocator 
falsely assumes that the input register operands still need to be alive for 
the announcement instruction and this prevents some optimizations.)

What might be a bit hairy is to make sure that the real compare instructions 
(i.e. the possibly "unnecessary" compares I am aiming to remove) that are 
emitted at expand result in RTL that match as well as possible the 
"announcement" patterns that are generated by the arithmetic/logic 
operations.
Anyway, I have hope that by using this method one would at least be able to 
handle condition code reuse for code segments like

int a,b,c;

c = a - b;
if (c > 0)
{ 
   // do something
 ;
}

without requiring to use peepholes.

Yours,

BjÃrn

Reply via email to