]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/LoopVectorize/X86/strided_load_cost.ll
Vendor import of llvm trunk r291274:
[FreeBSD/FreeBSD.git] / test / Transforms / LoopVectorize / X86 / strided_load_cost.ll
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
4
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-unknown-linux-gnu"
7
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 {
10 entry:
11   %idxprom = sext i32 %i to i64
12   %idxprom5 = sext i32 %j to i64
13   br label %for.body
14
15   for.cond.cleanup:                                 ; preds = %for.body
16   ret i32 %add7
17
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
23   ; CHECK: load i32
24   ; CHECK: load i32
25   ; CHECK: load i32
26   ; CHECK: load i32
27   ; CHECK: load i32
28   ; CHECK: load i32
29   ; CHECK: load i32
30   ; CHECK: load i32
31
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
44 }
45
46 attributes #0 = { "target-cpu"="core-avx2" "target-features"="+avx,+avx2,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3" }
47
48 !llvm.ident = !{!0}
49
50 !0 = !{!"clang version 4.0.0 (cfe/trunk 284570)"}
51 !1 = !{!2, !2, i64 0}
52 !2 = !{!"int", !3, i64 0}
53 !3 = !{!"omnipotent char", !4, i64 0}
54 !4 = !{!"Simple C/C++ TBAA"}