Chad Rosier | 232e29e | 2016-07-06 21:20:47 +0000 | [diff] [blame] | 1 | ; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s |
Geoff Berry | b96d3b2 | 2016-06-01 21:30:40 +0000 | [diff] [blame] | 2 | ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s |
George Burgess IV | e1100f5 | 2016-02-02 22:46:49 +0000 | [diff] [blame] | 3 | ; |
| 4 | ; This test ensures we don't end up with multiple reaching defs for a single |
| 5 | ; use/phi edge If we were to optimize defs, we would end up with 2= |
| 6 | ; MemoryDef(liveOnEntry) and 4 = MemoryDef(liveOnEntry) Both would mean both |
| 7 | ; 1,2, and 3,4 would reach the phi node. Because the phi node can only have one |
| 8 | ; entry on each edge, it would choose 2, 4 and disconnect 1 and 3 completely |
| 9 | ; from the SSA graph, even though they are not dead |
| 10 | |
| 11 | define void @sink_store(i32 %index, i32* %foo, i32* %bar) { |
| 12 | entry: |
| 13 | %cmp = trunc i32 %index to i1 |
| 14 | br i1 %cmp, label %if.then, label %if.else |
| 15 | |
| 16 | if.then: ; preds = %entry |
| 17 | ; CHECK: 1 = MemoryDef(liveOnEntry) |
| 18 | ; CHECK-NEXT: store i32 %index, i32* %foo, align 4 |
| 19 | store i32 %index, i32* %foo, align 4 |
| 20 | ; CHECK: 2 = MemoryDef(1) |
| 21 | ; CHECK-NEXT: store i32 %index, i32* %bar, align 4 |
| 22 | store i32 %index, i32* %bar, align 4 |
| 23 | br label %if.end |
| 24 | |
| 25 | if.else: ; preds = %entry |
| 26 | ; CHECK: 3 = MemoryDef(liveOnEntry) |
| 27 | ; CHECK-NEXT: store i32 %index, i32* %foo, align 4 |
| 28 | store i32 %index, i32* %foo, align 4 |
| 29 | ; CHECK: 4 = MemoryDef(3) |
| 30 | ; CHECK-NEXT: store i32 %index, i32* %bar, align 4 |
| 31 | store i32 %index, i32* %bar, align 4 |
| 32 | br label %if.end |
| 33 | |
| 34 | if.end: ; preds = %if.else, %if.then |
| 35 | ; CHECK: 5 = MemoryPhi({if.then,2},{if.else,4}) |
| 36 | ; CHECK: MemoryUse(5) |
| 37 | ; CHECK-NEXT: %c = load i32, i32* %foo |
| 38 | %c = load i32, i32* %foo |
| 39 | ; CHECK: MemoryUse(5) |
| 40 | ; CHECK-NEXT: %d = load i32, i32* %bar |
| 41 | %d = load i32, i32* %bar |
| 42 | ret void |
| 43 | } |