[X86] Add target combine rules for horizontal add/sub.
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 9 Jun 2014 16:54:41 +0000 (16:54 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 9 Jun 2014 16:54:41 +0000 (16:54 +0000)
commit9b6992ddc272e4c7a3e15bfb5924c4e62c46fa65
tree19fdfe3cc19166e1c4b0aa07aba61625c89a32a7
parent1968da36ed044f0ad87cfc3614be9e48ac9cdd98
[X86] Add target combine rules for horizontal add/sub.

This patch adds new target specific combine rules to identify horizontal
add/sub idioms from BUILD_VECTOR dag nodes.

This patch also teaches the DAGCombiner how to canonicalize sequences of
insert_vector_elt dag nodes according to the following rule:

  (insert_vector_elt (insert_vector_elt A, I0), I1) ->
    (insert_vecto_elt (insert_vector_elt A, I1), I0)

This new canonicalization rule only triggers if the inner insert_vector
dag node has exactly one use; also, both indices must be known constants,
and I1 < I0.
This last rule made it possible to write a simpler algorithm to identify
horizontal add/sub patterns because now we don't have to worry about the
ordering of insert_vector_elt dag nodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210477 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/haddsub-2.ll [new file with mode: 0644]