[GVN PRE] Patch the source for Phi node in PRE
authorSerguei Katkov <serguei.katkov@azul.com>
Thu, 9 Nov 2017 06:02:18 +0000 (06:02 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Thu, 9 Nov 2017 06:02:18 +0000 (06:02 +0000)
commit722339e40562003b4d32693fa568e98ab38da831
tree072c513ef592c02c374b477db5648aeb9187ff64
parent3ac31d445313f491e1349b4914c36c57c56671b0
[GVN PRE] Patch the source for Phi node in PRE

We must patch all existing incoming values of Phi node,
otherwise it is possible that we can see poison
where program does not expect to see it.

This is the similar what GVN does.

The added test test/Transforms/GVN/PRE/pre-jt-add.ll shows an
example of wrong optimization done by jump threading due to
GVN PRE did not patch existing incoming value.

Reviewers: mkazantsev, wmi, dberlin, davide
Reviewed By: dberlin
Subscribers: efriedma, llvm-commits
Differential Revision: https://reviews.llvm.org/D39637

llvm-svn: 317768
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/GVN/PRE/pre-jt-add.ll [new file with mode: 0644]
llvm/test/Transforms/GVN/PRE/pre-poison-add.ll [new file with mode: 0644]