This is an archive of the discontinued LLVM Phabricator instance.

InstCombine: avoid non-reducing xor combine
AbandonedPublic

Authored by t.p.northover on Aug 27 2021, 3:38 AM.

Details

Reviewers
spatel
lebedev.ri
Summary

We should only fold min(not X, C) -> not max(X, not C) if not C is as simple as C, otherwise there's a competing not max(X, not Y) -> min(not X, Y) that will form an infinite loop. Checking for a non-expr constant is a good way to do this (the fold above already takes care of C == not D so we don't lose any power that way).

Diff Detail

Event Timeline

t.p.northover created this revision.Aug 27 2021, 3:38 AM
t.p.northover requested review of this revision.Aug 27 2021, 3:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2021, 3:38 AM
lebedev.ri accepted this revision.Aug 27 2021, 4:02 AM
lebedev.ri added a subscriber: lebedev.ri.

Constant expressions are evil.
Thanks, LG.

This revision is now accepted and ready to land.Aug 27 2021, 4:02 AM
spatel accepted this revision.Aug 27 2021, 5:08 AM

LGTM - we may want to do a bulk search/replace of m_Constant() -> m_ImmConstant() to avoid these loops.

spatel requested changes to this revision.Sep 1 2021, 11:39 AM

I pushed an alternative fix with:
8a10f4a0f661a1171 ( D109058 )

So I think we can abandon this patch. If there's some constant expression variant that still escapes/loops, let me know.

This revision now requires changes to proceed.Sep 1 2021, 11:39 AM
t.p.northover abandoned this revision.Sep 3 2021, 2:59 AM

Thanks for that fix, sorry I was silent.