BBVectorize: Choose pair ordering to minimize shuffles
authorHal Finkel <hfinkel@anl.gov>
Wed, 31 Oct 2012 15:17:07 +0000 (15:17 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 31 Oct 2012 15:17:07 +0000 (15:17 +0000)
commit72465ea23d010507d3746adc126d719005981e05
treed5e6b1ad3aad528df1c41d88c82db6a62ba61ca4
parentef026f1b5e4d52e11c67a1a5ad01eadffcfa4d8e
BBVectorize: Choose pair ordering to minimize shuffles

BBVectorize would, except for loads and stores, always fuse instructions
so that the first instruction (in the current source order) would always
represent the low part of the input vectors and the second instruction
would always represent the high part. This lead to too many shuffles
being produced because sometimes the opposite order produces fewer of them.

With this change, BBVectorize tracks the kind of pair connections that form
the DAG of candidate pairs, and uses that information to reorder the pairs to
avoid excess shuffles. Using this information, a future commit will be able
to add VTTI-based shuffle costs to the pair selection procedure. Importantly,
the number of remaining shuffles can now be estimated during pair selection.

There are some trivial instruction reorderings in the test cases, and one
simple additional test where we certainly want to do a reordering to
avoid an unnecessary shuffle.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167122 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/BBVectorize.cpp
test/Transforms/BBVectorize/X86/loop1.ll
test/Transforms/BBVectorize/X86/simple.ll
test/Transforms/BBVectorize/cycle.ll
test/Transforms/BBVectorize/loop1.ll
test/Transforms/BBVectorize/search-limit.ll
test/Transforms/BBVectorize/simple-int.ll
test/Transforms/BBVectorize/simple-ldstr.ll
test/Transforms/BBVectorize/simple-sel.ll
test/Transforms/BBVectorize/simple.ll