1 ; This test checks that the given loop still beneficial for vecotization
2 ; even if it contains scalarized load (gather on AVX2)
3 ;RUN: opt < %s -loop-vectorize -S -o - | FileCheck %s
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
8 ; Function Attrs: norecurse nounwind readonly uwtable
9 define i32 @matrix_row_col([100 x i32]* nocapture readonly %data, i32 %i, i32 %j) local_unnamed_addr #0 {
11 %idxprom = sext i32 %i to i64
12 %idxprom5 = sext i32 %j to i64
15 for.cond.cleanup: ; preds = %for.body
18 for.body: ; preds = %for.body, %entry
19 ; the loop gets vectorized
20 ; first consecutive load as vector load
21 ; CHECK: %wide.load = load <8 x i32>
22 ; second strided load scalarized
32 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
33 %sum.015 = phi i32 [ 0, %entry ], [ %add7, %for.body ]
34 %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* %data, i64 %idxprom, i64 %indvars.iv
35 %0 = load i32, i32* %arrayidx2, align 4, !tbaa !1
36 %arrayidx6 = getelementptr inbounds [100 x i32], [100 x i32]* %data, i64 %indvars.iv, i64 %idxprom5
37 %1 = load i32, i32* %arrayidx6, align 4, !tbaa !1
38 %mul = mul nsw i32 %1, %0
39 %add = add i32 %sum.015, 4
40 %add7 = add i32 %add, %mul
41 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
42 %exitcond = icmp eq i64 %indvars.iv.next, 100
43 br i1 %exitcond, label %for.cond.cleanup, label %for.body
46 attributes #0 = { "target-cpu"="core-avx2" "target-features"="+avx,+avx2,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3" }
50 !0 = !{!"clang version 4.0.0 (cfe/trunk 284570)"}
52 !2 = !{!"int", !3, i64 0}
53 !3 = !{!"omnipotent char", !4, i64 0}
54 !4 = !{!"Simple C/C++ TBAA"}