[tree-ssa] [PATCH] Add ABS optimization to tree-ssa-phiopt.c

Andrew Pinski pinskia@physics.uc.edu
Wed Feb 25 20:04:00 GMT 2004


This patch adds the part of the ABS optimization that which if 
conversion does
on the RTL level but since it is done before the tree is expanded it 
can cause
much better code.  I am sending this so I do not forget about this 
patch at all
and so that maybe it can be reviewed after the tree-ssa gets merged 
into the
mainline.  I will also be committing this patch on the lno branch soon.


For an example on 32bit PPC:
long long absl1(long long i)
{
   long long t;
   if(i>=0)
     t = i;
   else
     t = -i;
   return t;
}
Without the patch:
_absl1:
         cmpwi cr7,r3,0
         mr r10,r4
         mr r9,r3
         blt- cr7,L7
         mr r3,r9
         mr r4,r10
         blr
L7:
         subfic r10,r4,0
         subfze r9,r3
         mr r3,r9
         mr r4,r10
         blr

With the patch:
_absl1:
         srawi r9,r3,31
         srawi r10,r3,31
         xor r3,r9,r3
         xor r4,r10,r4
         subfc r4,r10,r4
         subfe r3,r9,r3
         blr

Basically if conversion cannot do the conversion here as the RTL level 
has too
many moves and barriers.

Note this patch does not detect Negative ABS yet but does detect all 
simple
ABS that I can throw at it.

ChangeLog:
	*tree-ssa-phiopt.c (tree_ssa_phiopt):
	Split into conditional_replacement.
	Call also absolute_replacement.
	(conditional_replacement): New function.
	(absolute_replacement): New function.

Patch:
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: temp.abs.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040225/41db3c29/attachment.txt>
-------------- next part --------------




More information about the Gcc-patches mailing list