InstCombine: Remove infinite loop caused by FoldOpIntoPhi
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 3 Nov 2014 21:55:12 +0000 (21:55 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 3 Nov 2014 21:55:12 +0000 (21:55 +0000)
commitc671375e8eaff8e91c37ac7621c84a9373923ecd
tree7db5e7a512a597a3833c4ae972622c296801032f
parentfcd4288009f1829ab4c5a4ea23883a437b220850
InstCombine: Remove infinite loop caused by FoldOpIntoPhi

FoldOpIntoPhi could create an infinite loop if the PHI could potentially
reach a BB it was considering inserting instructions into.  The
instructions it would insert would eventually lead to other combines
firing which would, again, lead to FoldOpIntoPhi firing.

The solution is to handicap FoldOpIntoPhi so that it doesn't attempt to
insert instructions that the PHI might reach.

This fixes PR21377.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221187 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/fold-phi.ll
test/Transforms/InstCombine/pr12338.ll