1; RUN: opt < %s -globals-aa -gvn -S | FileCheck %s
2
3@X = internal global i32 4
4
5define i32 @test_cmpxchg(i32* %P) {
6; CHECK-LABEL: @test_cmpxchg
7; CHECK-NEXT: store i32 12, i32* @X
8; CHECK-NEXT: call void @modrefX_cmpxchg()
9; CHECK-NEXT: %V = load i32, i32* @X
10; CHECK-NEXT: ret i32 %V
11  store i32 12, i32* @X
12  call void @modrefX_cmpxchg()
13  %V = load i32, i32* @X
14  ret i32 %V
15}
16
17define void @modrefX_cmpxchg() {
18  %1 = cmpxchg i32* @X, i32 0, i32 -1 monotonic monotonic
19  ret void
20}
21
22define i32 @test_atomicrmw(i32* %P) {
23; CHECK-LABEL: @test_atomicrmw
24; CHECK-NEXT: store i32 12, i32* @X
25; CHECK-NEXT: call void @modrefXatomicrmw()
26; CHECK-NEXT: %V = load i32, i32* @X
27; CHECK-NEXT: ret i32 %V
28  store i32 12, i32* @X
29  call void @modrefXatomicrmw()
30  %V = load i32, i32* @X
31  ret i32 %V
32}
33
34define void @modrefXatomicrmw() {
35  %1 = atomicrmw add i32* @X, i32 1 acquire
36  ret void
37}
38