1 ; RUN: opt < %s -jump-threading -S | FileCheck %s
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4 target triple = "i386-apple-darwin7"
6 declare void @use(i32 *)
8 ; Check that we propagate nonnull to dominated loads, when we find an available
10 ; CHECK-LABEL: @test1(
12 ; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr
14 ; CHECK-NEXT: store i32 1, i32* %[[p1]]
15 ; CHECK-NEXT: tail call void @use(i32* null)
16 ; CHECK-NEXT: ret void
19 ; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, align 4, !nonnull !0
20 ; CHECK: tail call void @use(i32* %[[p2]])
21 ; CHECK-NEXT: ret void
22 define void @test1(i32** %ptr, i1 %c) {
23 br i1 %c, label %d1, label %d2
26 %p1 = load i32*, i32** %ptr, !nonnull !0
33 %pm = phi i32* [ null, %d2 ], [ %p1, %d1 ]
34 %p2 = load i32*, i32** %ptr
36 %c2 = icmp eq i32* %pm, null
37 br i1 %c2, label %ret1, label %ret2
40 tail call void @use(i32* %pm) nounwind
44 tail call void @use(i32* %pm) nounwind
48 ; Check that we propagate nonnull to dominated loads, when we find an available
50 ; CHECK-LABEL: @test2(
51 ; CHECK-LABEL: d3.thread:
52 ; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr, align 4, !nonnull !0
53 ; CHECK-NEXT: store i32 1, i32* %[[p1]]
54 ; CHECK-NEXT: br label %ret1
57 ; CHECK-NEXT: %[[p_cmp:.*]] = load i32*, i32** %ptr
58 ; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, align 4, !nonnull !0
59 ; CHECK-NEXT: store i32 1, i32* %[[p2]]
60 ; CHECK-NEXT: icmp eq i32* %[[p_cmp]], null
61 define void @test2(i32** %ptr, i1 %c) {
62 br i1 %c, label %d1, label %d2
65 %p1 = load i32*, i32** %ptr
72 %pm = phi i32* [ null, %d2 ], [ %p1, %d1 ]
73 %p2 = load i32*, i32** %ptr, !nonnull !0
75 %c2 = icmp eq i32* %pm, null
76 br i1 %c2, label %ret1, label %ret2
79 tail call void @use(i32* %pm) nounwind
83 tail call void @use(i32* %pm) nounwind
87 ; Check that we do not propagate nonnull to loads predecessors that are combined
89 ; CHECK-LABEL: @test3(
91 ; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr
95 ; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr
99 ; CHECK-NEXT: phi i32* [ %[[p2]], %d2 ], [ %[[p1]], %d1 ]
100 define void @test3(i32** %ptr) {
102 %x = load i32*, i32** %ptr, !nonnull !0
109 %y = load i32*, i32** %ptr
111 %c2 = icmp eq i32* %y, @p
112 br i1 %c2, label %ret1, label %ret2
121 @p = external global i32