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)
commit7e2b9882b147bf9c26faa7b04b56884ec444bd64
tree23aee4ea62f1aa2200f2f7c7e08d3d842469a220
parent542616d47c5533a338e54db76dc99765410065ef
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.

llvm-svn: 221187
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/fold-phi.ll
llvm/test/Transforms/InstCombine/pr12338.ll