This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Support one-hot merge for logical and/or
ClosedPublic

Authored by nikic on May 11 2021, 2:31 PM.

Details

Summary

If a logical and/or is used, we need to be careful not to propagate a potential poison value from the RHS by inserting a freeze instruction. Otherwise it works the same way as bitwise and/or.

This is intended to address the regression reported at https://reviews.llvm.org/D101191#2751002.

Diff Detail

Event Timeline

nikic created this revision.May 11 2021, 2:31 PM
nikic requested review of this revision.May 11 2021, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2021, 2:31 PM
nikic added inline comments.May 11 2021, 2:42 PM
llvm/test/Transforms/InstCombine/onehot_merge.ll
69–73

As a side-note, it would probably make sense to push freeze instructions through one-use non-canCreateUndefOrPoison instructions. 1 << freeze(x) is better than freeze(1 << x).

spatel accepted this revision.May 11 2021, 2:45 PM

LGTM

This revision is now accepted and ready to land.May 11 2021, 2:45 PM
This revision was automatically updated to reflect the committed changes.

@nikic this fixed the regression, thank you!