[PATCH] D54211: [SimpleLoopUnswitch] partial unswitch needs to be careful when replacing invariants with constants

Fedor Sergeev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 08:23:29 PST 2018


fedor.sergeev created this revision.
fedor.sergeev added reviewers: chandlerc, mkazantsev, asbirlea, reames.

When partial unswitch operates on multiple conditions at once, .e.g:

  if (Cond1 || Cond2 || NonInv) ...

it should infer (and replace) values for individual conditions only on one
side of unswitch and not another.

More precisely only these derivations hold true:

  (Cond1 || Cond2) == false  =>  Cond1 == Cond2 == false
  (Cond1 && Cond2) == true   =>  Cond1 == Cond2 == true

By the way we organize unswitching it means only replacing on "continue" blocks
and never on "unswitched" ones. Since trivial unswitch does not have "unswitched"
blocks it does not have this problem.

Fixes PR 39568.


Repository:
  rL LLVM

https://reviews.llvm.org/D54211

Files:
  lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll
  test/Transforms/SimpleLoopUnswitch/partial-unswitch-PR39568.ll
  test/Transforms/SimpleLoopUnswitch/trivial-unswitch-PR39568.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54211.172964.patch
Type: text/x-patch
Size: 13493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181107/ffee280c/attachment.bin>


More information about the llvm-commits mailing list