This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Teach SimplifyDemandedInstructionBits that even if we reach an instruction that has multiple uses, if we know all the bits for the demanded bits for this context we can go ahead and create a constant.
ClosedPublic

Authored by craig.topper on Mar 31 2017, 2:59 PM.

Details

Summary

Currently if we reach an instruction with multiples uses we know we can't do any optimizations to that instruction itself since we only have the demanded bits for one of the users. But if we know all of the bits are zero/one for that one user we can still go ahead and create a constant to give to that user.

This might then reduce the instruction to having a single use and allow additional optimizations on the other path.

This picks up an additional transformation that the patch for D31120 didn't catch.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Mar 31 2017, 2:59 PM

Add the test case update. The first 3 of them are the same as D31120

spatel accepted this revision.Apr 12 2017, 8:00 AM

LGTM. It would be nice to lift everything in the:

if (Depth != 0 && !I->hasOneUse()) {

block into a helper function to make it easier to read as an NFC change ahead of this. SimplifyDemandedUseBits has grown to over 700 lines.

This revision is now accepted and ready to land.Apr 12 2017, 8:00 AM
This revision was automatically updated to reflect the committed changes.