1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mtriple=arm64-apple-macosx11.0.0 -passes=slp-vectorizer -S < %s | FileCheck %s
4 ; Test case reported on D134605 where the vectorization was causing a slowdown due to an underestimation in the cost of the extractions.
6 define fastcc i64 @zot(float %arg, float %arg1, float %arg2, float %arg3, float %arg4, ptr %arg5, i1 %arg6, i1 %arg7, i1 %arg8) {
9 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x float> <float 0.000000e+00, float poison, float poison, float poison>, float [[ARG:%.*]], i32 1
10 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x float> [[TMP0]], float [[ARG3:%.*]], i32 2
11 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
12 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast <4 x float> <float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00>, [[TMP2]]
13 ; CHECK-NEXT: [[VAL12:%.*]] = fadd fast float [[ARG3]], 1.000000e+00
14 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x float> [[TMP2]], float [[VAL12]], i32 0
15 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> [[TMP4]], float 0.000000e+00, i32 1
16 ; CHECK-NEXT: [[TMP6:%.*]] = fadd fast <4 x float> [[TMP5]], <float 2.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
17 ; CHECK-NEXT: br i1 [[ARG6:%.*]], label [[BB18:%.*]], label [[BB57:%.*]]
19 ; CHECK-NEXT: [[TMP7:%.*]] = phi <4 x float> [ [[TMP6]], [[BB:%.*]] ]
20 ; CHECK-NEXT: [[TMP8:%.*]] = extractelement <4 x float> [[TMP6]], i32 2
21 ; CHECK-NEXT: [[VAL23:%.*]] = fmul fast float [[TMP8]], 2.000000e+00
22 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x float> [[TMP6]], i32 3
23 ; CHECK-NEXT: [[VAL24:%.*]] = fmul fast float [[TMP9]], 3.000000e+00
24 ; CHECK-NEXT: br i1 [[ARG7:%.*]], label [[BB25:%.*]], label [[BB57]]
26 ; CHECK-NEXT: [[TMP10:%.*]] = phi <4 x float> [ [[TMP7]], [[BB18]] ]
27 ; CHECK-NEXT: [[TMP11:%.*]] = extractelement <4 x float> [[TMP3]], i32 1
28 ; CHECK-NEXT: br label [[BB30:%.*]]
30 ; CHECK-NEXT: [[VAL31:%.*]] = phi float [ [[VAL55:%.*]], [[BB30]] ], [ 0.000000e+00, [[BB25]] ]
31 ; CHECK-NEXT: [[VAL32:%.*]] = phi float [ [[TMP11]], [[BB30]] ], [ 0.000000e+00, [[BB25]] ]
32 ; CHECK-NEXT: [[TMP12:%.*]] = load <4 x i8>, ptr [[ARG5:%.*]], align 1
33 ; CHECK-NEXT: [[TMP13:%.*]] = uitofp <4 x i8> [[TMP12]] to <4 x float>
34 ; CHECK-NEXT: [[TMP14:%.*]] = fsub fast <4 x float> [[TMP13]], [[TMP3]]
35 ; CHECK-NEXT: [[TMP15:%.*]] = fmul fast <4 x float> [[TMP14]], [[TMP10]]
36 ; CHECK-NEXT: [[TMP16:%.*]] = call fast float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[TMP15]])
37 ; CHECK-NEXT: [[VAL55]] = tail call fast float @llvm.minnum.f32(float [[VAL31]], float [[ARG1:%.*]])
38 ; CHECK-NEXT: [[VAL56:%.*]] = tail call fast float @llvm.maxnum.f32(float [[ARG2:%.*]], float [[TMP16]])
39 ; CHECK-NEXT: call void @ham(float [[VAL55]], float [[VAL56]])
40 ; CHECK-NEXT: br i1 [[ARG8:%.*]], label [[BB30]], label [[BB57]]
42 ; CHECK-NEXT: ret i64 0
45 %val = fmul fast float 0.000000e+00, 0.000000e+00
46 %val9 = fmul fast float 0.000000e+00, %arg
47 %val10 = fmul fast float %arg3, 1.000000e+00
48 %val11 = fmul fast float %arg3, 1.000000e+00
49 %val12 = fadd fast float %arg3, 1.000000e+00
50 %val13 = fadd fast float %val12, 2.000000e+00
51 %val14 = fadd fast float 0.000000e+00, 0.000000e+00
52 %val15 = fadd fast float %val14, 1.000000e+00
53 %val16 = fadd fast float %arg3, 1.000000e+00
54 %val17 = fadd fast float %arg3, 1.000000e+00
55 br i1 %arg6, label %bb18, label %bb57
58 %val19 = phi float [ %val13, %bb ]
59 %val20 = phi float [ %val15, %bb ]
60 %val21 = phi float [ %val16, %bb ]
61 %val22 = phi float [ %val17, %bb ]
62 %val23 = fmul fast float %val16, 2.000000e+00
63 %val24 = fmul fast float %val17, 3.000000e+00
64 br i1 %arg7, label %bb25, label %bb57
67 %val26 = phi float [ %val19, %bb18 ]
68 %val27 = phi float [ %val20, %bb18 ]
69 %val28 = phi float [ %val21, %bb18 ]
70 %val29 = phi float [ %val22, %bb18 ]
73 bb30: ; preds = %bb30, %bb25
74 %val31 = phi float [ %val55, %bb30 ], [ 0.000000e+00, %bb25 ]
75 %val32 = phi float [ %val9, %bb30 ], [ 0.000000e+00, %bb25 ]
76 %val33 = load i8, ptr %arg5, align 1
77 %val34 = uitofp i8 %val33 to float
78 %val35 = getelementptr inbounds i8, ptr %arg5, i64 1
79 %val36 = load i8, ptr %val35, align 1
80 %val37 = uitofp i8 %val36 to float
81 %val38 = getelementptr inbounds i8, ptr %arg5, i64 2
82 %val39 = load i8, ptr %val38, align 1
83 %val40 = uitofp i8 %val39 to float
84 %val41 = getelementptr inbounds i8, ptr %arg5, i64 3
85 %val42 = load i8, ptr %val41, align 1
86 %val43 = uitofp i8 %val42 to float
87 %val44 = fsub fast float %val34, %val
88 %val45 = fsub fast float %val37, %val9
89 %val46 = fsub fast float %val40, %val10
90 %val47 = fsub fast float %val43, %val11
91 %val48 = fmul fast float %val44, %val26
92 %val49 = fmul fast float %val45, %val27
93 %val50 = fadd fast float %val49, %val48
94 %val51 = fmul fast float %val46, %val28
95 %val52 = fadd fast float %val50, %val51
96 %val53 = fmul fast float %val47, %val29
97 %val54 = fadd fast float %val52, %val53
98 %val55 = tail call fast float @llvm.minnum.f32(float %val31, float %arg1)
99 %val56 = tail call fast float @llvm.maxnum.f32(float %arg2, float %val54)
100 call void @ham(float %val55, float %val56)
101 br i1 %arg8, label %bb30, label %bb57
103 bb57: ; preds = %bb30, %bb18, %bb
107 declare float @llvm.maxnum.f32(float, float)
108 declare float @llvm.minnum.f32(float, float)
109 declare void @ham(float, float)