This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix known bits handling in SimplifyDemandedUseBits
ClosedPublic

Authored by nikic on Mar 7 2020, 4:42 AM.

Details

Summary

Fixes a regression from D75801. SimplifyDemandedUseBits() is also supposed to compute the known bits (of the demanded subset) of the instruction. For unknown instructions it does so by directly calling computeKnownBits(). For known instructions it will compute known bits itself. However, for instructions where only some cases are handled directly (e.g. a constant shift amount) the known bits invocation for the unhandled case is sometimes missing. This patch adds the missing calls and thus removes the main discrepancy with ExpensiveCombines mode.

Diff Detail

Event Timeline

nikic created this revision.Mar 7 2020, 4:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2020, 4:42 AM
nikic marked 4 inline comments as done.Mar 7 2020, 4:47 AM

Some comments on the intrinsics code, as it did some weird things before...

lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
719 ↗(On Diff #248922)

Despite what the comment says, this was already computing known bits, because the "break" falls through to the call below.

752 ↗(On Diff #248922)

While known bits were computed explicitly here, this break would still fall through to the known bits call below, and thus recompute the result from scratch.

781 ↗(On Diff #248922)

This return nullptr skipped the bit of code for returning a constant integer below.

790 ↗(On Diff #248922)

To avoid the three issues mentioned above, I'm now explicitly tracking whether known bits were computed or not for the call.

spatel accepted this revision.Mar 7 2020, 7:23 AM

LGTM

This revision is now accepted and ready to land.Mar 7 2020, 7:23 AM
This revision was automatically updated to reflect the committed changes.