blob: 15976f9f10d40f36e2cff11fdb2c566c9205639d [file] [log] [blame]
Dmitri Gribenkod7beca82013-01-01 13:57:25 +00001; RUN: opt -basicaa -dse -S < %s | FileCheck %s
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +00002
3%t = type { i32 }
4
Dan Gohmanfb419362010-01-05 17:55:26 +00005@g = global i32 42
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +00006
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}