This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Propagate fast math flags through selects
ClosedPublic

Authored by foad on Aug 2 2019, 7:43 AM.

Details

Summary

In SimplifySelectsFeedingBinaryOp, propagate fast math flags from the
outer op into both arms of the new select, to take advantage of
simplifications that require fast math flags.

Diff Detail

Repository
rL LLVM

Event Timeline

foad created this revision.Aug 2 2019, 7:43 AM
spatel added a comment.Aug 6 2019, 6:19 AM

The code change seems fine, but the lone test does not provide enough coverage. Please have a look and rebase:
rL368028

foad updated this revision to Diff 213839.Aug 7 2019, 4:06 AM

Rebase.

foad added a comment.Aug 7 2019, 4:08 AM

The code change seems fine, but the lone test does not provide enough coverage. Please have a look and rebase:
rL368028

Done. Thanks for the test cases! Note that the fdiv case is not affected because InstCombiner::visitFDiv does not call SimplifySelectsFeedingBinaryOp. Perhaps it should.

spatel accepted this revision.Aug 7 2019, 4:25 AM

The code change seems fine, but the lone test does not provide enough coverage. Please have a look and rebase:
rL368028

Done. Thanks for the test cases! Note that the fdiv case is not affected because InstCombiner::visitFDiv does not call SimplifySelectsFeedingBinaryOp. Perhaps it should.

Yes - I noticed that test wasn't changing, but I didn't track down why. If you want to mark that test with a TODO comment, that would be good. Or you could fix the fdiv logic first, then update this patch again to show the improvement for fdiv.

LGTM

This revision is now accepted and ready to land.Aug 7 2019, 4:25 AM
This revision was automatically updated to reflect the committed changes.