xref: /llvm-project/llvm/test/Transforms/NewGVN/pr31501.ll (revision 229640343e400394b315c6798c7c19e8a9bd188c)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=newgvn -S | FileCheck %s
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4
5%struct.foo = type { ptr, %struct.zot, ptr }
6%struct.zot = type { i64 }
7%struct.barney = type <{ ptr, %struct.wibble, %struct.snork, %struct.quux.4, %struct.snork.10, ptr, ptr, i32, i8, i8, [2 x i8] }>
8%struct.wibble = type { %struct.pluto, %struct.bar }
9%struct.pluto = type { %struct.quux }
10%struct.quux = type { %struct.eggs }
11%struct.eggs = type { %struct.zot.0, %struct.widget }
12%struct.zot.0 = type { ptr, ptr, ptr }
13%struct.widget = type { %struct.barney.1 }
14%struct.barney.1 = type { [8 x i8] }
15%struct.bar = type { [3 x %struct.widget] }
16%struct.snork = type <{ %struct.wobble, %struct.bar.3, [7 x i8] }>
17%struct.wobble = type { %struct.wombat }
18%struct.wombat = type { %struct.zot.2 }
19%struct.zot.2 = type { %struct.zot.0, %struct.ham }
20%struct.ham = type { %struct.barney.1 }
21%struct.bar.3 = type { i8 }
22%struct.quux.4 = type <{ %struct.quux.5, %struct.snork.9, [7 x i8] }>
23%struct.quux.5 = type { %struct.widget.6 }
24%struct.widget.6 = type { %struct.spam }
25%struct.spam = type { %struct.zot.0, %struct.ham.7 }
26%struct.ham.7 = type { %struct.barney.8 }
27%struct.barney.8 = type { [24 x i8] }
28%struct.snork.9 = type { i8 }
29%struct.snork.10 = type <{ %struct.foo.11, %struct.spam.15, [7 x i8] }>
30%struct.foo.11 = type { %struct.snork.12 }
31%struct.snork.12 = type { %struct.wombat.13 }
32%struct.wombat.13 = type { %struct.zot.0, %struct.wibble.14 }
33%struct.wibble.14 = type { %struct.barney.8 }
34%struct.spam.15 = type { i8 }
35%struct.ham.16 = type { %struct.pluto.17, %struct.pluto.17 }
36%struct.pluto.17 = type { %struct.bar.18 }
37%struct.bar.18 = type { ptr, %struct.zot.20, %struct.barney.22 }
38%struct.baz = type { ptr }
39%struct.wibble.19 = type <{ %struct.baz, ptr, ptr, i8, [7 x i8] }>
40%struct.zot.20 = type { %struct.ham.21 }
41%struct.ham.21 = type { %struct.baz }
42%struct.barney.22 = type { %struct.blam }
43%struct.blam = type { i64 }
44%struct.wobble.23 = type { %struct.spam.24, ptr }
45%struct.spam.24 = type { %struct.bar.25, ptr }
46%struct.bar.25 = type <{ ptr, i8, i8 }>
47%struct.zot.26 = type { ptr, i32, ptr }
48%struct.widget.27 = type { %struct.zot.26, ptr }
49%struct.wombat.28 = type <{ ptr, i8, i8, [6 x i8] }>
50
51; Function Attrs: norecurse nounwind ssp uwtable
52define weak_odr hidden ptr @quux(ptr %arg, ptr %arg1) local_unnamed_addr #0 align 2 {
53; CHECK-LABEL: @quux(
54; CHECK-NEXT:  bb:
55; CHECK-NEXT:    [[TMP:%.*]] = getelementptr inbounds [[STRUCT_BARNEY:%.*]], ptr [[ARG:%.*]], i64 0, i32 3, i32 0, i32 0, i32 0
56; CHECK-NEXT:    [[TMP3:%.*]] = load ptr, ptr [[TMP]], align 8, !tbaa [[TBAA2:![0-9]+]]
57; CHECK-NEXT:    [[TMP4:%.*]] = getelementptr inbounds [[STRUCT_BARNEY]], ptr [[ARG]], i64 0, i32 3, i32 0, i32 0, i32 0, i32 0, i32 1
58; CHECK-NEXT:    [[TMP6:%.*]] = load ptr, ptr [[TMP4]], align 8, !tbaa [[TBAA7:![0-9]+]]
59; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq ptr [[TMP3]], [[TMP6]]
60; CHECK-NEXT:    br i1 [[TMP7]], label [[BB21:%.*]], label [[BB8:%.*]]
61; CHECK:       bb8:
62; CHECK-NEXT:    br label [[BB11:%.*]]
63; CHECK:       bb9:
64; CHECK-NEXT:    [[TMP10:%.*]] = icmp eq ptr [[TMP18:%.*]], [[TMP6]]
65; CHECK-NEXT:    br i1 [[TMP10]], label [[BB19:%.*]], label [[BB11]]
66; CHECK:       bb11:
67; CHECK-NEXT:    [[TMP12:%.*]] = phi ptr [ [[TMP17:%.*]], [[BB9:%.*]] ], [ undef, [[BB8]] ]
68; CHECK-NEXT:    [[TMP13:%.*]] = phi ptr [ [[TMP18]], [[BB9]] ], [ [[TMP3]], [[BB8]] ]
69; CHECK-NEXT:    [[TMP15:%.*]] = load ptr, ptr [[TMP13]], align 8, !tbaa [[TBAA8:![0-9]+]]
70; CHECK-NEXT:    [[TMP16:%.*]] = icmp eq ptr [[TMP15]], [[ARG1:%.*]]
71; CHECK-NEXT:    [[TMP17]] = select i1 [[TMP16]], ptr [[TMP13]], ptr [[TMP12]]
72; CHECK-NEXT:    [[TMP18]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[TMP13]], i64 1
73; CHECK-NEXT:    br i1 [[TMP16]], label [[BB19]], label [[BB9]]
74; CHECK:       bb19:
75; CHECK-NEXT:    [[TMP20:%.*]] = phi ptr [ null, [[BB9]] ], [ [[TMP17]], [[BB11]] ]
76; CHECK-NEXT:    br label [[BB21]]
77; CHECK:       bb21:
78; CHECK-NEXT:    [[TMP22:%.*]] = phi ptr [ null, [[BB:%.*]] ], [ [[TMP20]], [[BB19]] ]
79; CHECK-NEXT:    ret ptr [[TMP22]]
80;
81bb:
82  %tmp = getelementptr inbounds %struct.barney, ptr %arg, i64 0, i32 3, i32 0, i32 0, i32 0
83  %tmp3 = load ptr, ptr %tmp, align 8, !tbaa !2
84  %tmp4 = getelementptr inbounds %struct.barney, ptr %arg, i64 0, i32 3, i32 0, i32 0, i32 0, i32 0, i32 1
85  %tmp6 = load ptr, ptr %tmp4, align 8, !tbaa !7
86  %tmp7 = icmp eq ptr %tmp3, %tmp6
87  br i1 %tmp7, label %bb21, label %bb8
88
89bb8:                                              ; preds = %bb
90  br label %bb11
91
92bb9:                                              ; preds = %bb11
93  %tmp10 = icmp eq ptr %tmp18, %tmp6
94  br i1 %tmp10, label %bb19, label %bb11
95
96bb11:                                             ; preds = %bb9, %bb8
97  %tmp12 = phi ptr [ %tmp17, %bb9 ], [ undef, %bb8 ]
98  %tmp13 = phi ptr [ %tmp18, %bb9 ], [ %tmp3, %bb8 ]
99  %tmp15 = load ptr, ptr %tmp13, align 8, !tbaa !8
100  %tmp16 = icmp eq ptr %tmp15, %arg1
101  %tmp17 = select i1 %tmp16, ptr %tmp13, ptr %tmp12
102  %tmp18 = getelementptr inbounds %struct.foo, ptr %tmp13, i64 1
103  br i1 %tmp16, label %bb19, label %bb9
104
105bb19:                                             ; preds = %bb11, %bb9
106  %tmp20 = phi ptr [ null, %bb9 ], [ %tmp17, %bb11 ]
107  br label %bb21
108
109bb21:                                             ; preds = %bb19, %bb
110  %tmp22 = phi ptr [ null, %bb ], [ %tmp20, %bb19 ]
111  ret ptr %tmp22
112}
113
114attributes #0 = { norecurse nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
115
116!llvm.module.flags = !{!0}
117!llvm.ident = !{!1}
118
119!0 = !{i32 1, !"PIC Level", i32 2}
120!1 = !{!"clang version 4.0.0"}
121!2 = !{!3, !4, i64 0}
122!3 = !{!"_ZTSN4llvm15SmallVectorBaseE", !4, i64 0, !4, i64 8, !4, i64 16}
123!4 = !{!"any pointer", !5, i64 0}
124!5 = !{!"omnipotent char", !6, i64 0}
125!6 = !{!"Simple C++ TBAA"}
126!7 = !{!3, !4, i64 8}
127!8 = !{!9, !4, i64 0}
128!9 = !{!"_ZTSN4llvm9RecordValE", !4, i64 0, !10, i64 8, !4, i64 16}
129!10 = !{!"_ZTSN4llvm14PointerIntPairIPNS_5RecTyELj1EbNS_21PointerLikeTypeTraitsIS2_EENS_18PointerIntPairInfoIS2_Lj1ES4_EEEE", !11, i64 0}
130!11 = !{!"long", !5, i64 0}
131