OSDN Git Service

[SLP] Make sure instructions are ordered when computing spill cost.
authorFlorian Hahn <flo@fhahn.com>
Fri, 3 Jul 2020 16:28:45 +0000 (17:28 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 3 Jul 2020 16:30:17 +0000 (17:30 +0100)
commiteb46137daa92723b75d828f2db959f2061612622
treecaef43d90dfaf4ee99dd95f187d39a253c9836b7
parent9e03547cab691521ea3be9dab0b543156ce44c04
[SLP] Make sure instructions are ordered when computing spill cost.

The entries in VectorizableTree are not necessarily ordered by their
position in basic blocks. Collect them and order them by dominance so
later instructions are guaranteed to be visited first. For instructions
in different basic blocks, we only scan to the beginning of the block,
so their order does not matter, as long as all instructions in a basic
block are grouped together. Using dominance ensures a deterministic order.

The modified test case contains an example where we compute a wrong
spill cost (2) without this patch, even though there is no call between
any instruction in the bundle.

This seems to have limited practical impact, .e.g on X86 with a recent
Intel Xeon CPU with -O3 -march=native -flto on MultiSource,SPEC2000,SPEC2006
there are no binary changes.

Reviewers: craig.topper, RKSimon, xbolva00, ABataev, spatel

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D82444
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/spillcost-order.ll