Revert "Strip metadata when speculatively hoisting instructions"
[oota-llvm.git] / test / Analysis / TypeBasedAliasAnalysis / licm.ll
1 ; RUN: opt -tbaa -licm -S < %s | FileCheck %s
2
3 ; LICM should be able to hoist the address load out of the loop
4 ; by using TBAA information.
5
6 ; CHECK: @foo
7 ; CHECK:      entry:
8 ; CHECK-NEXT:   %tmp3 = load double*, double** @P, !tbaa !0
9 ; CHECK-NEXT:   br label %for.body
10
11 @P = common global double* null
12
13 define void @foo(i64 %n) nounwind {
14 entry:
15   br label %for.body
16
17 for.body:                                         ; preds = %entry, %for.body
18   %i.07 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
19   %tmp3 = load double*, double** @P, !tbaa !1
20   %scevgep = getelementptr double, double* %tmp3, i64 %i.07
21   %tmp4 = load double, double* %scevgep, !tbaa !2
22   %mul = fmul double %tmp4, 2.300000e+00
23   store double %mul, double* %scevgep, !tbaa !2
24   %inc = add i64 %i.07, 1
25   %exitcond = icmp eq i64 %inc, %n
26   br i1 %exitcond, label %for.end, label %for.body
27
28 for.end:                                          ; preds = %for.body, %entry
29   ret void
30 }
31
32 !0 = !{!"root", null}
33 !1 = !{!6, !6, i64 0}
34 !2 = !{!7, !7, i64 0}
35
36 ; LICM shouldn't hoist anything here.
37
38 ; CHECK: @bar
39 ; CHECK: loop:
40 ; CHECK: load
41 ; CHECK: store
42 ; CHECK: load
43 ; CHECK: store
44 ; CHECK: br label %loop
45
46 define void @bar(i8** %p) nounwind {
47 entry:
48   %q = bitcast i8** %p to i8*
49   br label %loop
50
51 loop:
52   %tmp51 = load i8*, i8** %p, !tbaa !4
53   store i8* %tmp51, i8** %p
54   %tmp40 = load i8, i8* %q, !tbaa !5
55   store i8 %tmp40, i8* %q
56   br label %loop
57 }
58
59 !3 = !{!"pointer", !8}
60 !4 = !{!8, !8, i64 0}
61 !5 = !{!9, !9, i64 0}
62 !6 = !{!"pointer", !0}
63 !7 = !{!"double", !0}
64 !8 = !{!"char", !9}
65 !9 = !{!"root", null}