This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Canonicalize icmp eq pow2 more thoroughly

Authored by nikic on Mar 15 2023, 9:11 AM.



We currently already canonicalize icmp eq (%x & Pow2), Pow2 to icmp ne (%x & Pow2), 0. This patch generalizes the fold based on known bits.

In particular, this allows us to handle comparisons against !range !{i64 0, i64 2} loads, which addresses an optimization regression in Rust caused by

Diff Detail

Event Timeline

nikic created this revision.Mar 15 2023, 9:11 AM
nikic requested review of this revision.Mar 15 2023, 9:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 9:11 AM
goldstein.w.n accepted this revision.Mar 15 2023, 2:02 PM



nit: "is" -> "is known to be".
also maybe "Pow2" -> "C_Pow2" so its a little clearer to you are refering to the exact same value.

This revision is now accepted and ready to land.Mar 15 2023, 2:02 PM
This revision was automatically updated to reflect the committed changes.