[PATCH] Combine fcmp + select to fminnum / fmaxnum if no nans and legal

Owen Anderson resistor at mac.com
Mon Jan 12 15:59:58 PST 2015


> On Jan 12, 2015, at 3:39 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:
> 
> In http://reviews.llvm.org/D6744#107740, @ab wrote:
> 
>> The NaN part LGTM, but what happens on 0?
>> 
>> Say:
>> 
>>  select +0.0, -0.0, (fcmp lt +0.0, -0.0)
>> 
>> turns into:
>> 
>>  fminnum +0.0, -0.0
>> 
>> 
>> My understanding is, the first returns -0.0 (because they compare equal, and not "lt").
>> But it's unspecified which the second returns, so if the implementation returns the first operand when both are zero, it would return a "different" result here, +0.0.
>> Does that make sense?
> 
> 
> Yes, however I am unclear on what guarantees there are for signed zeros. The DAG TargetOptions are also missing the equivalent of No Signed Zeros. I can weaken this to unsafe FP Math as well.

Changing 0.0 to -0.0 or vice versa is not necessarily a no-op, so we shouldn’t do it without permission from the user.

—Owen



More information about the llvm-commits mailing list