1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=aarch64-unknown-unknown | FileCheck %s
4 ; This test is reduced from the TSVC evaluation of vectorizers:
5 ; https://github.com/llvm/llvm-test-suite/commits/main/MultiSource/Benchmarks/TSVC/LoopRerolling-flt/tsc.c
8 ; This test is currently getting vectorized with VF=2. We should be able
9 ; to vectorize it with VF=4. Specifically, we should be able to have 1 load of
10 ; <4 x float> instead of 2 loads of <2 x float>, and there should be no need
12 ; The current issue comes from the Left-Hand-Side fmul operands.
13 ; These operands are coming from 4 loads which are not
14 ; contiguous. The score estimation needs to be corrected, so that these 4 loads
15 ; are not selected for vectorization. Instead we should vectorize with
16 ; contiguous loads, from %a plus offsets 0 to 3, or offsets 1 to 4.
18 define void @s116_modified(ptr %a) {
19 ; CHECK-LABEL: @s116_modified(
20 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i64 1
21 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds float, ptr [[A]], i64 3
22 ; CHECK-NEXT: [[LD0:%.*]] = load float, ptr [[A]], align 4
23 ; CHECK-NEXT: [[TMP2:%.*]] = load <2 x float>, ptr [[GEP1]], align 4
24 ; CHECK-NEXT: [[TMP4:%.*]] = load <2 x float>, ptr [[GEP3]], align 4
25 ; CHECK-NEXT: [[TMP5:%.*]] = insertelement <4 x float> poison, float [[LD0]], i32 0
26 ; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <2 x float> [[TMP2]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 poison>
27 ; CHECK-NEXT: [[TMP7:%.*]] = shufflevector <4 x float> [[TMP5]], <4 x float> [[TMP6]], <4 x i32> <i32 0, i32 5, i32 poison, i32 poison>
28 ; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <2 x float> [[TMP4]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
29 ; CHECK-NEXT: [[TMP9:%.*]] = shufflevector <4 x float> [[TMP7]], <4 x float> [[TMP8]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
30 ; CHECK-NEXT: [[TMP10:%.*]] = shufflevector <4 x float> [[TMP6]], <4 x float> [[TMP8]], <4 x i32> <i32 0, i32 poison, i32 2, i32 4>
31 ; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <4 x float> [[TMP10]], <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 2, i32 3>
32 ; CHECK-NEXT: [[TMP12:%.*]] = fmul fast <4 x float> [[TMP9]], [[TMP11]]
33 ; CHECK-NEXT: store <4 x float> [[TMP12]], ptr [[A]], align 4
34 ; CHECK-NEXT: ret void
36 %gep1 = getelementptr inbounds float, ptr %a, i64 1
37 %gep2 = getelementptr inbounds float, ptr %a, i64 2
38 %gep3 = getelementptr inbounds float, ptr %a, i64 3
39 %gep4 = getelementptr inbounds float, ptr %a, i64 4
40 %ld0 = load float, ptr %a
41 %ld1 = load float, ptr %gep1
42 %ld2 = load float, ptr %gep2
43 %ld3 = load float, ptr %gep3
44 %ld4 = load float, ptr %gep4
45 %mul0 = fmul fast float %ld0, %ld1
46 %mul1 = fmul fast float %ld2, %ld1
47 %mul2 = fmul fast float %ld3, %ld2
48 %mul3 = fmul fast float %ld4, %ld3
49 store float %mul0, ptr %a
50 store float %mul1, ptr %gep1
51 store float %mul2, ptr %gep2
52 store float %mul3, ptr %gep3