[LoopVectorize] Add Support for Small Size Reductions.
authorChad Rosier <mcrosier@codeaurora.org>
Thu, 27 Aug 2015 14:12:17 +0000 (14:12 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Thu, 27 Aug 2015 14:12:17 +0000 (14:12 +0000)
commited15c79fb68d40c5980f926b90b5a614080b8245
tree2d1cb7305ac0f96f65a071c3017095b9200e717b
parent18671a3a8f128ec934fb0345ba6a1960ed78196c
[LoopVectorize] Add Support for Small Size Reductions.

Unlike scalar operations, we can perform vector operations on element types that
are smaller than the native integer types. We type-promote scalar operations if
they are smaller than a native type (e.g., i8 arithmetic is promoted to i32
arithmetic on Arm targets). This patch detects and removes type-promotions
within the reduction detection framework, enabling the vectorization of small
size reductions.

In the legality phase, we look through the ANDs and extensions that InstCombine
creates during promotion, keeping track of the smaller type. In the
profitability phase, we use the smaller type and ignore the ANDs and extensions
in the cost model. Finally, in the code generation phase, we truncate the result
of the reduction to allow InstCombine to rewrite the entire expression in the
smaller type.

This fixes PR21369.
http://reviews.llvm.org/D12202

Patch by Matt Simpson <mssimpso@codeaurora.org>!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246149 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/LoopUtils.h
lib/Transforms/Utils/LoopUtils.cpp
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/reduction-small-size.ll [new file with mode: 0644]