This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Generalize and-reduce pattern to handle `ne` case as well as `eq`
ClosedPublic

Authored by mkazantsev on Jan 27 2022, 9:38 PM.

Details

Summary

Following Sanjay's proposal from discussion in D118317, this patch
generalizes and-reduce handling to fold the following pattern

icmp ne (bitcast(icmp ne (lhs, rhs)), 0)

into

icmp ne (bitcast(lhs), bitcast(rhs))

https://alive2.llvm.org/ce/z/WDcuJ_

Diff Detail

Event Timeline

mkazantsev created this revision.Jan 27 2022, 9:38 PM
mkazantsev requested review of this revision.Jan 27 2022, 9:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2022, 9:38 PM
lebedev.ri edited the summary of this revision. (Show Details)Jan 28 2022, 12:27 AM
lebedev.ri edited the summary of this revision. (Show Details)Jan 28 2022, 12:35 AM

That's a yet another pattern ((x == y) != -1 --> x != y), while here you have (x != y) != 0 --> x != y,
i.e. https://alive2.llvm.org/ce/z/WDcuJ_

lebedev.ri edited the summary of this revision. (Show Details)Jan 28 2022, 12:38 AM
lebedev.ri accepted this revision.Jan 28 2022, 12:42 AM

LG modulo wrong proof :)
I believe there are some more patterns like that, let me know if can't come up with them.

This revision is now accepted and ready to land.Jan 28 2022, 12:42 AM

I'm sure there should be more of this kind. Interestingly, analogous test for reduction-and-sext-zext-i1.ll works even w/o this change, which means we might have some other transform missing something.

This revision was landed with ongoing or failed builds.Jan 30 2022, 9:14 PM
This revision was automatically updated to reflect the committed changes.