blob: f2c5c6acf2ff006dcc5d3cef76977f58bc4b2e77 [file] [log] [blame]
Dmitri Gribenkod7beca82013-01-01 13:57:25 +00001; RUN: opt -basicaa -dse -S < %s | FileCheck %s
Hal Finkeldd38c0b2014-10-17 11:56:00 +00002target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +00003
4%t = type { i32 }
5
Dan Gohmanfb419362010-01-05 17:55:26 +00006@g = global i32 42
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +00007
8define void @test1(%t* noalias %pp) {
David Blaikie79e6c742015-02-27 19:29:02 +00009 %p = getelementptr inbounds %t, %t* %pp, i32 0, i32 0
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000010
11 store i32 1, i32* %p; <-- This is dead
12 %x = load i32* inttoptr (i32 12345 to i32*)
13 store i32 %x, i32* %p
14 ret void
Stephen Lina76289a2013-07-14 01:50:49 +000015; CHECK-LABEL: define void @test1(
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000016; CHECK: store
17; CHECK-NOT: store
18; CHECK: ret void
19}
20
21define void @test3() {
22 store i32 1, i32* @g; <-- This is dead.
23 store i32 42, i32* @g
24 ret void
Stephen Lina76289a2013-07-14 01:50:49 +000025; CHECK-LABEL: define void @test3(
Benjamin Kramer401e6092009-12-12 09:25:50 +000026; CHECK: store
27; CHECK-NOT: store
28; CHECK: ret void
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000029}
30
31define void @test4(i32* %p) {
32 store i32 1, i32* %p
33 %x = load i32* @g; <-- %p and @g could alias
34 store i32 %x, i32* %p
35 ret void
Stephen Lina76289a2013-07-14 01:50:49 +000036; CHECK-LABEL: define void @test4(
Nick Lewyckyc53e2ec2009-11-14 06:15:14 +000037; CHECK: store
38; CHECK: store
39; CHECK: ret void
40}