This is an archive of the discontinued LLVM Phabricator instance.

Improve clamp recognition in ValueTracking.
ClosedPublic

Authored by ArturGainullin on Oct 24 2017, 6:50 AM.

Details

Summary

ValueTracking was recognizing not all variations of clamp. Swapping of
true value and false value of select was added to fix this problem. We
break canonical form only for clamp pattern recognition. The first patch
was reverted because it caused miscompile in NVPTX target. Added
corresponding test cases.

Diff Detail

Repository
rL LLVM

Event Timeline

ArturGainullin created this revision.Oct 24 2017, 6:50 AM
spatel edited edge metadata.Oct 26 2017, 8:25 AM

It seems less confusing to me to just make a clamp helper function where we do the swap locally without affecting anyone else. See attached patch proposal.

Sanjay, thank you very much! I agree that solution with helper function looks better.

spatel accepted this revision.Oct 27 2017, 7:44 AM

LGTM.

This revision is now accepted and ready to land.Oct 27 2017, 7:44 AM
This revision was automatically updated to reflect the committed changes.