• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -instcombine -S < %s | FileCheck %s
2
3target datalayout = "e-m:e-p:64:64:64-i64:64-f80:128-n8:16:32:64-S128"
4
5; Check that nonnull metadata is propagated from dominating load.
6; CHECK-LABEL: @combine_metadata_dominance1(
7; CHECK-LABEL: bb1:
8; CHECK: load i32*, i32** %p, align 8, !nonnull !0
9; CHECK-NOT: load i32*, i32** %p
10define void @combine_metadata_dominance1(i32** %p) {
11entry:
12  %a = load i32*, i32** %p, !nonnull !0
13  br label %bb1
14
15bb1:
16  %b = load i32*, i32** %p
17  store i32 0, i32* %a
18  store i32 0, i32* %b
19  ret void
20}
21
22declare i32 @use(i32*, i32) readonly
23
24; Check that nonnull from the dominated load does not get propagated.
25; There are some cases where it would be safe to keep it.
26; CHECK-LABEL: @combine_metadata_dominance2(
27; CHECK-NOT: nonnull
28define void @combine_metadata_dominance2(i32** %p) {
29entry:
30  %a = load i32*, i32** %p
31  br i1 undef, label %bb1, label %bb2
32
33bb1:
34  %b = load i32*, i32** %p, !nonnull !0
35  store i32 0, i32* %a
36  store i32 0, i32* %b
37  ret void
38
39bb2:
40  ret void
41}
42
43
44!0 = !{}
45