This is an archive of the discontinued LLVM Phabricator instance.

Simplify (x >> y) <= x
ClosedPublic

Authored by ranma42 on Jan 21 2016, 6:02 AM.

Details

Summary

This commit extends the patterns recognised by InstSimplify to also handle (x >> y) <= x in the same way as (x /u y) <= x.

The missing optimisation was found investigating why LLVM did not optimise away bound checks in a binary search: https://github.com/rust-lang/rust/pull/30917

I was did not like duplicating the code for udiv and lshr, so I tried to replicate the pattern match as in ValueTracking.cpp:1803.

Diff Detail

Repository
rL LLVM

Event Timeline

ranma42 updated this revision to Diff 45520.Jan 21 2016, 6:02 AM
ranma42 retitled this revision from to Simplify (x >> y) <= x.
ranma42 updated this object.
ranma42 set the repository for this revision to rL LLVM.
ranma42 added a subscriber: llvm-commits.
ranma42 added reviewers: majnemer, baldrick.EditedJan 21 2016, 6:53 AM

Added the author of the original code and the owner of IR Constant Folder, InstCombine as reviewers, as suggested by the code reviews guide.

sanjoy accepted this revision.Jan 21 2016, 8:22 AM
sanjoy added a reviewer: sanjoy.
This revision is now accepted and ready to land.Jan 21 2016, 8:22 AM

Phabricator says "Action required", but I do not know what is the next step.
The guide "Code Reviews with Phabricator" seems to indicate that this can now be committed to trunk, but I do not have commit access.

Sorry if I have misused the system, I have never used Phabricator nor posted patches for LLVM.

Usually you just mention that you don't have commit access and someone will commit it for you, if Sanjoy doesn't do it by tonight I'll commit it for you.

This revision was automatically updated to reflect the committed changes.