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)
commit842ad0b621b3c89a0bf1b505c4ce99b292ba8602
tree5b06a7679a987dd08a7bc14d4f71d9c6d88b217c
parent09acdb9a160eec044a7a78f3e770e50e5b7d914a
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.

llvm-svn: 167122
llvm/lib/Transforms/Vectorize/BBVectorize.cpp
llvm/test/Transforms/BBVectorize/X86/loop1.ll
llvm/test/Transforms/BBVectorize/X86/simple.ll
llvm/test/Transforms/BBVectorize/cycle.ll
llvm/test/Transforms/BBVectorize/loop1.ll
llvm/test/Transforms/BBVectorize/search-limit.ll
llvm/test/Transforms/BBVectorize/simple-int.ll
llvm/test/Transforms/BBVectorize/simple-ldstr.ll
llvm/test/Transforms/BBVectorize/simple-sel.ll
llvm/test/Transforms/BBVectorize/simple.ll