summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MIRPrinter.cpp
diff options
context:
space:
mode:
authorCong Hou <congh@google.com>2015-11-24 05:44:19 +0000
committerCong Hou <congh@google.com>2015-11-24 05:44:19 +0000
commitbed60d35ed332f12a7c54eb16e59b69adb5d8c15 (patch)
tree44020f50bbb10215241bea640004e32eea66749c /llvm/lib/CodeGen/MIRPrinter.cpp
parentd68ba4255627a31196d13e6cde0568f643bd94d7 (diff)
downloadbcm5719-llvm-bed60d35ed332f12a7c54eb16e59b69adb5d8c15.tar.gz
bcm5719-llvm-bed60d35ed332f12a7c54eb16e59b69adb5d8c15.zip
[X86][SSE] Detect AVG pattern during instruction combine for SSE2/AVX2/AVX512BW.
This patch detects the AVG pattern in vectorized code, which is simply c = (a + b + 1) / 2, where a, b, and c have the same type which are vectors of either unsigned i8 or unsigned i16. In the IR, i8/i16 will be promoted to i32 before any arithmetic operations. The following IR shows such an example: %1 = zext <N x i8> %a to <N x i32> %2 = zext <N x i8> %b to <N x i32> %3 = add nuw nsw <N x i32> %1, <i32 1 x N> %4 = add nuw nsw <N x i32> %3, %2 %5 = lshr <N x i32> %N, <i32 1 x N> %6 = trunc <N x i32> %5 to <N x i8> and with this patch it will be converted to a X86ISD::AVG instruction. The pattern recognition is done when combining instructions just before type legalization during instruction selection. We do it here because after type legalization, it is much more difficult to do pattern recognition based on many instructions that are doing type conversions. Therefore, for target-specific instructions (like X86ISD::AVG), we need to take care of type legalization by ourselves. However, as X86ISD::AVG behaves similarly to ISD::ADD, I am wondering if there is a way to legalize operands and result types of X86ISD::AVG together with ISD::ADD. It seems that the current design doesn't support this idea. Tests are added for SSE2, AVX2, and AVX512BW and both i8 and i16 types of variant vector sizes. Differential revision: http://reviews.llvm.org/D14761 llvm-svn: 253952
Diffstat (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud