[PATCH] D124526: [SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 06:09:12 PDT 2022


fhahn created this revision.
fhahn added reviewers: asbirlea, reames, nlopes, nikic, aqjune.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.

After D97756 <https://reviews.llvm.org/D97756>, collectHomogenousInstGraphLoopInvariants may collect
conditions for both logical ANDs and logical ORs in case the root is a
select that matches both logical AND & OR.

This means the function won't return invariant values of either AND/OR
chains, but both. This can result in incorrect transformations.

See llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch-logical-and-or.ll.
Without the patch, Alive2 rejects the modified tests with:

  Source and target don't have the same return domain.

Note that this also applies to the test case added in D97756 <https://reviews.llvm.org/D97756>
(@test_partial_condition_unswitch_or_select). We can't unswitch on
%cond6, because the graph leading to it contains and AND and an OR.

This only fixes trivial unswitching for now, but a similar problem
likely exists with non-trivial unswitching.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124526

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch-logical-and-or.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124526.425503.patch
Type: text/x-patch
Size: 10085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220427/c314fe45/attachment.bin>


More information about the llvm-commits mailing list