OSDN Git Service

[LV] Pick vector loop body as insert point for SCEV expansion.
authorFlorian Hahn <flo@fhahn.com>
Fri, 10 Jul 2020 08:45:02 +0000 (09:45 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 10 Jul 2020 09:37:12 +0000 (10:37 +0100)
commit264ab1e2c815728ede5d1fce257abbd04044cc27
treeaec2a2d0e7c9c4d55d4ce7bfbd56ed2e29eedcfc
parentcf40db21af489e3e5bc1c39cea855cc068c4ce48
[LV] Pick vector loop body as insert point for SCEV expansion.

Currently the DomTree is not kept up to date for additional blocks
generated in the vector loop, for example when vectorizing with
predication. SCEVExpander relies on dominance checks when looking for
existing instructions to re-use and in some cases that can lead to the
expander picking instructions that do not actually dominate their insert
point (e.g. as in PR46525).

Unfortunately keeping the DT up-to-date is a bit tricky, because the CFG
is only patched up after generating code for a block. For now, we can
just use the vector loop header, as this ensures the inserted
instructions dominate all uses in the vector loop. There should be no
noticeable impact on the generated code, as other passes should sink
those instructions, if profitable.

Fixes PR46525.

Reviewers: Ayal, gilr, mkazantsev, dmgreen

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D83288
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/pr46525-expander-insertpoint.ll [new file with mode: 0644]