This is an archive of the discontinued LLVM Phabricator instance.

[SimpleLoopUnswitch] Freeze individual OR/AND operands.
ClosedPublic

Authored by fhahn on Apr 27 2022, 1:51 PM.

Details

Summary

In some cases, it is not enough to freeze the final AND/OR operation
when chaining a number of invariant conditions together.

After creating a chain of ANDs/ORs, we assume all unswitched operands to
be either true or false. But if any of the operands is poison, the rest
of the operands could have any value after branching on the frozen
condition.

To avoid that, freeze individual operands, if needed. In some cases this
may lead to unnecessary freezes, but it seems required at least for some
cases (see trivial-unswitch-freeze-individual-conditions.ll)

Diff Detail

Event Timeline

fhahn created this revision.Apr 27 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 1:51 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn requested review of this revision.Apr 27 2022, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2022, 1:51 PM
nikic accepted this revision.Apr 28 2022, 1:05 PM

LGTM

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
215

nit: unnecessary braces

This revision is now accepted and ready to land.Apr 28 2022, 1:05 PM
fhahn updated this revision to Diff 426291.May 1 2022, 5:01 AM

Rebased so it can be applied before D124526.

This revision was landed with ongoing or failed builds.May 1 2022, 12:11 PM
This revision was automatically updated to reflect the committed changes.