1 ; RUN: opt -basicaa -gvn -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 @x = common global i32 0, align 4
7 @y = common global i32 0, align 4
9 ; GVN across unordered store (allowed)
10 define i32 @test1() nounwind uwtable ssp {
12 ; CHECK: add i32 %x, %x
15 store atomic i32 %x, i32* @x unordered, align 4
21 ; GVN across seq_cst store (allowed in theory; not implemented ATM)
22 define i32 @test2() nounwind uwtable ssp {
24 ; CHECK: add i32 %x, %y
27 store atomic i32 %x, i32* @x seq_cst, align 4
33 ; GVN across unordered load (allowed)
34 define i32 @test3() nounwind uwtable ssp {
36 ; CHECK: add i32 %x, %x
39 %y = load atomic i32* @x unordered, align 4
46 ; GVN across acquire load (load after atomic load must not be removed)
47 define i32 @test4() nounwind uwtable ssp {
49 ; CHECK: load atomic i32* @x
53 %y = load atomic i32* @x seq_cst, align 4
60 ; GVN load to unordered load (allowed)
61 define i32 @test5() nounwind uwtable ssp {
63 ; CHECK: add i32 %x, %x
65 %x = load atomic i32* @x unordered, align 4
71 ; GVN unordered load to load (unordered load must not be removed)
72 define i32 @test6() nounwind uwtable ssp {
74 ; CHECK: load atomic i32* @x unordered
77 %x2 = load atomic i32* @x unordered, align 4