GVN-hoist: fix hoistingFromAllPaths for loops (PR29034)
authorSebastian Pop <sebpop@gmail.com>
Thu, 25 Aug 2016 11:55:47 +0000 (11:55 +0000)
committerSebastian Pop <sebpop@gmail.com>
Thu, 25 Aug 2016 11:55:47 +0000 (11:55 +0000)
commit5f0d0e60d11b8d2e48aacf31a82762280f9a8712
tree42db4b0d0335a43a2b63e682b7c8326cf7f31be6
parent331fb804c96008bbceec8e5f305fc27f06d58ba6
GVN-hoist: fix hoistingFromAllPaths for loops (PR29034)

It is invalid to hoist stores or loads if they are not executed on all paths
from the hoisting point to the exit of the function. In the testcase, there are
paths in the loop that do not execute the stores or the loads, and so hoisting
them within the loop is unsafe.

The problem is that the current implementation of hoistingFromAllPaths is
incomplete: it walks all blocks dominated by the hoisting point, and does not
return false when the loop contains a path on which the hoisted ld/st is
not executed.

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

llvm-svn: 279732
llvm/lib/Transforms/Scalar/GVNHoist.cpp
llvm/test/Transforms/GVNHoist/pr29031.ll [new file with mode: 0644]
llvm/test/Transforms/GVNHoist/pr29034.ll [new file with mode: 0644]