This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] try to eliminate icmp Pred (add nsw X, C1), C2
ClosedPublic

Authored by spatel on Jan 23 2017, 3:09 PM.

Details

Summary

I was surprised to see that we're missing icmp folds based on 'add nsw' in InstCombine, but I think we should handle the 'InstSimplify' cases first because that could make the InstCombine code simpler.

Here's an attempt to prove the logic with Alive:
http://rise4fun.com/Alive/g5Q

gcc has had these kinds of folds since at least v4.4 based on:
https://godbolt.org/g/J1nh5Q

Diff Detail

Event Timeline

spatel created this revision.Jan 23 2017, 3:09 PM
nlopes accepted this revision.Jan 24 2017, 3:07 AM

Alive is still not great for thins kind of patch; I guess it needs some macro support.
But you can use a little more general preconditions like this: http://rise4fun.com/Alive/Tz0

Regardless, the patch LGTM.

This revision is now accepted and ready to land.Jan 24 2017, 3:07 AM

Alive is still not great for thins kind of patch; I guess it needs some macro support.
But you can use a little more general preconditions like this: http://rise4fun.com/Alive/Tz0

Thanks! It's a good sign when people can mostly use the product without reading any docs or code. :)

This revision was automatically updated to reflect the committed changes.