[IPSCCP] Run Solve each time we resolved an undef in a function.
authorFlorian Hahn <florian.hahn@arm.com>
Tue, 17 Jul 2018 14:04:59 +0000 (14:04 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Tue, 17 Jul 2018 14:04:59 +0000 (14:04 +0000)
commitd95761d9d08340b641225b2cf6d397a06db29137
tree1a0594e08c559e24a03d4fccd91aff8d3ee0b7ff
parentf41dd122d67ee45007e8f26142ad34fec622d748
[IPSCCP] Run Solve each time we resolved an undef in a function.

Once we resolved an undef in a function we can run Solve, which could
lead to finding a constant return value for the function, which in turn
could turn undefs into constants in other functions that call it, before
resolving undefs there.

Computationally the amount of work we are doing stays the same, just the
order we process things is slightly different and potentially there are
a few less undefs to resolve.

We are still relying on the order of functions in the IR, which means
depending on the order, we are able to resolve the optimal undef first
or not. For example, if @test1 comes before @testf, we find the constant
return value of @testf too late and we cannot use it while solving
@test1.

This on its own does not lead to more constants removed in the
test-suite, probably because currently we have to be very lucky to visit
applicable functions in the right order.

Maybe we manage to come up with a better way of resolving undefs in more
'profitable' functions first.

Reviewers: efriedma, mssimpso, davide

Reviewed By: efriedma, davide

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

llvm-svn: 337283
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll [new file with mode: 0644]
llvm/test/Transforms/SCCP/ipsccp-basic.ll