This is an archive of the discontinued LLVM Phabricator instance.

SelectionDAG: mimic InstCombine when comparing to undef
Needs ReviewPublic

Authored by mehdi_amini on Feb 12 2015, 7:20 PM.

Details

Reviewers
hfinkel
Summary

This implements the same folding for SelectionDAG than what is present in InstCombine.

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.

Diff Detail

Repository
rL LLVM

Event Timeline

mehdi_amini retitled this revision from to SelectionDAG: mimic InstCombine when comparing to undef.
mehdi_amini updated this object.
mehdi_amini edited the test plan for this revision. (Show Details)
mehdi_amini added a reviewer: hfinkel.
mehdi_amini set the repository for this revision to rL LLVM.
mehdi_amini added a subscriber: Unknown Object (MLST).
hfinkel edited edge metadata.Feb 12 2015, 9:25 PM

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).

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
1924

Is the third check supposed to be N2?

Thanks, this was my impression as well, I’ll try to write a test and a patch for InstCombine, and then I’ll come back to SelectionDAG.

(good catch for N2, I'll try to have a test that stress this as well)