OSDN Git Service

[SimpleLoopUnswitch] partial unswitch needs to be careful when replacing invariants...
authorFedor Sergeev <fedor.sergeev@azul.com>
Wed, 7 Nov 2018 20:05:11 +0000 (20:05 +0000)
committerFedor Sergeev <fedor.sergeev@azul.com>
Wed, 7 Nov 2018 20:05:11 +0000 (20:05 +0000)
commit3a7cf3b32fb1dab03835b36cbc5c9adc07c6bab7
tree6cc2fed38fd1248017ba25b546af8a1651c76f77
parent24b118cefd35887c024042b75fc2d91af7533ec4
[SimpleLoopUnswitch] partial unswitch needs to be careful when replacing invariants with constants

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.

Reviewers: chandlerc, asbirlea
Differential Revision: https://reviews.llvm.org/D54211

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346350 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch.ll