[LV] Scalarize operands of predicated instructions
authorMatthew Simpson <mssimpso@codeaurora.org>
Wed, 7 Dec 2016 15:03:32 +0000 (15:03 +0000)
committerMatthew Simpson <mssimpso@codeaurora.org>
Wed, 7 Dec 2016 15:03:32 +0000 (15:03 +0000)
commit364da7e5270445397ef6862c7a7c1c4a0d41bf9b
treebaf7e9283c03ac4dda38db2c9fc5c13eece843ae
parent41552d6a37c8c9fb4a620b3a7164469a2cb914ac
[LV] Scalarize operands of predicated instructions

This patch attempts to scalarize the operand expressions of predicated
instructions if they were conditionally executed in the original loop. After
scalarization, the expressions will be sunk inside the blocks created for the
predicated instructions. The transformation essentially performs
un-if-conversion on the operands.

The cost model has been updated to determine if scalarization is profitable. It
compares the cost of a vectorized instruction, assuming it will be
if-converted, to the cost of the scalarized instruction, assuming that the
instructions corresponding to each vector lane will be sunk inside a predicated
block, possibly avoiding execution. If it's more profitable to scalarize the
entire expression tree feeding the predicated instruction, the expression will
be scalarized; otherwise, it will be vectorized. We only consider the cost of
the entire expression to accurately estimate the cost of the required
insertelement and extractelement instructions.

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

llvm-svn: 288909
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/aarch64-predication.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/AArch64/predication_costs.ll
llvm/test/Transforms/LoopVectorize/X86/x86-predication.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/if-pred-non-void.ll
llvm/test/Transforms/LoopVectorize/if-pred-stores.ll