This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just the special case that doesn't use computeKnownBits.
ClosedPublic

Authored by craig.topper on Aug 11 2018, 9:51 PM.

Details

Summary

computeKnownBits is expensive. The cases that would be detected by the computeKnownBits portion of haveNoCommonBitsSet were already handled by the earlier call to SimplifyDemandedInstructionBits.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Aug 11 2018, 9:51 PM
lebedev.ri accepted this revision.Aug 12 2018, 12:29 AM

This is a NFC, right?

I suppose it makes sense. I kinda hoped inlining would have taken care of it.
There may be a similar case in the visitAdd().

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
2513 ↗(On Diff #160250)

s/it/is/

2517–2520 ↗(On Diff #160250)

Here this could be

if (match(&I, m_c_Xor(m_c_And(m_Not(m_Value(M)), m_Value()), 
                      m_c_And(m_Deferred(M), m_Value()))))
This revision is now accepted and ready to land.Aug 12 2018, 12:29 AM

We don't currently turn Add into Or inside SimplifyDemandedBits so visitAdd doesn't have this issue. I'm a little skeptical that we should be aggressively turning adds into ors. I plan to start an llvm-dev thread on that.

I believe this is NFC based on my understanding of SimplifyDemandedInstructionBits and haveNoCommonBitSet.

This revision was automatically updated to reflect the committed changes.