Eli Friedman | 293c31b | 2011-08-31 21:37:06 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -ipsccp -S | FileCheck %s |
| 2 | |
| 3 | ; This transformation is safe for atomic loads and stores; check that it works. |
| 4 | |
| 5 | @G = internal global i32 17 |
| 6 | @C = internal constant i32 222 |
| 7 | |
| 8 | define i32 @test1() { |
| 9 | %V = load atomic i32* @G seq_cst, align 4 |
| 10 | %C = icmp eq i32 %V, 17 |
| 11 | br i1 %C, label %T, label %F |
| 12 | T: |
| 13 | store atomic i32 17, i32* @G seq_cst, align 4 |
| 14 | ret i32 %V |
| 15 | F: |
| 16 | store atomic i32 123, i32* @G seq_cst, align 4 |
| 17 | ret i32 0 |
| 18 | } |
Stephen Lin | a76289a | 2013-07-14 01:50:49 +0000 | [diff] [blame] | 19 | ; CHECK-LABEL: define i32 @test1( |
Eli Friedman | 293c31b | 2011-08-31 21:37:06 +0000 | [diff] [blame] | 20 | ; CHECK-NOT: store |
| 21 | ; CHECK: ret i32 17 |
| 22 | |
| 23 | define i32 @test2() { |
| 24 | %V = load atomic i32* @C seq_cst, align 4 |
| 25 | ret i32 %V |
| 26 | } |
| 27 | |
Stephen Lin | a76289a | 2013-07-14 01:50:49 +0000 | [diff] [blame] | 28 | ; CHECK-LABEL: define i32 @test2( |
Eli Friedman | 293c31b | 2011-08-31 21:37:06 +0000 | [diff] [blame] | 29 | ; CHECK-NOT: load |
Eli Friedman | cc6e928 | 2011-09-01 21:20:11 +0000 | [diff] [blame] | 30 | ; CHECK: ret i32 222 |