This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

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:
        srawi r9,r3,31
        srawi r10,r3,31
        xor r3,r9,r3
        xor r4,r10,r4
        subfc r4,r10,r4
        subfe r3,r9,r3

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.

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


Attachment: temp.abs.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]