1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=x86_64 -mcpu=skylake-avx512 -passes=slp-vectorizer -pass-remarks-output=%t < %s | FileCheck %s
3 ; RUN: FileCheck --input-file=%t --check-prefix=YAML %s
5 define i32 @test(ptr noalias %p, ptr noalias %addr) {
8 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[ADDR:%.*]], i32 0
9 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x ptr> [[TMP0]], <8 x ptr> poison, <8 x i32> zeroinitializer
10 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i32, <8 x ptr> [[TMP1]], <8 x i32> <i32 3, i32 1, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
11 ; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i32> @llvm.masked.gather.v8i32.v8p0(<8 x ptr> [[TMP2]], i32 8, <8 x i1> splat (i1 true), <8 x i32> poison)
12 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <8 x ptr> poison, ptr [[P:%.*]], i32 0
13 ; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <8 x ptr> [[TMP4]], <8 x ptr> poison, <8 x i32> zeroinitializer
14 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr i32, <8 x ptr> [[TMP5]], <8 x i32> [[TMP3]]
15 ; CHECK-NEXT: [[TMP7:%.*]] = call <8 x i32> @llvm.masked.gather.v8i32.v8p0(<8 x ptr> [[TMP6]], i32 4, <8 x i1> splat (i1 true), <8 x i32> poison)
16 ; CHECK-NEXT: [[TMP8:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP7]])
17 ; CHECK-NEXT: ret i32 [[TMP8]]
20 ; YAML-NEXT: Pass: slp-vectorizer
21 ; YAML-NEXT: Name: VectorizedHorizontalReduction
22 ; YAML-NEXT: Function: test
24 ; YAML-NEXT: - String: 'Vectorized horizontal reduction with cost '
25 ; YAML-NEXT: - Cost: '-1'
26 ; YAML-NEXT: - String: ' and with tree size '
27 ; YAML-NEXT: - TreeSize: '8'
29 %off0.1 = getelementptr inbounds i32, ptr %addr, i32 1
30 %idx0 = load i32, ptr %off0.1, align 8
31 %gep0 = getelementptr inbounds i32, ptr %p, i32 %idx0
32 %ld0 = load i32, ptr %gep0, align 4
34 %off1.3 = getelementptr inbounds i32, ptr %addr, i32 3
35 %idx1 = load i32, ptr %off1.3, align 8
36 %gep1 = getelementptr inbounds i32, ptr %p, i32 %idx1
37 %ld1 = load i32, ptr %gep1, align 4
39 %off2.5 = getelementptr inbounds i32, ptr %addr, i32 5
40 %idx2 = load i32, ptr %off2.5, align 8
41 %gep2 = getelementptr inbounds i32, ptr %p, i32 %idx2
42 %ld2 = load i32, ptr %gep2, align 4
44 %off3.7 = getelementptr inbounds i32, ptr %addr, i32 7
45 %idx3 = load i32, ptr %off3.7, align 8
46 %gep3 = getelementptr inbounds i32, ptr %p, i32 %idx3
47 %ld3 = load i32, ptr %gep3, align 4
49 %off4.9 = getelementptr inbounds i32, ptr %addr, i32 9
50 %idx4 = load i32, ptr %off4.9, align 8
51 %gep4 = getelementptr inbounds i32, ptr %p, i32 %idx4
52 %ld4 = load i32, ptr %gep4, align 4
54 %off5.11 = getelementptr inbounds i32, ptr %addr, i32 11
55 %idx5 = load i32, ptr %off5.11, align 8
56 %gep5 = getelementptr inbounds i32, ptr %p, i32 %idx5
57 %ld5 = load i32, ptr %gep5, align 4
59 %off6.13 = getelementptr inbounds i32, ptr %addr, i32 13
60 %idx6 = load i32, ptr %off6.13, align 8
61 %gep6 = getelementptr inbounds i32, ptr %p, i32 %idx6
62 %ld6 = load i32, ptr %gep6, align 4
64 %off7.15 = getelementptr inbounds i32, ptr %addr, i32 15
65 %idx7 = load i32, ptr %off7.15, align 8
66 %gep7 = getelementptr inbounds i32, ptr %p, i32 %idx7
67 %ld7 = load i32, ptr %gep7, align 4
69 %add0 = add nsw i32 %ld1, %ld0
70 %add1 = add nsw i32 %add0, %ld2
71 %add2 = add nsw i32 %add1, %ld3
72 %add3 = add nsw i32 %add2, %ld4
73 %add4 = add nsw i32 %add3, %ld5
74 %add5 = add nsw i32 %add4, %ld6
75 %add6 = add nsw i32 %add5, %ld7