]> granicus.if.org Git - llvm/commit
[JumpThreading] Fix threading with unusual PHI nodes.
authorEli Friedman <efriedma@quicinc.com>
Wed, 3 Jul 2019 23:12:39 +0000 (23:12 +0000)
committerEli Friedman <efriedma@quicinc.com>
Wed, 3 Jul 2019 23:12:39 +0000 (23:12 +0000)
commit33f3187acfff25bd861da4598c57ff0214f9110c
treed24cd94ecbbf209f0fb7f0b3349d8b0c5f9d284f
parentd562a5618a25148f272dfd2dfceb6e9688ed2d48
[JumpThreading] Fix threading with unusual PHI nodes.

If the block being cloned contains a PHI node, in general, we need to
clone that PHI node, even though it's trivial. If the operand of the PHI
is an instruction in the block being cloned, the correct value for the
operand doesn't exist until SSAUpdater constructs it.

We usually don't hit this issue because we try to avoid threading across
loop headers, but it's possible to hit this in some cases involving
irreducible CFGs.  I added a flag to allow threading across loop headers
to make the testcase easier to understand.

Thanks to Brian Rzycki for reducing the testcase.

Fixes https://bugs.llvm.org/show_bug.cgi?id=42085.

Differential Revision: https://reviews.llvm.org/D63913

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365094 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/loop-phi.ll [new file with mode: 0644]
test/Transforms/JumpThreading/lvi-tristate.ll
test/Transforms/JumpThreading/select.ll
test/Transforms/JumpThreading/thread-loads.ll