This is an archive of the discontinued LLVM Phabricator instance.

Revert "[InstCombine] Hoist xor-by-constant from xor-by-value"
AbandonedPublic

Authored by bgraur on Dec 28 2020, 5:13 AM.

Details

Summary

Changes in commit d9ebaeeb468d6a8f29eb479f18d2790f7efb8565 cause the
compiler to enter an infinite loop.

This reverts commit d9ebaeeb468d6a8f29eb479f18d2790f7efb8565.

Diff Detail

Event Timeline

bgraur created this revision.Dec 28 2020, 5:13 AM
bgraur requested review of this revision.Dec 28 2020, 5:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2020, 5:13 AM
This revision is now accepted and ready to land.Dec 28 2020, 5:15 AM
lebedev.ri requested changes to this revision.Dec 28 2020, 5:17 AM

Reproducer?

This revision now requires changes to proceed.Dec 28 2020, 5:17 AM

@lebedev.ri: I'll need some time to localize and minimize a test for this.
The infinite loop occurs while compiling an internal source file @Google while validating the upstream.

Is it OK for you to send you this later (this evening or tomorrow)?

It would be best to have the reproducer beforehand.
Usually it should be fine to just dump the whole module's IR
in InstCombinerImpl::run() as the first thing in that loop,
save the IR that is clearly stuck within the inf combine loop,
and feed it to llvm-reduce..

bgraur added a comment.EditedDec 28 2020, 7:44 AM

Here's a small repro:

#include <cstdint>

static int v;

void foo(unsigned char x[2]) {
  x[0] = static_cast<unsigned char>(reinterpret_cast<uintptr_t>(&v));
  x[1] = ~static_cast<unsigned char>(0);

  for (int i = 0; i < 2; i++) {
    unsigned char s0 = x[0];
    unsigned char s1 = x[1];
    s1 ^= s0;
    x[0] = s1 ^ (s1 << 1);
    x[1] = (s1 << 4) | (s1 >> 4);
  }
}
SureYeaah requested changes to this revision.Dec 28 2020, 7:57 AM
SureYeaah accepted this revision.

Yep, as i expected, constant expressions as usual.
Let me just fix this instead.

How about submitting this revert and you work on the fix separately?
If another problem is added with the fix reverting will be harder.

Thank you very much for the reproducer!
Fixed in d4ccef38d0bbcd70f56d586b4dfc988db863e388
Sorry for the trouble!

bgraur abandoned this revision.Dec 29 2020, 5:12 AM

Roman fixed forward the cause of the infinite loop.
This revert is no longer necessary.