Skip to content

Commit 9d93893

Browse files
[PowerPC] Test case for vector float gather on ppc64le and ppc64
Test case to verify that the expected code is generated for a vector float gather based on the patterns in tablegen for big and little endian cases. Patch by: Kamau Bridgeman Differential Revision: https://reviews.llvm.org/D69443
1 parent 1ff5f0c commit 9d93893

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
; NOTE: This test ensures that for both Big and Little Endian cases a set of
2+
; NOTE: 4 floats is gathered into a v4f32 register using xxmrghd, xvcvdpsp,
3+
; NOTE: and vmrgew.
4+
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-vsr-nums-as-vr \
5+
; RUN: -ppc-asm-full-reg-names -mtriple=powerpc64le-unknown-linux-gnu < %s \
6+
; RUN: | FileCheck %s -check-prefix=CHECK-LE
7+
; RUN: llc -verify-machineinstrs -mcpu=pwr9 -ppc-vsr-nums-as-vr \
8+
; RUN: -ppc-asm-full-reg-names -mtriple=powerpc64-unknown-linux-gnu < %s \
9+
; RUN: | FileCheck %s -check-prefix=CHECK-BE
10+
define dso_local <4 x float> @vector_gatherf(float* nocapture readonly %a,
11+
float* nocapture readonly %b, float* nocapture readonly %c,
12+
float* nocapture readonly %d) {
13+
; C code from which this IR test case was generated:
14+
; vector float test(float *a, float *b, float *c, float *d) {
15+
; return (vector float) { *a, *b, *c, *d };
16+
; }
17+
; CHECK-LE-LABEL: vector_gatherf:
18+
; CHECK-LE: # %bb.0: # %entry
19+
; CHECK-LE-DAG: lfs f[[REG0:[0-9]+]], 0(r3)
20+
; CHECK-LE-DAG: lfs f[[REG1:[0-9]+]], 0(r4)
21+
; CHECK-LE-DAG: lfs f[[REG2:[0-9]+]], 0(r5)
22+
; CHECK-LE-DAG: lfs f[[REG3:[0-9]+]], 0(r6)
23+
; CHECK-LE-DAG: xxmrghd vs[[REG4:[0-9]+]], vs[[REG2]], vs[[REG0]]
24+
; CHECK-LE-NEXT: xvcvdpsp v[[VREG2:[0-9]+]], vs[[REG4]]
25+
; CHECK-LE-NEXT: xxmrghd vs[[REG5:[0-9]+]], vs[[REG3]], vs[[REG1]]
26+
; CHECK-LE-NEXT: xvcvdpsp v[[VREG3:[0-9]+]], vs[[REG5]]
27+
; CHECK-LE-NEXT: vmrgew v[[VREG:[0-9]+]], v[[VREG3]], v[[VREG2]]
28+
; CHECK-LE-NEXT: blr
29+
30+
; CHECK-BE-LABEL: vector_gatherf:
31+
; CHECK-BE: # %bb.0: # %entry
32+
; CHECK-BE-DAG: lfs f[[REG0:[0-9]+]], 0(r3)
33+
; CHECK-BE-DAG: lfs f[[REG1:[0-9]+]], 0(r4)
34+
; CHECK-BE-DAG: lfs f[[REG2:[0-9]+]], 0(r5)
35+
; CHECK-BE-DAG: lfs f[[REG3:[0-9]+]], 0(r6)
36+
; CHECK-BE-DAG: xxmrghd vs[[REG4:[0-9]+]], vs[[REG0]], vs[[REG2]]
37+
; CHECK-BE-DAG: xxmrghd vs[[REG5:[0-9]+]], vs[[REG1]], vs[[REG3]]
38+
; CHECK-BE-NEXT: xvcvdpsp v[[VREG2:[0-9]+]], vs[[REG5]]
39+
; CHECK-BE-NEXT: xvcvdpsp v[[VREG3:[0-9]+]], vs[[REG4]]
40+
; CHECK-BE-NEXT: vmrgew v[[VREG:[0-9]+]], v[[VREG3]], v[[VREG2]]
41+
; CHECK-BE-NEXT: blr
42+
entry:
43+
%0 = load float, float* %a, align 4
44+
%vecinit = insertelement <4 x float> undef, float %0, i32 0
45+
%1 = load float, float* %b, align 4
46+
%vecinit1 = insertelement <4 x float> %vecinit, float %1, i32 1
47+
%2 = load float, float* %c, align 4
48+
%vecinit2 = insertelement <4 x float> %vecinit1, float %2, i32 2
49+
%3 = load float, float* %d, align 4
50+
%vecinit3 = insertelement <4 x float> %vecinit2, float %3, i32 3
51+
ret <4 x float> %vecinit3
52+
}
53+

0 commit comments

Comments
 (0)