Page MenuHomePhabricator

[InstCombine] Don't replace musttail result based on known bits
ClosedPublic

Authored by nikic on Thu, Mar 19, 2:57 PM.

Details

Summary

This is the same change as D75824, but for two cases where InstCombine performs the same optimization: Replacing an instructions whose bits are fully known with a constant. This is not (generally) legal for musttail calls.

I was wondering whether we should be preventing this somehow directly in computeKnownBits(), but it seemed pretty odd to me to add a check in the analysis to return a worse result if musttail is used...

Diff Detail

Event Timeline

nikic created this revision.Thu, Mar 19, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Mar 19, 2:57 PM
jdoerfert accepted this revision.Thu, Mar 19, 5:40 PM

LGTM. Thanks for following up on this.

I was wondering whether we should be preventing this somehow directly in computeKnownBits(), but it seemed pretty odd to me to add a check in the analysis to return a worse result if musttail is used...

I don't think so, your approach is better. Other users of computeKnownBits might be able to use the result even though it is a returned must-tail call, e.g., if the user is inter-procedrual.

This revision is now accepted and ready to land.Thu, Mar 19, 5:40 PM
This revision was automatically updated to reflect the committed changes.