This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [patches] Re: SSE min/max take2 - documentation




On Tue, 27 Feb 2001, Jan Hubicka wrote:
|> We can use the identity (x > y ? x : y) == (-y <= -x ? y : x) 
|> to uniformly handle all cases on all platforms. This identity
|> holds in presence of signed zeroes, infinities and NaN's.
|hmm, thats nice, but how this helps to expanders?
|If we define min expander to generate three negations and max on target
|platform, I don't think we will win the code quality....

The negations only involve toggling one bit, and it also might be possible
to optimize away in many expressions (by reversing subtractions etc.)
but what I mean is that we can use the tree to express all cases.

If you have code like:

   z = (x > y ? x : y)

and no special -ffast-math option and compile for PowerPC,
you would see that the cost of this is the cost of two negations
and the min operation, which might be high enough not to choose this.
On the other hand, on x86 this would just have the cost for the max.

Similarly, if you have code like
   z = (x >= y ? x : y) 
then you would notice that this is equivalent to (-y < -x ? y : x)
and the cost for the PowerPC would be lower than the cost for the x86.

So it seems that instead of a semantic issue, we would just have a
cost issue. I do not know enough on how exactly expansion and combination
of patterns works in GCC to see whether this would work, but it seems
to me that since we can always convert to/from these patterns there
should be a way to get the minimal cost alternative for a certain expression.

 -Geert


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