blob: ce3b24c996fd68a3eea713487b8a14804e154b1b [file] [log] [blame]
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +00001; RUN: opt %s -dse -S | FileCheck %s
2
3%t = type { i32 }
4
5@g = global i32 42;
6
7define void @test1(%t* noalias %pp) {
8 %p = getelementptr inbounds %t* %pp, i32 0, i32 0
9
10 store i32 1, i32* %p; <-- This is dead
11 %x = load i32* inttoptr (i32 12345 to i32*)
12 store i32 %x, i32* %p
13 ret void
Benjamin Kramer401e6092009-12-12 09:25:50 +000014; CHECK: define void @test1
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000015; CHECK: store
16; CHECK-NOT: store
17; CHECK: ret void
18}
19
20define void @test3() {
21 store i32 1, i32* @g; <-- This is dead.
22 store i32 42, i32* @g
23 ret void
Benjamin Kramer401e6092009-12-12 09:25:50 +000024; CHECK: define void @test3
25; CHECK: store
26; CHECK-NOT: store
27; CHECK: ret void
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000028}
29
30define void @test4(i32* %p) {
31 store i32 1, i32* %p
32 %x = load i32* @g; <-- %p and @g could alias
33 store i32 %x, i32* %p
34 ret void
Benjamin Kramer401e6092009-12-12 09:25:50 +000035; CHECK: define void @test4
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000036; CHECK: store
37; CHECK: store
38; CHECK: ret void
39}