1 ; RUN: opt < %s -passes=gvn-sink -S | FileCheck %s
3 ; Check that nonnull metadata for non-dominating loads is not propagated.
6 ; CHECK: %[[ptr:.*]] = phi ptr
7 ; CHECK: %[[load:.*]] = load ptr, ptr %[[ptr]]
9 ; CHECK: ret ptr %[[load]]
10 define ptr @test1(i1 zeroext %flag, ptr %p) {
12 br i1 %flag, label %if.then, label %if.else
16 %aa = load ptr, ptr %a, !nonnull !0
25 %c = phi ptr [ %aa, %if.then ], [ %bb, %if.else ]
29 ; CHECK-LABEL: @test2(
30 ; CHECK-LABEL: if.end:
31 ; CHECK: %[[ptr:.*]] = phi ptr
32 ; CHECK: %[[load:.*]] = load ptr, ptr %[[ptr]]
34 ; CHECK: ret ptr %[[load]]
35 define ptr @test2(i1 zeroext %flag, ptr %p) {
37 br i1 %flag, label %if.then, label %if.else
41 %aa = load ptr, ptr %a
46 %bb= load ptr, ptr %b, !nonnull !0
50 %c = phi ptr [ %aa, %if.then ], [ %bb, %if.else ]
54 ; Check that nontemporal markings are propagated if both original stores are
56 ; CHECK-LABEL: @nontemporal(
57 ; CHECK-LABEL: if.end:
60 define void @nontemporal(i1 zeroext %flag, ptr %p) {
62 br i1 %flag, label %if.then, label %if.else
66 store ptr %p, ptr %a, align 8, !nontemporal !1
71 store ptr %p, ptr %b, align 8, !nontemporal !1
78 ; CHECK-LABEL: @nontemporal_mismatch(
79 ; CHECK-NOT: !nontemporal
80 define void @nontemporal_mismatch(i1 zeroext %flag, ptr %p) {
82 br i1 %flag, label %if.then, label %if.else
86 store ptr %p, ptr %a, align 8
91 store ptr %p, ptr %b, align 8, !nontemporal !1