1 ; RUN: opt -basicaa -dse -S < %s | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4 target triple = "x86_64-apple-macosx10.7.0"
6 ; Sanity tests for atomic stores.
7 ; Note that it turns out essentially every transformation DSE does is legal on
8 ; atomic ops, just some transformations are not allowed across them.
10 @x = common global i32 0, align 4
11 @y = common global i32 0, align 4
13 declare void @randomop(i32*)
15 ; DSE across unordered store (allowed)
16 define void @test1() nounwind uwtable ssp {
18 ; CHECK-NOT: store i32 0
22 store atomic i32 0, i32* @y unordered, align 4
27 ; DSE across seq_cst load (allowed in theory; not implemented ATM)
28 define i32 @test2() nounwind uwtable ssp {
34 %x = load atomic i32* @y seq_cst, align 4
39 ; DSE across seq_cst store (store before atomic store must not be removed)
40 define void @test3() nounwind uwtable ssp {
43 ; CHECK: store atomic i32 2
46 store atomic i32 2, i32* @y seq_cst, align 4
51 ; DSE remove unordered store (allowed)
52 define void @test4() nounwind uwtable ssp {
54 ; CHECK-NOT: store atomic
57 store atomic i32 0, i32* @x unordered, align 4
62 ; DSE unordered store overwriting non-atomic store (allowed)
63 define void @test5() nounwind uwtable ssp {
65 ; CHECK: store atomic i32 1
68 store atomic i32 1, i32* @x unordered, align 4
72 ; DSE no-op unordered atomic store (allowed)
73 define void @test6() nounwind uwtable ssp {
78 %x = load atomic i32* @x unordered, align 4
79 store atomic i32 %x, i32* @x unordered, align 4
83 ; DSE seq_cst store (be conservative; DSE doesn't have infrastructure
84 ; to reason about atomic operations).
85 define void @test7() nounwind uwtable ssp {
90 store atomic i32 0, i32* %a seq_cst, align 4
94 ; DSE and seq_cst load (be conservative; DSE doesn't have infrastructure
95 ; to reason about atomic operations).
96 define i32 @test8() nounwind uwtable ssp {
102 call void @randomop(i32* %a)
103 store i32 0, i32* %a, align 4
104 %x = load atomic i32* @x seq_cst, align 4