1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; REQUIRES: x86-registered-target
3 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
4 ;; Now that we do store refinement, we have to verify that we add fake uses
5 ;; when we skip existing stores.
6 ;; We also are testing that various variations that cause stores to move classes
7 ;; have the right class movement happen
8 ;; All of these tests result in verification failures if it does not.
10 source_filename = "bugpoint-output-daef094.bc"
11 target triple = "x86_64-apple-darwin16.5.0"
13 %struct.eggs = type {}
15 define void @spam(ptr %a, i1 %arg) {
18 ; CHECK-NEXT: store ptr null, ptr [[A:%.*]], align 8
19 ; CHECK-NEXT: br label [[BB1:%.*]]
21 ; CHECK-NEXT: br i1 [[ARG:%.*]], label [[BB3:%.*]], label [[BB2:%.*]]
23 ; CHECK-NEXT: call void @baz()
24 ; CHECK-NEXT: br label [[BB1]]
26 ; CHECK-NEXT: store i32 0, ptr undef, align 4
27 ; CHECK-NEXT: store ptr null, ptr [[A]], align 8
28 ; CHECK-NEXT: unreachable
31 store ptr null, ptr %a
34 bb1: ; preds = %bb2, %bb
35 br i1 %arg, label %bb3, label %bb2
42 store i32 0, ptr undef
43 ;; This store is defined by a memoryphi of the call and the first store
44 ;; At first, we will prove it equivalent to the first store above.
45 ;; Then the call will become reachable, and the equivalence will be removed
46 ;; Without it being a use of the first store, we will not update the store
48 store ptr null, ptr %a
55 define void @a(i1 %arg) {
58 ; CHECK-NEXT: br label [[C:%.*]]
60 ; CHECK-NEXT: store i64 undef, ptr null, align 8
61 ; CHECK-NEXT: br label [[E:%.*]]
63 ; CHECK-NEXT: store ptr undef, ptr null, align 8
64 ; CHECK-NEXT: br i1 [[ARG:%.*]], label [[C]], label [[E]]
70 %d = phi ptr [ undef, %b ], [ null, %e ]
71 store i64 undef, ptr %d
75 ;; The memory for this load starts out equivalent to just the store in c, we later discover the store after us, and
76 ;; need to make sure the right set of values get marked as changed after memory leaders change
77 %g = load ptr, ptr null
78 store ptr undef, ptr null
79 br i1 %arg, label %c, label %e
82 %struct.hoge = type {}
84 define void @widget(ptr %arg, i1 %arg2) {
85 ; CHECK-LABEL: @widget(
87 ; CHECK-NEXT: br label [[BB1:%.*]]
89 ; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB1]] ]
90 ; CHECK-NEXT: store ptr [[TMP]], ptr undef, align 8
91 ; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB1]], label [[BB2:%.*]]
93 ; CHECK-NEXT: [[TMP3:%.*]] = phi i64 [ [[TMP8:%.*]], [[BB7:%.*]] ], [ 0, [[BB1]] ]
94 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[TMP3]], 0
95 ; CHECK-NEXT: br i1 [[TMP4]], label [[BB7]], label [[BB5:%.*]]
97 ; CHECK-NEXT: [[TMP6:%.*]] = load i64, ptr null, align 8
98 ; CHECK-NEXT: call void @quux()
99 ; CHECK-NEXT: store i64 [[TMP6]], ptr undef, align 8
100 ; CHECK-NEXT: br label [[BB7]]
102 ; CHECK-NEXT: [[TMP8]] = add i64 [[TMP3]], 1
103 ; CHECK-NEXT: br label [[BB2]]
108 bb1: ; preds = %bb1, %bb
109 %tmp = phi ptr [ %arg, %bb ], [ null, %bb1 ]
110 store ptr %tmp, ptr undef
111 br i1 %arg2, label %bb1, label %bb2
113 bb2: ; preds = %bb7, %bb1
114 %tmp3 = phi i64 [ %tmp8, %bb7 ], [ 0, %bb1 ]
115 %tmp4 = icmp eq i64 %tmp3, 0
116 br i1 %tmp4, label %bb7, label %bb5
119 ;; Originally thought equal to the store that comes after it until the phi edges
120 ;; are completely traversed
121 %tmp6 = load i64, ptr null
123 store i64 %tmp6, ptr undef
126 bb7: ; preds = %bb5, %bb2
127 %tmp8 = add i64 %tmp3, 1
135 define void @b(i1 %arg) {
137 ; CHECK-NEXT: [[C:%.*]] = alloca [[STRUCT_A:%.*]], align 8
138 ; CHECK-NEXT: br label [[D:%.*]]
140 ; CHECK-NEXT: unreachable
142 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[C]], align 4
143 ; CHECK-NEXT: br i1 [[ARG:%.*]], label [[I:%.*]], label [[J:%.*]]
145 ; CHECK-NEXT: br i1 true, label [[K:%.*]], label [[M:%.*]]
147 ; CHECK-NEXT: br label [[L:%.*]]
149 ; CHECK-NEXT: unreachable
151 ; CHECK-NEXT: br label [[M]]
153 %c = alloca %struct.a
161 %h = getelementptr i8, ptr %c
162 %e = load i32, ptr %h
163 br i1 %arg, label %i, label %j
166 br i1 %arg, label %k, label %m
172 %n = phi i32 [ %e, %k ]
173 ;; Becomes equal and then not equal to the other store, and
174 ;; along the way, the load.