[PPC64LE] Remove unnecessary swaps from lane-insensitive vector computations
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Mon, 27 Apr 2015 19:57:34 +0000 (19:57 +0000)
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>
Mon, 27 Apr 2015 19:57:34 +0000 (19:57 +0000)
commitdcc4f724cc3b8ff4d717bc602c8840b4f2929901
treeb678153518e4a473f1aa9ff9e3819ec91ad52b29
parent267cdc080f532883ad34888ffe62438a88541a38
[PPC64LE] Remove unnecessary swaps from lane-insensitive vector computations

This patch adds a new SSA MI pass that runs on little-endian PPC64
code with VSX enabled. Loads and stores of 4x32 and 2x64 vectors
without alignment constraints are accomplished for little-endian using
lxvd2x/xxswapd and xxswapd/stxvd2x. The existence of the additional
xxswapd instructions hurts performance in comparison with big-endian
code, but they are necessary in the general case to support correct
semantics.

However, the general case does not apply to most vector code. Many
vector instructions are lane-insensitive; they do not "care" which
lanes the parallel computations are performed within, provided that
the resulting data is stored into the correct locations. Thus this
pass looks for computations that perform only lane-insensitive
operations, and remove the unnecessary swaps from loads and stores in
such computations.

Future improvements will allow computations using certain
lane-sensitive operations to also be optimized in this manner, by
modifying the lane-sensitive operations to account for the permuted
order of the lanes. However, this patch only adds the infrastructure
to permit this; no lane-sensitive operations are optimized at this
time.

This code is heavily exercised by the various vectorizing applications
in the projects/test-suite tree. For the time being, I have only added
one simple test case to demonstrate what the pass is doing. Although
it is quite simple, it provides coverage for much of the code,
including the special case handling of copies and subreg-to-reg
operations feeding the swaps. I plan to add additional tests in the
future as I fill in more of the "special handling" code.

Two existing tests were affected, because they expected the swaps to
be present, but they are now removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235910 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/CMakeLists.txt
lib/Target/PowerPC/PPC.h
lib/Target/PowerPC/PPCInstrAltivec.td
lib/Target/PowerPC/PPCInstrVSX.td
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/PowerPC/PPCVSXSwapRemoval.cpp [new file with mode: 0644]
test/CodeGen/PowerPC/swaps-le-1.ll [new file with mode: 0644]
test/CodeGen/PowerPC/vsx-ldst-builtin-le.ll
test/CodeGen/PowerPC/vsx-ldst.ll