1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
2 ; RUN: opt -passes=slp-vectorizer -mtriple=x86_64 -S -mcpu=core-avx2 -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: FileCheck --input-file=%t --check-prefix=YAML %s
6 ; YAML: Pass: slp-vectorizer
7 ; YAML: Name: StoresVectorized
10 ; YAML: - String: 'Stores SLP vectorized with cost '
12 ; YAML: - String: ' and with tree size '
13 ; YAML: - TreeSize: '14'
16 ; Test that SLP cost modeling is able to match gathering tree
17 ; entries: two instances of { call0 .. call3 }. Both used by
18 ; vectorized PHI entries: { phi0 .. phi3 } and { phi4 .. phi7 }.
19 ; Check that cost is not added twice for gathered calls.
21 define void @test(ptr %dst, float %a, float %b, float %c, float %d) {
22 ; CHECK-LABEL: define void @test(
23 ; CHECK-SAME: ptr [[DST:%.*]], float [[A:%.*]], float [[B:%.*]], float [[C:%.*]], float [[D:%.*]]) #[[ATTR0:[0-9]+]] {
25 ; CHECK-NEXT: br i1 poison, label [[LOOP0:%.*]], label [[EXIT:%.*]]
27 ; CHECK-NEXT: [[TMP0:%.*]] = phi <4 x float> [ <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>, [[ENTRY:%.*]] ], [ [[TMP7:%.*]], [[USERBLOCK1:%.*]] ]
28 ; CHECK-NEXT: br i1 poison, label [[USERBLOCK0:%.*]], label [[BLKX:%.*]]
30 ; CHECK-NEXT: [[TMP1:%.*]] = phi <4 x float> [ zeroinitializer, [[LOOP0]] ], [ [[TMP5:%.*]], [[BLKX]] ]
31 ; CHECK-NEXT: br label [[LOOP_INNER:%.*]]
33 ; CHECK-NEXT: [[CALL0:%.*]] = call fast float @foo(float [[A]])
34 ; CHECK-NEXT: [[CALL1:%.*]] = call fast float @foo(float [[B]])
35 ; CHECK-NEXT: [[CALL2:%.*]] = call fast float @foo(float [[C]])
36 ; CHECK-NEXT: [[CALL3:%.*]] = call fast float @foo(float [[D]])
37 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x float> poison, float [[CALL0]], i32 0
38 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x float> [[TMP2]], float [[CALL1]], i32 1
39 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP3]], float [[CALL2]], i32 2
40 ; CHECK-NEXT: [[TMP5]] = insertelement <4 x float> [[TMP4]], float [[CALL3]], i32 3
41 ; CHECK-NEXT: br i1 poison, label [[USERBLOCK0]], label [[USERBLOCK1]]
43 ; CHECK-NEXT: [[TMP6:%.*]] = phi <4 x float> [ [[TMP5]], [[BLKX]] ], [ [[TMP9:%.*]], [[LOOP_INNER]] ]
44 ; CHECK-NEXT: [[TMP7]] = fadd fast <4 x float> [[TMP0]], [[TMP6]]
45 ; CHECK-NEXT: br i1 poison, label [[EXIT]], label [[LOOP0]]
47 ; CHECK-NEXT: [[TMP8:%.*]] = phi <4 x float> [ [[TMP1]], [[USERBLOCK0]] ], [ [[TMP9]], [[LOOP_INNER]] ]
48 ; CHECK-NEXT: [[TMP9]] = fadd fast <4 x float> [[TMP8]], poison
49 ; CHECK-NEXT: br i1 poison, label [[USERBLOCK1]], label [[LOOP_INNER]]
51 ; CHECK-NEXT: [[TMP10:%.*]] = phi <4 x float> [ <float 5.000000e-01, float 5.000000e-01, float 5.000000e-01, float 5.000000e-01>, [[ENTRY]] ], [ [[TMP7]], [[USERBLOCK1]] ]
52 ; CHECK-NEXT: [[IDX0:%.*]] = add i64 0, poison
53 ; CHECK-NEXT: [[GEP0:%.*]] = getelementptr inbounds float, ptr [[DST]], i64 [[IDX0]]
54 ; CHECK-NEXT: store <4 x float> [[TMP10]], ptr [[GEP0]], align 4
55 ; CHECK-NEXT: ret void
58 br i1 poison, label %loop0, label %Exit
61 %i0 = phi float [ 5.000000e-01, %Entry ], [ %add3, %UserBlock1 ]
62 %i1 = phi float [ 5.000000e-01, %Entry ], [ %add2, %UserBlock1 ]
63 %i2 = phi float [ 5.000000e-01, %Entry ], [ %add1, %UserBlock1 ]
64 %i3 = phi float [ 5.000000e-01, %Entry ], [ %add0, %UserBlock1 ]
65 br i1 poison, label %UserBlock0, label %blkx
68 %phi0 = phi float [ 0.000000e+00, %loop0 ], [ %call3, %blkx ]
69 %phi1 = phi float [ 0.000000e+00, %loop0 ], [ %call2, %blkx ]
70 %phi2 = phi float [ 0.000000e+00, %loop0 ], [ %call1, %blkx ]
71 %phi3 = phi float [ 0.000000e+00, %loop0 ], [ %call0, %blkx ]
75 %call0 = call fast float @foo(float %a)
76 %call1 = call fast float @foo(float %b)
77 %call2 = call fast float @foo(float %c)
78 %call3 = call fast float @foo(float %d)
79 br i1 poison, label %UserBlock0, label %UserBlock1
82 %phi4 = phi float [ %call0, %blkx ], [ %add4, %loop.inner ]
83 %phi5 = phi float [ %call1, %blkx ], [ %add5, %loop.inner ]
84 %phi6 = phi float [ %call2, %blkx ], [ %add6, %loop.inner ]
85 %phi7 = phi float [ %call3, %blkx ], [ %add7, %loop.inner ]
86 %add0 = fadd fast float %i3, %phi4
87 %add1 = fadd fast float %i2, %phi5
88 %add2 = fadd fast float %i1, %phi6
89 %add3 = fadd fast float %i0, %phi7
90 br i1 poison, label %Exit, label %loop0
93 %t20 = phi float [ %phi3, %UserBlock0 ], [ %add4, %loop.inner ]
94 %t19 = phi float [ %phi2, %UserBlock0 ], [ %add5, %loop.inner ]
95 %t18 = phi float [ %phi1, %UserBlock0 ], [ %add6, %loop.inner ]
96 %t17 = phi float [ %phi0, %UserBlock0 ], [ %add7, %loop.inner ]
97 %add4 = fadd fast float %t20, poison
98 %add5 = fadd fast float %t19, poison
99 %add6 = fadd fast float %t18, poison
100 %add7 = fadd fast float %t17, poison
102 br i1 poison, label %UserBlock1, label %loop.inner
105 %t48 = phi float [ 5.000000e-01, %Entry ], [ %add3, %UserBlock1 ]
106 %t47 = phi float [ 5.000000e-01, %Entry ], [ %add2, %UserBlock1 ]
107 %t46 = phi float [ 5.000000e-01, %Entry ], [ %add1, %UserBlock1 ]
108 %t45 = phi float [ 5.000000e-01, %Entry ], [ %add0, %UserBlock1 ]
109 %idx0 = add i64 0, poison
110 %gep0 = getelementptr inbounds float, ptr %dst, i64 %idx0
111 store float %t45, ptr %gep0, align 4
112 %idx1 = add i64 1, poison
113 %gep1 = getelementptr inbounds float, ptr %dst, i64 %idx1
114 store float %t46, ptr %gep1, align 4
115 %idx2 = add i64 2, poison
116 %gep2 = getelementptr inbounds float, ptr %dst, i64 %idx2
117 store float %t47, ptr %gep2, align 4
118 %idx3 = add i64 3, poison
119 %gep3 = getelementptr inbounds float, ptr %dst, i64 %idx3
120 store float %t48, ptr %gep3, align 4
124 declare float @foo(float)