[InstCombine] PHI-aware aggregate reconstruction: correctly detect "use" basic block
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 17 Aug 2020 20:15:30 +0000 (23:15 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 17 Aug 2020 21:45:18 +0000 (00:45 +0300)
commit03127f795b8244c1039c18d4391374707a3dc75e
treed5ed41d316daa97a3cde52c277da109bda783151
parentf4f673e0e36937954c2410b2dfd5ca8e39ccffa5
[InstCombine] PHI-aware aggregate reconstruction: correctly detect "use" basic block

While the original implementation added in D85787 / ae7f08812e0995481eb345cecc5dd4529829ba44
is not incorrect, it is known to be suboptimal.

In particular, it is not incorrect to use the basic block
in which the original `insertvalue` instruction is located
as the merge point, that is not necessarily optimal,
as `@test6` shows.

We should look at all the AggElts, and, if they are all defined
in the same basic block, then that is the basic block we should use.

On RawSpeed library, this catches +4% (+50) more cases.
On vanilla LLVM test-suits, this catches +12% (+92) more cases.
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/phi-aware-aggregate-reconstruction.ll