1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/CodeGen/PowerPC/swaps-le-5.ll
Nemanja Ivanovic f6f0a5745d [PowerPC] Canonicalize shuffles to match more single-instruction masks on LE
We currently miss a number of opportunities to emit single-instruction
VMRG[LH][BHW] instructions for shuffles on little endian subtargets. Although
this in itself is not a huge performance opportunity since loading the permute
vector for a VPERM can always be pulled out of loops, producing such merge
instructions is useful to downstream optimizations.
Since VPERM is essentially opaque to all subsequent optimizations, we want to
avoid it as much as possible. Other permute instructions have semantics that can
be reasoned about much more easily in later optimizations.

This patch does the following:
- Canonicalize shuffles so that the first element comes from the first vector
  (since that's what most of the mask matching functions want)
- Switch the elements that come from splat vectors so that they match the
  corresponding elements from the other vector (to allow for merges)
- Adds debugging messages for when a shuffle is matched to a VPERM so that
  anyone interested in improving this further can get the info for their code

Differential revision: https://reviews.llvm.org/D77448
2020-06-18 21:54:22 -05:00

71 lines
1.9 KiB
LLVM

; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -O3 < %s | FileCheck %s
; These tests verify that VSX swap optimization works for various
; manipulations of <2 x double> vectors.
@x = global <2 x double> <double 9.970000e+01, double -1.032220e+02>, align 16
@z = global <2 x double> <double 2.332000e+01, double 3.111111e+01>, align 16
define void @bar0(double %y) {
entry:
%0 = load <2 x double>, <2 x double>* @x, align 16
%vecins = insertelement <2 x double> %0, double %y, i32 0
store <2 x double> %vecins, <2 x double>* @z, align 16
ret void
}
; CHECK-LABEL: @bar0
; CHECK-DAG: xxswapd 1, 1
; CHECK-DAG: lxvd2x [[REG1:[0-9]+]]
; CHECK: xxmrgld [[REG2:[0-9]+]], 1, [[REG1]]
; CHECK: stxvd2x [[REG2]]
; CHECK-NOT: xxswapd
define void @bar1(double %y) {
entry:
%0 = load <2 x double>, <2 x double>* @x, align 16
%vecins = insertelement <2 x double> %0, double %y, i32 1
store <2 x double> %vecins, <2 x double>* @z, align 16
ret void
}
; CHECK-LABEL: @bar1
; CHECK-DAG: xxswapd 1, 1
; CHECK-DAG: lxvd2x [[REG1:[0-9]+]]
; CHECK: xxpermdi [[REG2:[0-9]+]], [[REG1]], 1, 1
; CHECK: stxvd2x [[REG2]]
; CHECK-NOT: xxswapd
define void @baz0() {
entry:
%0 = load <2 x double>, <2 x double>* @z, align 16
%1 = load <2 x double>, <2 x double>* @x, align 16
%vecins = shufflevector <2 x double> %0, <2 x double> %1, <2 x i32> <i32 0, i32 2>
store <2 x double> %vecins, <2 x double>* @z, align 16
ret void
}
; CHECK-LABEL: @baz0
; CHECK: lxvd2x
; CHECK: lxvd2x
; CHECK: xxmrghd
; CHECK: stxvd2x
; CHECK-NOT: xxswapd
define void @baz1() {
entry:
%0 = load <2 x double>, <2 x double>* @z, align 16
%1 = load <2 x double>, <2 x double>* @x, align 16
%vecins = shufflevector <2 x double> %0, <2 x double> %1, <2 x i32> <i32 3, i32 1>
store <2 x double> %vecins, <2 x double>* @z, align 16
ret void
}
; CHECK-LABEL: @baz1
; CHECK: lxvd2x
; CHECK: lxvd2x
; CHECK: xxmrgld
; CHECK: stxvd2x
; CHECK-NOT: xxswapd