[PATCH] D33928: [LoopStrengthReduction] Treat SCEVUnknown pessimistically in LSR
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 00:50:03 PDT 2017
mkazantsev created this revision.
Herald added subscribers: javed.absar, mzolotukhin.
When evaluating formulae for LSR, we sometimes may have SCEVUnknown included
into the expression. When we try to make a fixup for an instruction outside the loop
and this SCEVUnknown is loop-variant, we are unable to duplicate/sink its s out of loop.
We must reuse the instruction from the loop after fixup. As result, it will not be trivially
dead for sure. We are also unable to evaluate the number of other instructions that will
also not become dead, because they are still used by it. This makes our reasoning about
profitability of application of the formula misleading.
On the other hand, while doing this transformation, we may create LSR IV Phis in the loop,
thus increasing the code. These new Phis will also be (likely) not dead. As result, this
misleading choise of a formula ends up with code increase without any benefits. This only
leads to performance, compile time and code size degradations.
The examples of tests where the LSR only produces new instructions inside and ouside the
loop are demonstrated in the attached test.
To avoid this situation, this patch changes LSR cost model so that it rejects formulae with
registers that include loop-variant SCEVUnknown values if they require at least one fixup
outside the loop.
https://reviews.llvm.org/D33928
Files:
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/CodeGen/ARM/arm-and-tst-peephole.ll
test/Transforms/LoopStrengthReduce/X86/reject-scev-unknown.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33928.101518.patch
Type: text/x-patch
Size: 11890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170606/7b1e978f/attachment.bin>
More information about the llvm-commits
mailing list