[DAGCombine] matchBinOpReduction - add partial reduction matching
commit8acd141e45ee105fc45a9812ef2d1de29bdc8757
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 24 Jul 2019 17:29:56 +0000 (24 17:29 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 24 Jul 2019 17:29:56 +0000 (24 17:29 +0000)
treec868d1ac3a6e36e6d800abb76bb8fe7825e93053
parentd0d41de2fb8b8c8b73d4b298f59af2a88d87be89
[DAGCombine] matchBinOpReduction - add partial reduction matching

This patch adds support for recognizing cases where a larger vector type is being used to reduce just the elements in the lower subvector:

e.g. <8 x i32> reduction pattern in a <16 x i32> vector:

<4,5,6,7,u,u,u,u,u,u,u,u,u,u,u,u>
<2,3,u,u,u,u,u,u,u,u,u,u,u,u,u,u>
<1,u,u,u,u,u,u,u,u,u,u,u,u,u,u,u>

matchBinOpReduction returns the lower extracted subvector in such cases, assuming isExtractSubvectorCheap accepts the extraction.

I've only enabled it for X86 reduction sums so far. I intend to enable it for the bitop/minmax cases in future patches, and eventually I think its worth turning it on all the time. This is mainly just a case of ensuring calls to matchBinOpReduction don't make assumptions on the vector width based on the original vector extraction.

Fixes the x86 partial reduction sum cases in PR33758 and PR42023.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366933 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/phaddsub-extract.ll