xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/avx.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=i686-apple-darwin -mcpu=corei7-avx | FileCheck %s -check-prefix=X32 --check-prefix=CHECK
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx | FileCheck %s -check-prefix=X64 --check-prefix=CHECK
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdefine <4 x i32> @blendvb_fallback_v4i32(<4 x i1> %mask, <4 x i32> %x, <4 x i32> %y) {
5*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @blendvb_fallback_v4i32
6*9880d681SAndroid Build Coastguard Worker; CHECK: vblendvps
7*9880d681SAndroid Build Coastguard Worker; CHECK: ret
8*9880d681SAndroid Build Coastguard Worker  %ret = select <4 x i1> %mask, <4 x i32> %x, <4 x i32> %y
9*9880d681SAndroid Build Coastguard Worker  ret <4 x i32> %ret
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine <8 x i32> @blendvb_fallback_v8i32(<8 x i1> %mask, <8 x i32> %x, <8 x i32> %y) {
13*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @blendvb_fallback_v8i32
14*9880d681SAndroid Build Coastguard Worker; CHECK: vblendvps
15*9880d681SAndroid Build Coastguard Worker; CHECK: ret
16*9880d681SAndroid Build Coastguard Worker  %ret = select <8 x i1> %mask, <8 x i32> %x, <8 x i32> %y
17*9880d681SAndroid Build Coastguard Worker  ret <8 x i32> %ret
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerdefine <8 x float> @blendvb_fallback_v8f32(<8 x i1> %mask, <8 x float> %x, <8 x float> %y) {
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @blendvb_fallback_v8f32
22*9880d681SAndroid Build Coastguard Worker; CHECK: vblendvps
23*9880d681SAndroid Build Coastguard Worker; CHECK: ret
24*9880d681SAndroid Build Coastguard Worker  %ret = select <8 x i1> %mask, <8 x float> %x, <8 x float> %y
25*9880d681SAndroid Build Coastguard Worker  ret <8 x float> %ret
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.x86.sse41.insertps(<4 x float>, <4 x float>, i32) nounwind readnone
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_vector_load(<4 x float> %a, <4 x float>* nocapture readonly %pb) {
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_vector_load:
32*9880d681SAndroid Build Coastguard Worker; On X32, account for the argument's move to registers
33*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %eax
34*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
35*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertps    $48, (%{{...}}), {{.*#+}} xmm0 = xmm0[0,1,2],mem[0]
36*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
37*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x float>, <4 x float>* %pb, align 16
38*9880d681SAndroid Build Coastguard Worker  %2 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %1, i32 48)
39*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %2
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker;; Use a non-zero CountS for insertps
43*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_vector_load_offset(<4 x float> %a, <4 x float>* nocapture readonly %pb) {
44*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_vector_load_offset:
45*9880d681SAndroid Build Coastguard Worker; On X32, account for the argument's move to registers
46*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %eax
47*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
48*9880d681SAndroid Build Coastguard Worker;; Try to match a bit more of the instr, since we need the load's offset.
49*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertps    $32, 4(%{{...}}), {{.*#+}} xmm0 = xmm0[0,1],mem[0],xmm0[3]
50*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
51*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x float>, <4 x float>* %pb, align 16
52*9880d681SAndroid Build Coastguard Worker  %2 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %1, i32 96)
53*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %2
54*9880d681SAndroid Build Coastguard Worker}
55*9880d681SAndroid Build Coastguard Worker
56*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_vector_load_offset_2(<4 x float> %a, <4 x float>* nocapture readonly %pb, i64 %index) {
57*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_vector_load_offset_2:
58*9880d681SAndroid Build Coastguard Worker; On X32, account for the argument's move to registers
59*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %eax
60*9880d681SAndroid Build Coastguard Worker; X32: movl    8(%esp), %ecx
61*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
62*9880d681SAndroid Build Coastguard Worker;; Try to match a bit more of the instr, since we need the load's offset.
63*9880d681SAndroid Build Coastguard Worker; CHECK: vinsertps    $0, 12(%{{...}},%{{...}}), {{.*#+}} xmm0 = mem[0],xmm0[1,2,3]
64*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
65*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds <4 x float>, <4 x float>* %pb, i64 %index
66*9880d681SAndroid Build Coastguard Worker  %2 = load <4 x float>, <4 x float>* %1, align 16
67*9880d681SAndroid Build Coastguard Worker  %3 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %2, i32 192)
68*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %3
69*9880d681SAndroid Build Coastguard Worker}
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_broadcast_loadf32(<4 x float> %a, float* nocapture readonly %fb, i64 %index) {
72*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_broadcast_loadf32:
73*9880d681SAndroid Build Coastguard Worker; On X32, account for the arguments' move to registers
74*9880d681SAndroid Build Coastguard Worker; X32: movl    8(%esp), %eax
75*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %ecx
76*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
77*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
78*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
79*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds float, float* %fb, i64 %index
80*9880d681SAndroid Build Coastguard Worker  %2 = load float, float* %1, align 4
81*9880d681SAndroid Build Coastguard Worker  %3 = insertelement <4 x float> undef, float %2, i32 0
82*9880d681SAndroid Build Coastguard Worker  %4 = insertelement <4 x float> %3, float %2, i32 1
83*9880d681SAndroid Build Coastguard Worker  %5 = insertelement <4 x float> %4, float %2, i32 2
84*9880d681SAndroid Build Coastguard Worker  %6 = insertelement <4 x float> %5, float %2, i32 3
85*9880d681SAndroid Build Coastguard Worker  %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
86*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %7
87*9880d681SAndroid Build Coastguard Worker}
88*9880d681SAndroid Build Coastguard Worker
89*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_broadcast_loadv4f32(<4 x float> %a, <4 x float>* nocapture readonly %b) {
90*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_broadcast_loadv4f32:
91*9880d681SAndroid Build Coastguard Worker; On X32, account for the arguments' move to registers
92*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %{{...}}
93*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
94*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
95*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
96*9880d681SAndroid Build Coastguard Worker  %1 = load <4 x float>, <4 x float>* %b, align 4
97*9880d681SAndroid Build Coastguard Worker  %2 = extractelement <4 x float> %1, i32 0
98*9880d681SAndroid Build Coastguard Worker  %3 = insertelement <4 x float> undef, float %2, i32 0
99*9880d681SAndroid Build Coastguard Worker  %4 = insertelement <4 x float> %3, float %2, i32 1
100*9880d681SAndroid Build Coastguard Worker  %5 = insertelement <4 x float> %4, float %2, i32 2
101*9880d681SAndroid Build Coastguard Worker  %6 = insertelement <4 x float> %5, float %2, i32 3
102*9880d681SAndroid Build Coastguard Worker  %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
103*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %7
104*9880d681SAndroid Build Coastguard Worker}
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Worker;; FIXME: We're emitting an extraneous pshufd/vbroadcast.
107*9880d681SAndroid Build Coastguard Workerdefine <4 x float> @insertps_from_broadcast_multiple_use(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x float> %d, float* nocapture readonly %fb, i64 %index) {
108*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: insertps_from_broadcast_multiple_use:
109*9880d681SAndroid Build Coastguard Worker; On X32, account for the arguments' move to registers
110*9880d681SAndroid Build Coastguard Worker; X32: movl    8(%esp), %eax
111*9880d681SAndroid Build Coastguard Worker; X32: movl    4(%esp), %ecx
112*9880d681SAndroid Build Coastguard Worker; CHECK: vbroadcastss
113*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: mov
114*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
115*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
116*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
117*9880d681SAndroid Build Coastguard Worker; CHECK: insertps    $48
118*9880d681SAndroid Build Coastguard Worker; CHECK: vaddps
119*9880d681SAndroid Build Coastguard Worker; CHECK: vaddps
120*9880d681SAndroid Build Coastguard Worker; CHECK: vaddps
121*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret
122*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds float, float* %fb, i64 %index
123*9880d681SAndroid Build Coastguard Worker  %2 = load float, float* %1, align 4
124*9880d681SAndroid Build Coastguard Worker  %3 = insertelement <4 x float> undef, float %2, i32 0
125*9880d681SAndroid Build Coastguard Worker  %4 = insertelement <4 x float> %3, float %2, i32 1
126*9880d681SAndroid Build Coastguard Worker  %5 = insertelement <4 x float> %4, float %2, i32 2
127*9880d681SAndroid Build Coastguard Worker  %6 = insertelement <4 x float> %5, float %2, i32 3
128*9880d681SAndroid Build Coastguard Worker  %7 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a, <4 x float> %6, i32 48)
129*9880d681SAndroid Build Coastguard Worker  %8 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %b, <4 x float> %6, i32 48)
130*9880d681SAndroid Build Coastguard Worker  %9 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %c, <4 x float> %6, i32 48)
131*9880d681SAndroid Build Coastguard Worker  %10 = tail call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %d, <4 x float> %6, i32 48)
132*9880d681SAndroid Build Coastguard Worker  %11 = fadd <4 x float> %7, %8
133*9880d681SAndroid Build Coastguard Worker  %12 = fadd <4 x float> %9, %10
134*9880d681SAndroid Build Coastguard Worker  %13 = fadd <4 x float> %11, %12
135*9880d681SAndroid Build Coastguard Worker  ret <4 x float> %13
136*9880d681SAndroid Build Coastguard Worker}
137