1 ; RUN: opt -tbaa -licm -S < %s | FileCheck %s
3 ; LICM should be able to hoist the address load out of the loop
4 ; by using TBAA information.
8 ; CHECK-NEXT: %tmp3 = load double*, double** @P
9 ; CHECK-NEXT: br label %for.body
11 @P = common global double* null
13 define void @foo(i64 %n) nounwind {
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
28 for.end: ; preds = %for.body, %entry
36 ; LICM shouldn't hoist anything here.
44 ; CHECK: br label %loop
46 define void @bar(i8** %p) nounwind {
48 %q = bitcast i8** %p to i8*
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
59 !3 = !{!"pointer", !8}
61 !5 = !{!10, !10, i64 0}
62 !6 = !{!"pointer", !0}
66 !10 = !{!"scalar-type", !9}