1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
2 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
4 target datalayout = "e-m:e-p:64:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 ; Check that nonnull metadata is not propagated from dominating load.
7 define void @combine_metadata_dominance1(ptr %p) {
8 ; CHECK-LABEL: define void @combine_metadata_dominance1
9 ; CHECK-SAME: (ptr [[P:%.*]]) {
11 ; CHECK-NEXT: br label [[BB1:%.*]]
13 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8
14 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
15 ; CHECK-NEXT: ret void
18 %a = load ptr, ptr %p, !nonnull !0
28 declare i32 @use(ptr, i32) readonly
30 ; Check that nonnull from the dominated load does not get propagated.
31 ; There are some cases where it would be safe to keep it.
32 define void @combine_metadata_dominance2(ptr %p, i1 %c1) {
33 ; CHECK-LABEL: define void @combine_metadata_dominance2
34 ; CHECK-SAME: (ptr [[P:%.*]], i1 [[C1:%.*]]) {
36 ; CHECK-NEXT: br i1 [[C1]], label [[BB1:%.*]], label [[BB2:%.*]]
38 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8
39 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
40 ; CHECK-NEXT: ret void
42 ; CHECK-NEXT: ret void
46 br i1 %c1, label %bb1, label %bb2
49 %b = load ptr, ptr %p, !nonnull !0
58 define void @combine_metadata_dominance3(ptr %p) {
59 ; CHECK-LABEL: define void @combine_metadata_dominance3
60 ; CHECK-SAME: (ptr [[P:%.*]]) {
62 ; CHECK-NEXT: br label [[BB1:%.*]]
64 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8, !nonnull !0, !noundef !0
65 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
66 ; CHECK-NEXT: ret void
69 %a = load ptr, ptr %p, !nonnull !0, !noundef !1
79 define void @combine_metadata_dominance4(ptr %p) {
80 ; CHECK-LABEL: define void @combine_metadata_dominance4
81 ; CHECK-SAME: (ptr [[P:%.*]]) {
83 ; CHECK-NEXT: br label [[BB1:%.*]]
85 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8
86 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
87 ; CHECK-NEXT: ret void
90 %a = load ptr, ptr %p, !nonnull !0
94 %b = load ptr, ptr %p, !noundef !1
100 define void @combine_metadata_dominance5(ptr %p) {
101 ; CHECK-LABEL: define void @combine_metadata_dominance5
102 ; CHECK-SAME: (ptr [[P:%.*]]) {
104 ; CHECK-NEXT: br label [[BB1:%.*]]
106 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8, !align !1
107 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
108 ; CHECK-NEXT: ret void
111 %a = load ptr, ptr %p, !align !2
115 %b = load ptr, ptr %p, !align !3
121 define void @combine_metadata_dominance6(ptr %p) {
122 ; CHECK-LABEL: define void @combine_metadata_dominance6
123 ; CHECK-SAME: (ptr [[P:%.*]]) {
125 ; CHECK-NEXT: br label [[BB1:%.*]]
127 ; CHECK-NEXT: [[A:%.*]] = load ptr, ptr [[P]], align 8, !align !2, !noundef !0
128 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4
129 ; CHECK-NEXT: ret void
132 %a = load ptr, ptr %p, !align !2, !noundef !1
136 %b = load ptr, ptr %p, !align !3
147 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { memory(read) }
149 ; CHECK: [[META0:![0-9]+]] = !{}
150 ; CHECK: [[META1:![0-9]+]] = !{i64 4}
151 ; CHECK: [[META2:![0-9]+]] = !{i64 8}