1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt %s -newgvn -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 define i8* @test1(i8** %v0, i8** %v1) {
10 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], !nonnull !0
11 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
12 ; CHECK-NEXT: ret i8* [[V2]]
15 %v2 = load i8*, i8** %v0, !nonnull !0
16 store i8* %v2, i8** %v1
17 %v3 = load i8*, i8** %v1
21 ; FIXME: could propagate nonnull to first load?
22 define i8* @test2(i8** %v0, i8** %v1) {
23 ; CHECK-LABEL: @test2(
25 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
27 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
28 ; CHECK-NEXT: ret i8* [[V2]]
31 %v2 = load i8*, i8** %v0
32 store i8* %v2, i8** %v1
33 %v3 = load i8*, i8** %v1, !nonnull !0
37 declare void @use1(i8* %a) readonly
39 define i8* @test3(i8** %v0) {
40 ; CHECK-LABEL: @test3(
42 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
44 ; CHECK-NEXT: call void @use1(i8* [[V1]])
45 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
47 ; CHECK-NEXT: ret i8* [[V1]]
49 ; CHECK-NEXT: ret i8* [[V1]]
52 %v1 = load i8*, i8** %v0
53 call void @use1(i8* %v1)
54 br i1 undef, label %bb1, label %bb2
57 %v2 = load i8*, i8** %v0, !nonnull !0
61 %v3 = load i8*, i8** %v0
65 define i8* @test4(i8** %v0) {
66 ; CHECK-LABEL: @test4(
68 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]]
70 ; CHECK-NEXT: call void @use1(i8* [[V1]])
71 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
73 ; CHECK-NEXT: ret i8* [[V1]]
75 ; CHECK-NEXT: ret i8* [[V1]]
78 %v1 = load i8*, i8** %v0
79 call void @use1(i8* %v1)
80 br i1 undef, label %bb1, label %bb2
83 %v2 = load i8*, i8** %v0
87 %v3 = load i8*, i8** %v0, !nonnull !0
91 define i8* @test5(i8** %v0) {
92 ; CHECK-LABEL: @test5(
94 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], !nonnull !0
95 ; CHECK-NEXT: call void @use1(i8* [[V1]])
96 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
98 ; CHECK-NEXT: ret i8* [[V1]]
100 ; CHECK-NEXT: ret i8* [[V1]]
103 %v1 = load i8*, i8** %v0, !nonnull !0
104 call void @use1(i8* %v1)
105 br i1 undef, label %bb1, label %bb2
108 %v2 = load i8*, i8** %v0
112 %v3 = load i8*, i8** %v0
116 define i8* @test6(i8** %v0, i8** %v1) {
117 ; CHECK-LABEL: @test6(
119 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
121 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], !nonnull !0
122 ; CHECK-NEXT: store i8* [[V2]], i8** [[V1:%.*]]
123 ; CHECK-NEXT: ret i8* [[V2]]
125 ; CHECK-NEXT: [[V4:%.*]] = load i8*, i8** [[V0]]
126 ; CHECK-NOT: !nonnull
127 ; CHECK-NEXT: store i8* [[V4]], i8** [[V1]]
128 ; CHECK-NOT: !nonnull
129 ; CHECK-NEXT: ret i8* [[V4]]
132 br i1 undef, label %bb1, label %bb2
135 %v2 = load i8*, i8** %v0, !nonnull !0
136 store i8* %v2, i8** %v1
137 %v3 = load i8*, i8** %v1
141 %v4 = load i8*, i8** %v0
142 store i8* %v4, i8** %v1
143 %v5 = load i8*, i8** %v1, !nonnull !0
147 declare void @use2(i8* %a)
149 define i8* @test7(i8** %v0) {
150 ; CHECK-LABEL: @test7(
152 ; CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[V0:%[a-z0-9]+]], !nonnull !0
153 ; CHECK-NEXT: call void @use2(i8* [[V1]])
154 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
156 ; CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[V0]]
157 ; CHECK-NOT: !nonnull
158 ; CHECK-NEXT: ret i8* [[V2]]
160 ; CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[V0]]
161 ; CHECK-NOT: !nonnull
162 ; CHECK-NEXT: ret i8* [[V3]]
165 %v1 = load i8*, i8** %v0, !nonnull !0
166 call void @use2(i8* %v1)
167 br i1 undef, label %bb1, label %bb2
170 %v2 = load i8*, i8** %v0
174 %v3 = load i8*, i8** %v0