[PATCH] SelectionDAG: mimic InstCombine when comparing to undef

Mehdi Amini mehdi.amini at apple.com
Thu Feb 12 23:36:31 PST 2015


> On Feb 12, 2015, at 9:25 PM, hfinkel at anl.gov wrote:
> 
>> I haven't put a test yet, and it breaks the validation, but before fixing this I seek opinion on NaN handling here. InstCombine does not care and I don't really see why the same IR would be handled differently in the DAG than in InstCombine.
> 
> 
> I don't know either, but that sounds wrong. This depends on the predicate, I think, for fcmp, but NaN != NaN (or anything else), and so we can't arbitrarily fold fcmp pred x, undef to true unless we know that x cannot be NaN (or we're generically allowing unsafe floating-point transformations).


I’m not sure I can invalidate the reasoning for InstCombine, I need help :)

 // fcmp pred X, undef -> undef

If we don’t know anything for X, then the result of the comparison can be either true or false. It seems to me completely valid to return “undef”.

The select will then decide that on “undef” it will always pick the first choice (IIRC).

Mehdi

PS: about NaN != NaN, "fcmp ueq NaN, NaN” yields true :)



More information about the llvm-commits mailing list