]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Analysis/DependenceAnalysis/NonCanonicalizedSubscript.ll
Vendor import of llvm trunk r338150:
[FreeBSD/FreeBSD.git] / test / Analysis / DependenceAnalysis / NonCanonicalizedSubscript.ll
1 ; RUN: opt < %s -analyze -basicaa -da | FileCheck %s -check-prefix=DELIN
2
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.6.0"
5
6 ; for (int i = 0; i < 100; ++i) {
7 ;   int t0 = a[i][i];
8 ;   int t1 = t0 + 1;
9 ;   a[i][5] = t1;
10 ; }
11 ; The subscript 5 in a[i][5] is deliberately an i32, mismatching the types of
12 ; other subscript. DependenceAnalysis before the fix crashed due to this
13 ; mismatch.
14 define void @i32_subscript([100 x [100 x i32]]* %a, i32* %b) {
15 ; DELIN-LABEL: 'Dependence Analysis' for function 'i32_subscript'
16 entry:
17   br label %for.body
18
19 for.body:
20 ; DELIN: da analyze - none!
21 ; DELIN: da analyze - anti [=|<]!
22 ; DELIN: da analyze - none!
23   %i = phi i64 [ 0, %entry ], [ %i.inc, %for.body ]
24   %a.addr = getelementptr [100 x [100 x i32]], [100 x [100 x i32]]* %a, i64 0, i64 %i, i64 %i
25   %a.addr.2 = getelementptr [100 x [100 x i32]], [100 x [100 x i32]]* %a, i64 0, i64 %i, i32 5
26   %0 = load i32, i32* %a.addr, align 4
27   %1 = add i32 %0, 1
28   store i32 %1, i32* %a.addr.2, align 4
29   %i.inc = add nsw i64 %i, 1
30   %exitcond = icmp ne i64 %i.inc, 100
31   br i1 %exitcond, label %for.body, label %for.end
32
33 for.end:
34   ret void
35 }
36
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38 target triple = "x86_64-unknown-linux-gnu"
39
40 ;  unsigned i, j;
41 ;  for (i = 1; i < SIZE; i++) {
42 ;    for (j = i; j < SIZE; j++) {
43 ;      a[i][j] = a[i+1][j-1] + 2;
44 ;    }
45 ;  }
46 ;  Extends the previous example to coupled MIV subscripts.
47
48
49 @a = global [10004 x [10004 x i32]] zeroinitializer, align 16
50
51 ; Function Attrs: nounwind uwtable
52 define void @coupled_miv_type_mismatch(i32 %n) #0 {
53 ; DELIN-LABEL: 'Dependence Analysis' for function 'coupled_miv_type_mismatch'
54 entry:
55   br label %for.cond
56
57 ; DELIN: da analyze - input [* *]!
58 ; DELIN: da analyze - anti [* *|<]!
59 ; DELIN: da analyze - none!
60 for.cond:                                         ; preds = %for.inc11, %entry
61   %indvars.iv11 = phi i64 [ %indvars.iv.next12, %for.inc11 ], [ 1, %entry ]
62   %exitcond14 = icmp ne i64 %indvars.iv11, 10000
63   br i1 %exitcond14, label %for.cond1.preheader, label %for.end13
64
65 for.cond1.preheader:                              ; preds = %for.cond
66   %0 = trunc i64 %indvars.iv11 to i32
67   br label %for.cond1
68
69 for.cond1:                                        ; preds = %for.cond1.preheader, %for.body3
70   %indvars.iv8 = phi i64 [ %indvars.iv11, %for.cond1.preheader ], [ %indvars.iv.next9, %for.body3 ]
71   %j.0 = phi i32 [ %inc, %for.body3 ], [ %0, %for.cond1.preheader ]
72   %lftr.wideiv = trunc i64 %indvars.iv8 to i32
73   %exitcond = icmp ne i32 %lftr.wideiv, 10000
74   br i1 %exitcond, label %for.body3, label %for.inc11
75
76 for.body3:                                        ; preds = %for.cond1
77   %sub = add nsw i32 %j.0, -1
78   %idxprom = zext i32 %sub to i64
79   %1 = add nuw nsw i64 %indvars.iv11, 1
80   %arrayidx5 = getelementptr inbounds [10004 x [10004 x i32]], [10004 x [10004 x i32]]* @a, i64 0, i64 %1, i64 %idxprom
81   %2 = load i32, i32* %arrayidx5, align 4
82   %add6 = add nsw i32 %2, 2
83   %arrayidx10 = getelementptr inbounds [10004 x [10004 x i32]], [10004 x [10004 x i32]]* @a, i64 0, i64 %indvars.iv11, i64 %indvars.iv8
84   store i32 %add6, i32* %arrayidx10, align 4
85   %indvars.iv.next9 = add nuw nsw i64 %indvars.iv8, 1
86   %inc = add nuw nsw i32 %j.0, 1
87   br label %for.cond1
88
89 for.inc11:                                        ; preds = %for.cond1
90   %indvars.iv.next12 = add nuw nsw i64 %indvars.iv11, 1
91   br label %for.cond
92
93 for.end13:                                        ; preds = %for.cond
94   ret void
95 }
96
97 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
98
99 !llvm.ident = !{!0}
100
101 !0 = !{!"clang version 3.7.0 (https://vaivaswatha@bitbucket.org/compilertree/amd_clang.git 93a05fb75ee3411d24e8b2b184fc766a5318403e) (https://vaivaswatha@bitbucket.org/compilertree/amd_llvm.git 166d93d26efc912b517739f64d054a435e8e95cd)"}