This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] don't assert that InstSimplify has removed a known true/false cmp (PR34838)
AbandonedPublic

Authored by spatel on Oct 5 2017, 12:16 PM.

Details

Summary

InstSimplify uses computeKnownBits() to prove that the low bits of a shifted-left value are zeros. Therefore, a cmp with constant with low set bits must be true or false.

In the normal case, it's safe for InstCombine to assert that, but computeKnownBits() bails out when confronted with poison (undef?):

// If there is conflict between Known.Zero and Known.One, this must be an
// overflowing left shift, so the shift result is undefined. Clear Known
// bits so that other code could propagate this undef.

...so I don't think InstCombine can assert as much we'd like. We have to check preconditions at runtime instead.

Diff Detail

Event Timeline

spatel created this revision.Oct 5 2017, 12:16 PM

I've posted an alternate way to solve this in D38637. If that looks better, I'll abandon this patch.

spatel abandoned this revision.Oct 7 2017, 9:02 AM

Abandoning - we can fix this ahead of InstCombine and retain our asserts.