2 ; RUN: opt -passes=newgvn -S < %s | FileCheck %s
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"
5 %"class.llvm::SmallVector" = type { %"class.llvm::SmallVectorImpl", [1 x %"union.llvm::SmallVectorBase::U"] }
6 %"class.llvm::SmallVectorImpl" = type { %"class.llvm::SmallVectorTemplateBase" }
7 %"class.llvm::SmallVectorTemplateBase" = type { %"class.llvm::SmallVectorTemplateCommon" }
8 %"class.llvm::SmallVectorTemplateCommon" = type { %"class.llvm::SmallVectorBase" }
9 %"class.llvm::SmallVectorBase" = type { ptr, ptr, ptr, %"union.llvm::SmallVectorBase::U" }
10 %"union.llvm::SmallVectorBase::U" = type { x86_fp80 }
12 ; Function Attrs: ssp uwtable
13 define void @_Z4testv() #0 personality ptr @__gxx_personality_v0 {
16 ; CHECK: br i1 true, label %new.notnull.i11, label %if.end.i14
20 %sv = alloca %"class.llvm::SmallVector", align 16
21 call void @llvm.lifetime.start.p0(i64 64, ptr %sv) #1
22 %FirstEl.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 3
23 store ptr %FirstEl.i.i.i.i.i.i, ptr %sv, align 16, !tbaa !4
24 %EndX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
25 store ptr %FirstEl.i.i.i.i.i.i, ptr %EndX.i.i.i.i.i.i, align 8, !tbaa !4
26 %CapacityX.i.i.i.i.i.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
27 %add.ptr.i.i.i.i2.i.i = getelementptr inbounds %"union.llvm::SmallVectorBase::U", ptr %FirstEl.i.i.i.i.i.i, i64 2
28 store ptr %add.ptr.i.i.i.i2.i.i, ptr %CapacityX.i.i.i.i.i.i, align 16, !tbaa !4
29 %EndX.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 1
30 %0 = load ptr, ptr %EndX.i, align 8, !tbaa !4
31 %CapacityX.i = getelementptr inbounds %"class.llvm::SmallVector", ptr %sv, i64 0, i32 0, i32 0, i32 0, i32 0, i32 2
32 %cmp.i = icmp ult ptr %0, %add.ptr.i.i.i.i2.i.i
33 br i1 %cmp.i, label %Retry.i, label %if.end.i
35 Retry.i: ; preds = %.noexc, %entry
36 %1 = phi ptr [ %0, %entry ], [ %.pre.i, %.noexc ]
37 %new.isnull.i = icmp eq ptr %1, null
38 br i1 %new.isnull.i, label %invoke.cont, label %new.notnull.i
40 new.notnull.i: ; preds = %Retry.i
41 store i32 1, ptr %1, align 4, !tbaa !5
44 if.end.i: ; preds = %entry
45 invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr %sv, i64 0, i64 4)
46 to label %.noexc unwind label %lpad
48 .noexc: ; preds = %if.end.i
49 %.pre.i = load ptr, ptr %EndX.i, align 8, !tbaa !4
52 invoke.cont: ; preds = %new.notnull.i, %Retry.i
53 %add.ptr.i = getelementptr inbounds i8, ptr %1, i64 4
54 store ptr %add.ptr.i, ptr %EndX.i, align 8, !tbaa !4
55 %2 = load ptr, ptr %CapacityX.i, align 16, !tbaa !4
56 %cmp.i8 = icmp ult ptr %add.ptr.i, %2
57 br i1 %cmp.i8, label %new.notnull.i11, label %if.end.i14
59 Retry.i10: ; preds = %if.end.i14
60 %.pre.i13 = load ptr, ptr %EndX.i, align 8, !tbaa !4
61 %new.isnull.i9 = icmp eq ptr %.pre.i13, null
62 br i1 %new.isnull.i9, label %invoke.cont2, label %new.notnull.i11
64 new.notnull.i11: ; preds = %invoke.cont, %Retry.i10
65 %3 = phi ptr [ %.pre.i13, %Retry.i10 ], [ %add.ptr.i, %invoke.cont ]
66 store i32 2, ptr %3, align 4, !tbaa !5
67 br label %invoke.cont2
69 if.end.i14: ; preds = %invoke.cont
70 invoke void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr %sv, i64 0, i64 4)
71 to label %Retry.i10 unwind label %lpad
73 invoke.cont2: ; preds = %new.notnull.i11, %Retry.i10
74 %4 = phi ptr [ null, %Retry.i10 ], [ %3, %new.notnull.i11 ]
75 %add.ptr.i12 = getelementptr inbounds i8, ptr %4, i64 4
76 store ptr %add.ptr.i12, ptr %EndX.i, align 8, !tbaa !4
77 invoke void @_Z1gRN4llvm11SmallVectorIiLj8EEE(ptr %sv)
78 to label %invoke.cont3 unwind label %lpad
80 invoke.cont3: ; preds = %invoke.cont2
81 %5 = load ptr, ptr %sv, align 16, !tbaa !4
82 %cmp.i.i.i.i19 = icmp eq ptr %5, %FirstEl.i.i.i.i.i.i
83 br i1 %cmp.i.i.i.i19, label %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21, label %if.then.i.i.i20
85 if.then.i.i.i20: ; preds = %invoke.cont3
86 call void @free(ptr %5) #1
87 br label %_ZN4llvm11SmallVectorIiLj8EED1Ev.exit21
89 _ZN4llvm11SmallVectorIiLj8EED1Ev.exit21: ; preds = %invoke.cont3, %if.then.i.i.i20
90 call void @llvm.lifetime.end.p0(i64 64, ptr %sv) #1
93 lpad: ; preds = %if.end.i14, %if.end.i, %invoke.cont2
94 %6 = landingpad { ptr, i32 }
96 %7 = load ptr, ptr %sv, align 16, !tbaa !4
97 %cmp.i.i.i.i = icmp eq ptr %7, %FirstEl.i.i.i.i.i.i
98 br i1 %cmp.i.i.i.i, label %eh.resume, label %if.then.i.i.i
100 if.then.i.i.i: ; preds = %lpad
101 call void @free(ptr %7) #1
104 eh.resume: ; preds = %if.then.i.i.i, %lpad
105 resume { ptr, i32 } %6
108 ; Function Attrs: nounwind
109 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1
111 declare i32 @__gxx_personality_v0(...)
113 declare void @_Z1gRN4llvm11SmallVectorIiLj8EEE(ptr) #2
115 ; Function Attrs: nounwind
116 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
118 declare void @_ZN4llvm15SmallVectorBase8grow_podEmm(ptr, i64, i64) #2
120 ; Function Attrs: nounwind
121 declare void @free(ptr nocapture) #3
123 attributes #0 = { ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
124 attributes #1 = { nounwind }
125 attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
126 attributes #3 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
128 !0 = !{!"any pointer", !1}
129 !1 = !{!"omnipotent char", !2}
130 !2 = !{!"Simple C/C++ TBAA"}
132 !4 = !{!0, !0, i64 0}
133 !5 = !{!3, !3, i64 0}