• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -instcombine -S < %s | FileCheck %s
2
3declare void @bar()
4declare void @baz()
5
6; Check that dereferenceable_or_null metadata is combined
7; CHECK-LABEL: cont:
8; CHECK: load i32*, i32**
9; CHECK-SAME: !dereferenceable_or_null ![[DEREF:[0-9]+]]
10define i32* @test_phi_combine_load_metadata(i1 %c, i32** dereferenceable(8) %p1, i32** dereferenceable(8) %p2) {
11  br i1 %c, label %t, label %f
12t:
13  call void @bar()
14  %v1 = load i32*, i32** %p1, align 8, !dereferenceable_or_null !0
15  br label %cont
16
17f:
18  call void @baz()
19  %v2 = load i32*, i32** %p2, align 8, !dereferenceable_or_null !1
20  br label %cont
21
22cont:
23  %res = phi i32* [ %v1, %t ], [ %v2, %f ]
24  ret i32* %res
25}
26
27; CHECK: ![[DEREF]] = !{i64 8}
28
29!0 = !{i64 8}
30!1 = !{i64 16}
31