1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt %s -passes=newgvn -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define ptr @test1(ptr %v0, ptr %v1) {
7 ; CHECK-LABEL: define ptr @test1
8 ; CHECK-SAME: (ptr [[V0:%.*]], ptr [[V1:%.*]]) {
10 ; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0]], align 8
11 ; CHECK-NEXT: store ptr [[V2]], ptr [[V1]], align 8
12 ; CHECK-NEXT: ret ptr [[V2]]
15 %v2 = load ptr, ptr %v0, !nonnull !0
16 store ptr %v2, ptr %v1
17 %v3 = load ptr, ptr %v1
21 ; FIXME: could propagate nonnull to first load?
22 define ptr @test2(ptr %v0, ptr %v1) {
23 ; CHECK-LABEL: define ptr @test2
24 ; CHECK-SAME: (ptr [[V0:%.*]], ptr [[V1:%.*]]) {
26 ; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0]], align 8
27 ; CHECK-NEXT: store ptr [[V2]], ptr [[V1]], align 8
28 ; CHECK-NEXT: ret ptr [[V2]]
31 %v2 = load ptr, ptr %v0
32 store ptr %v2, ptr %v1
33 %v3 = load ptr, ptr %v1, !nonnull !0
37 declare void @use1(ptr %a) readonly
39 define ptr @test3(ptr %v0) {
40 ; CHECK-LABEL: define ptr @test3
41 ; CHECK-SAME: (ptr [[V0:%.*]]) {
43 ; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0]], align 8
44 ; CHECK-NEXT: call void @use1(ptr [[V1]])
45 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
47 ; CHECK-NEXT: ret ptr [[V1]]
49 ; CHECK-NEXT: ret ptr [[V1]]
52 %v1 = load ptr, ptr %v0
53 call void @use1(ptr %v1)
54 br i1 undef, label %bb1, label %bb2
57 %v2 = load ptr, ptr %v0, !nonnull !0
61 %v3 = load ptr, ptr %v0
65 define ptr @test4(ptr %v0) {
66 ; CHECK-LABEL: define ptr @test4
67 ; CHECK-SAME: (ptr [[V0:%.*]]) {
69 ; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0]], align 8
70 ; CHECK-NEXT: call void @use1(ptr [[V1]])
71 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
73 ; CHECK-NEXT: ret ptr [[V1]]
75 ; CHECK-NEXT: ret ptr [[V1]]
78 %v1 = load ptr, ptr %v0
79 call void @use1(ptr %v1)
80 br i1 undef, label %bb1, label %bb2
83 %v2 = load ptr, ptr %v0
87 %v3 = load ptr, ptr %v0, !nonnull !0
91 define ptr @test5(ptr %v0) {
92 ; CHECK-LABEL: define ptr @test5
93 ; CHECK-SAME: (ptr [[V0:%.*]]) {
95 ; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0]], align 8
96 ; CHECK-NEXT: call void @use1(ptr [[V1]])
97 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
99 ; CHECK-NEXT: ret ptr [[V1]]
101 ; CHECK-NEXT: ret ptr [[V1]]
104 %v1 = load ptr, ptr %v0, !nonnull !0
105 call void @use1(ptr %v1)
106 br i1 undef, label %bb1, label %bb2
109 %v2 = load ptr, ptr %v0
113 %v3 = load ptr, ptr %v0
117 define ptr @test6(ptr %v0, ptr %v1) {
118 ; CHECK-LABEL: define ptr @test6
119 ; CHECK-SAME: (ptr [[V0:%.*]], ptr [[V1:%.*]]) {
121 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
123 ; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0]], align 8
124 ; CHECK-NEXT: store ptr [[V2]], ptr [[V1]], align 8
125 ; CHECK-NEXT: ret ptr [[V2]]
127 ; CHECK-NEXT: [[V4:%.*]] = load ptr, ptr [[V0]], align 8
128 ; CHECK-NEXT: store ptr [[V4]], ptr [[V1]], align 8
129 ; CHECK-NEXT: ret ptr [[V4]]
132 br i1 undef, label %bb1, label %bb2
135 %v2 = load ptr, ptr %v0, !nonnull !0
136 store ptr %v2, ptr %v1
137 %v3 = load ptr, ptr %v1
141 %v4 = load ptr, ptr %v0
142 store ptr %v4, ptr %v1
143 %v5 = load ptr, ptr %v1, !nonnull !0
147 declare void @use2(ptr %a)
149 define ptr @test7(ptr %v0) {
150 ; CHECK-LABEL: define ptr @test7
151 ; CHECK-SAME: (ptr [[V0:%.*]]) {
153 ; CHECK-NEXT: [[V1:%.*]] = load ptr, ptr [[V0]], align 8, !nonnull !0
154 ; CHECK-NEXT: call void @use2(ptr [[V1]])
155 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
157 ; CHECK-NEXT: [[V2:%.*]] = load ptr, ptr [[V0]], align 8
158 ; CHECK-NEXT: ret ptr [[V2]]
160 ; CHECK-NEXT: [[V3:%.*]] = load ptr, ptr [[V0]], align 8
161 ; CHECK-NEXT: ret ptr [[V3]]
164 %v1 = load ptr, ptr %v0, !nonnull !0
165 call void @use2(ptr %v1)
166 br i1 undef, label %bb1, label %bb2
169 %v2 = load ptr, ptr %v0
173 %v3 = load ptr, ptr %v0