SUBREG GIVs - Suggestion for a quick hack.

Toon Moene toon@moene.indiv.nluug.nl
Tue Sep 30 14:31:00 GMT 1997


L.S.,

The more I look into the problem of getting SUBREG general  
induction variables being recognised by general_induction_var and  
simplify_giv_expr, the less I believe this will ever be possible  
without the grant-rewrite-of-loop-we-all-learned-to-fear.

However, for the performance problems on the Alpha, a quick hack  
seems to suggest itself.

The problematic induction variables are invariably ;-) part of the  
following sequence:

(set (subreg:DI (reg:SI x)) (<some construct<))
(set (reg:DI y) (sign_extend:DI (reg:SI x)))

Now, IMNSHO, this is equivalent to (whether this subreg variable is  
promoted or not and modulo overflow of `x', which leads to  
undefined behaviour anyway):

(set (subreg:DI (reg:SI x)) (<some construct>))
(set (reg:DI y) (<some construct>))

[ This only works if <some construct> doesn't have side effects ]

If <some construct> will make `y' a GIV, this will be recognised.   
Later optimisation passes like flow will eliminate the redundant  
store into a part of register `x', because it won't be used.

So it seems a quickie scan over the INSNs in the loop to `combine'  
these pairs would have all other strength reduction proceed  
normally.

Please comment on this, before I start out to try it (I would  
especially be interested in how to change the second of the two  
set's, i.e. how to `CONS' <some construct> into it ;-).

Regards,
Toon.



More information about the Gcc mailing list