1 ; RUN: opt < %s -gvn-sink -S | FileCheck %s
3 ; Check that nonnull metadata for non-dominating loads is not propagated.
6 ; CHECK: %[[ptr:.*]] = phi i32**
7 ; CHECK: %[[load:.*]] = load i32*, i32** %[[ptr]]
9 ; CHECK: ret i32* %[[load]]
10 define i32* @test1(i1 zeroext %flag, i32*** %p) {
12 br i1 %flag, label %if.then, label %if.else
15 %a = load i32**, i32*** %p
16 %aa = load i32*, i32** %a, !nonnull !0
20 %b = load i32**, i32*** %p
21 %bb= load i32*, i32** %b
25 %c = phi i32* [ %aa, %if.then ], [ %bb, %if.else ]
29 ; CHECK-LABEL: @test2(
30 ; CHECK-LABEL: if.end:
31 ; CHECK: %[[ptr:.*]] = phi i32**
32 ; CHECK: %[[load:.*]] = load i32*, i32** %[[ptr]]
34 ; CHECK: ret i32* %[[load]]
35 define i32* @test2(i1 zeroext %flag, i32*** %p) {
37 br i1 %flag, label %if.then, label %if.else
40 %a = load i32**, i32*** %p
41 %aa = load i32*, i32** %a
45 %b = load i32**, i32*** %p
46 %bb= load i32*, i32** %b, !nonnull !0
50 %c = phi i32* [ %aa, %if.then ], [ %bb, %if.else ]