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 ; NOTE: cost of shuffle <4 x float>, <4 x float>, <2 x i32> <i32 2, i32 5> is 12!
8 define fastcc i64 @zot(float %arg, float %arg1, float %arg2, float %arg3, float %arg4, ptr %arg5, i1 %arg6, i1 %arg7, i1 %arg8) {
11 ; CHECK-NEXT: [[VAL:%.*]] = fmul fast float 0.000000e+00, 0.000000e+00
12 ; CHECK-NEXT: [[VAL9:%.*]] = fmul fast float 0.000000e+00, [[ARG:%.*]]
13 ; CHECK-NEXT: [[VAL10:%.*]] = fmul fast float [[ARG3:%.*]], 1.000000e+00
14 ; CHECK-NEXT: [[VAL11:%.*]] = fmul fast float [[ARG3]], 1.000000e+00
15 ; CHECK-NEXT: [[VAL12:%.*]] = fadd fast float [[ARG3]], 1.000000e+00
16 ; CHECK-NEXT: [[VAL13:%.*]] = fadd fast float [[VAL12]], 2.000000e+00
17 ; CHECK-NEXT: [[VAL14:%.*]] = fadd fast float 0.000000e+00, 0.000000e+00
18 ; CHECK-NEXT: [[VAL15:%.*]] = fadd fast float [[VAL14]], 1.000000e+00
19 ; CHECK-NEXT: [[VAL16:%.*]] = fadd fast float [[ARG3]], 1.000000e+00
20 ; CHECK-NEXT: [[VAL17:%.*]] = fadd fast float [[ARG3]], 1.000000e+00
21 ; CHECK-NEXT: br i1 [[ARG6:%.*]], label [[BB18:%.*]], label [[BB57:%.*]]
23 ; CHECK-NEXT: [[VAL19:%.*]] = phi float [ [[VAL13]], [[BB:%.*]] ]
24 ; CHECK-NEXT: [[VAL20:%.*]] = phi float [ [[VAL15]], [[BB]] ]
25 ; CHECK-NEXT: [[VAL21:%.*]] = phi float [ [[VAL16]], [[BB]] ]
26 ; CHECK-NEXT: [[VAL22:%.*]] = phi float [ [[VAL17]], [[BB]] ]
27 ; CHECK-NEXT: [[VAL23:%.*]] = fmul fast float [[VAL16]], 2.000000e+00
28 ; CHECK-NEXT: [[VAL24:%.*]] = fmul fast float [[VAL17]], 3.000000e+00
29 ; CHECK-NEXT: br i1 [[ARG7:%.*]], label [[BB25:%.*]], label [[BB57]]
31 ; CHECK-NEXT: [[VAL26:%.*]] = phi float [ [[VAL19]], [[BB18]] ]
32 ; CHECK-NEXT: [[VAL27:%.*]] = phi float [ [[VAL20]], [[BB18]] ]
33 ; CHECK-NEXT: [[VAL28:%.*]] = phi float [ [[VAL21]], [[BB18]] ]
34 ; CHECK-NEXT: [[VAL29:%.*]] = phi float [ [[VAL22]], [[BB18]] ]
35 ; CHECK-NEXT: br label [[BB30:%.*]]
37 ; CHECK-NEXT: [[VAL31:%.*]] = phi float [ [[VAL55:%.*]], [[BB30]] ], [ 0.000000e+00, [[BB25]] ]
38 ; CHECK-NEXT: [[VAL32:%.*]] = phi float [ [[VAL9]], [[BB30]] ], [ 0.000000e+00, [[BB25]] ]
39 ; CHECK-NEXT: [[VAL33:%.*]] = load i8, ptr [[ARG5:%.*]], align 1
40 ; CHECK-NEXT: [[VAL34:%.*]] = uitofp i8 [[VAL33]] to float
41 ; CHECK-NEXT: [[VAL35:%.*]] = getelementptr inbounds i8, ptr [[ARG5]], i64 1
42 ; CHECK-NEXT: [[VAL36:%.*]] = load i8, ptr [[VAL35]], align 1
43 ; CHECK-NEXT: [[VAL37:%.*]] = uitofp i8 [[VAL36]] to float
44 ; CHECK-NEXT: [[VAL38:%.*]] = getelementptr inbounds i8, ptr [[ARG5]], i64 2
45 ; CHECK-NEXT: [[VAL39:%.*]] = load i8, ptr [[VAL38]], align 1
46 ; CHECK-NEXT: [[VAL40:%.*]] = uitofp i8 [[VAL39]] to float
47 ; CHECK-NEXT: [[VAL41:%.*]] = getelementptr inbounds i8, ptr [[ARG5]], i64 3
48 ; CHECK-NEXT: [[VAL42:%.*]] = load i8, ptr [[VAL41]], align 1
49 ; CHECK-NEXT: [[VAL43:%.*]] = uitofp i8 [[VAL42]] to float
50 ; CHECK-NEXT: [[VAL44:%.*]] = fsub fast float [[VAL34]], [[VAL]]
51 ; CHECK-NEXT: [[VAL45:%.*]] = fsub fast float [[VAL37]], [[VAL9]]
52 ; CHECK-NEXT: [[VAL46:%.*]] = fsub fast float [[VAL40]], [[VAL10]]
53 ; CHECK-NEXT: [[VAL47:%.*]] = fsub fast float [[VAL43]], [[VAL11]]
54 ; CHECK-NEXT: [[VAL48:%.*]] = fmul fast float [[VAL44]], [[VAL26]]
55 ; CHECK-NEXT: [[VAL49:%.*]] = fmul fast float [[VAL45]], [[VAL27]]
56 ; CHECK-NEXT: [[VAL50:%.*]] = fadd fast float [[VAL49]], [[VAL48]]
57 ; CHECK-NEXT: [[VAL51:%.*]] = fmul fast float [[VAL46]], [[VAL28]]
58 ; CHECK-NEXT: [[VAL52:%.*]] = fadd fast float [[VAL50]], [[VAL51]]
59 ; CHECK-NEXT: [[VAL53:%.*]] = fmul fast float [[VAL47]], [[VAL29]]
60 ; CHECK-NEXT: [[VAL54:%.*]] = fadd fast float [[VAL52]], [[VAL53]]
61 ; CHECK-NEXT: [[VAL55]] = tail call fast float @llvm.minnum.f32(float [[VAL31]], float [[ARG1:%.*]])
62 ; CHECK-NEXT: [[VAL56:%.*]] = tail call fast float @llvm.maxnum.f32(float [[ARG2:%.*]], float [[VAL54]])
63 ; CHECK-NEXT: call void @ham(float [[VAL55]], float [[VAL56]])
64 ; CHECK-NEXT: br i1 [[ARG8:%.*]], label [[BB30]], label [[BB57]]
66 ; CHECK-NEXT: ret i64 0
69 %val = fmul fast float 0.000000e+00, 0.000000e+00
70 %val9 = fmul fast float 0.000000e+00, %arg
71 %val10 = fmul fast float %arg3, 1.000000e+00
72 %val11 = fmul fast float %arg3, 1.000000e+00
73 %val12 = fadd fast float %arg3, 1.000000e+00
74 %val13 = fadd fast float %val12, 2.000000e+00
75 %val14 = fadd fast float 0.000000e+00, 0.000000e+00
76 %val15 = fadd fast float %val14, 1.000000e+00
77 %val16 = fadd fast float %arg3, 1.000000e+00
78 %val17 = fadd fast float %arg3, 1.000000e+00
79 br i1 %arg6, label %bb18, label %bb57
82 %val19 = phi float [ %val13, %bb ]
83 %val20 = phi float [ %val15, %bb ]
84 %val21 = phi float [ %val16, %bb ]
85 %val22 = phi float [ %val17, %bb ]
86 %val23 = fmul fast float %val16, 2.000000e+00
87 %val24 = fmul fast float %val17, 3.000000e+00
88 br i1 %arg7, label %bb25, label %bb57
91 %val26 = phi float [ %val19, %bb18 ]
92 %val27 = phi float [ %val20, %bb18 ]
93 %val28 = phi float [ %val21, %bb18 ]
94 %val29 = phi float [ %val22, %bb18 ]
97 bb30: ; preds = %bb30, %bb25
98 %val31 = phi float [ %val55, %bb30 ], [ 0.000000e+00, %bb25 ]
99 %val32 = phi float [ %val9, %bb30 ], [ 0.000000e+00, %bb25 ]
100 %val33 = load i8, ptr %arg5, align 1
101 %val34 = uitofp i8 %val33 to float
102 %val35 = getelementptr inbounds i8, ptr %arg5, i64 1
103 %val36 = load i8, ptr %val35, align 1
104 %val37 = uitofp i8 %val36 to float
105 %val38 = getelementptr inbounds i8, ptr %arg5, i64 2
106 %val39 = load i8, ptr %val38, align 1
107 %val40 = uitofp i8 %val39 to float
108 %val41 = getelementptr inbounds i8, ptr %arg5, i64 3
109 %val42 = load i8, ptr %val41, align 1
110 %val43 = uitofp i8 %val42 to float
111 %val44 = fsub fast float %val34, %val
112 %val45 = fsub fast float %val37, %val9
113 %val46 = fsub fast float %val40, %val10
114 %val47 = fsub fast float %val43, %val11
115 %val48 = fmul fast float %val44, %val26
116 %val49 = fmul fast float %val45, %val27
117 %val50 = fadd fast float %val49, %val48
118 %val51 = fmul fast float %val46, %val28
119 %val52 = fadd fast float %val50, %val51
120 %val53 = fmul fast float %val47, %val29
121 %val54 = fadd fast float %val52, %val53
122 %val55 = tail call fast float @llvm.minnum.f32(float %val31, float %arg1)
123 %val56 = tail call fast float @llvm.maxnum.f32(float %arg2, float %val54)
124 call void @ham(float %val55, float %val56)
125 br i1 %arg8, label %bb30, label %bb57
127 bb57: ; preds = %bb30, %bb18, %bb
131 declare float @llvm.maxnum.f32(float, float)
132 declare float @llvm.minnum.f32(float, float)
133 declare void @ham(float, float)