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** @P, !tbaa !0
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** @P, !tbaa !1
20 %scevgep = getelementptr double* %tmp3, i64 %i.07
21 %tmp4 = load 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
32 !0 = metadata !{metadata !"root", null}
33 !1 = metadata !{metadata !"pointer", metadata !0}
34 !2 = metadata !{metadata !"double", metadata !0}
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** %p, !tbaa !4
53 store i8* %tmp51, i8** %p
54 %tmp40 = load i8* %q, !tbaa !5
55 store i8 %tmp40, i8* %q
59 !3 = metadata !{metadata !"pointer", metadata !4}
60 !4 = metadata !{metadata !"char", metadata !5}
61 !5 = metadata !{metadata !"root", null}