This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Provide a way to calculate KnownZero/One for Add/Sub in SimplifyDemandedUseBits without recursing into ComputeKnownBits
AbandonedPublic

Authored by craig.topper on Mar 18 2017, 12:17 AM.

Details

Summary

SimplifyDemandedUseBits for Add/Sub already recursed down LHS and RHS for simplifying bits. If that didn't provide any simplifications we fall back to calling computeKnownBits which will recurse again. Instead just take the known bits for LHS and RHS we already have and call into a new function in ValueTracking that can calculate the known bits given the LHS/RHS bits.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 18 2017, 12:17 AM
spatel added inline comments.Mar 21 2017, 3:55 PM
lib/Analysis/ValueTracking.cpp
309

Can we call these params RHSKnownZero and RHSKnownOne at this point?

lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
552–555

"commute" confused me here. "compute"?
As in:
Compute more known bits based on the existing known bits and the fact that this is an add/sub.

craig.topper added inline comments.Mar 21 2017, 4:04 PM
lib/Analysis/ValueTracking.cpp
309

They don't contain the RHS known bits at the start of the call so it could be misleading. We're only passing it in because computeKnownBits preallocated them and we want to reuse that.

lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
552–555

Typo. Maybe I've spent too much time commuting instructions in the backend.

Fix comment

spatel accepted this revision.Mar 24 2017, 7:12 AM

LGTM.

This revision is now accepted and ready to land.Mar 24 2017, 7:12 AM
craig.topper abandoned this revision.Mar 25 2017, 9:09 PM