1 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s
2 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 @x = common global i32 0
5 @y = common global i32 0
6 @a = external global i32
7 @b = external global i32
9 define void @test_01(i32 %N) {
13 %2 = load i32, i32* %1
14 %3 = icmp ne i32 %2, 0
15 br i1 %3, label %4, label %5
25 ; CHECK-LABEL: @test_01(
26 ; CHECK-NOT: store i32 10, i32* @x
27 ; CHECK-NOT: store i32 5, i32* @x
28 ; CHECK: store i32 15, i32* @x
31 define void @test_02(i32 %N) {
35 %2 = load i32, i32* %1
36 %3 = icmp ne i32 %2, 0
37 br i1 %3, label %4, label %5
44 %6 = load i32, i32* @x
52 ; CHECK-LABEL: @test_02(
53 ; CHECK: store i32 10, i32* @x
54 ; CHECK-NOT: store i32 5, i32* @x
55 ; CHECK: store i32 %6, i32* @y
58 define void @test_03(i32 %N) #0 {
62 %2 = load i32, i32* %1
63 %3 = icmp ne i32 %2, 0
64 br i1 %3, label %4, label %6
66 ; <label>:4 ; preds = %0
67 %5 = load i32, i32* @x
71 ; <label>:6 ; preds = %4, %0
75 ; CHECK-LABEL: @test_03(
76 ; CHECK: store i32 10, i32* @x
77 ; CHECK: store i32 %5, i32* @y
78 ; CHECK: store i32 15, i32* @x
82 ; Check we safely delete store i32 %g.02, i32* @b below.(PR24469)
83 define void @test_04() {
85 br i1 false, label %for.body, label %for.end.9
87 for.cond.1.loopexit: ; preds = %for.body
89 %0 = load i32, i32* @a
90 br i1 false, label %for.body, label %for.end.9
92 for.body: ; preds = %for.cond.1.loopexit, %entry
93 %g.02 = phi i32 [ undef, %entry ], [ %0, %for.cond.1.loopexit ]
94 store i32 %g.02, i32* @b
95 br label %for.cond.1.loopexit
97 for.end.9: ; preds = %for.cond.1.loopexit, %entry
101 ; CHECK-LABEL: @test_04(
102 ; CHECK-NOT: store i32 %g.02, i32* @b
103 ; CHECK-NOT: %g.02 = phi i32 [ undef, %entry ], [ %0, %for.cond.1.loopexit ]
104 ; CHECK-NOT: %0 = load i32, i32* @a