|
1 | | -; RUN: opt < %s -passes=instcombine,mem2reg,simplifycfg -simplifycfg-require-and-preserve-domtree=1 | \ |
2 | | -; RUN: llvm-dis | grep -v store | not grep "i32 1" |
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 |
| 2 | +; RUN: opt %s -passes=instcombine,mem2reg,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -o - | FileCheck %s |
3 | 3 |
|
4 | 4 | ; Test to make sure that instcombine does not accidentally propagate the load |
5 | 5 | ; into the PHI, which would break the program. |
6 | 6 |
|
7 | 7 | define i32 @test(i1 %C) { |
| 8 | +; CHECK-LABEL: define i32 @test( |
| 9 | +; CHECK-SAME: i1 [[C:%.*]]) { |
| 10 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 11 | +; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4 |
| 12 | +; CHECK-NEXT: [[X2:%.*]] = alloca i32, align 4 |
| 13 | +; CHECK-NEXT: store i32 1, ptr [[X]], align 4 |
| 14 | +; CHECK-NEXT: store i32 2, ptr [[X2]], align 4 |
| 15 | +; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[C]], ptr [[X]], ptr [[X2]] |
| 16 | +; CHECK-NEXT: store i32 3, ptr [[X]], align 4 |
| 17 | +; CHECK-NEXT: [[TMP_3:%.*]] = load i32, ptr [[SPEC_SELECT]], align 4 |
| 18 | +; CHECK-NEXT: ret i32 [[TMP_3]] |
| 19 | +; |
8 | 20 | entry: |
9 | | - %X = alloca i32 ; <ptr> [#uses=3] |
10 | | - %X2 = alloca i32 ; <ptr> [#uses=2] |
11 | | - store i32 1, ptr %X |
12 | | - store i32 2, ptr %X2 |
13 | | - br i1 %C, label %cond_true.i, label %cond_continue.i |
| 21 | + %X = alloca i32 ; <ptr> [#uses=3] |
| 22 | + %X2 = alloca i32 ; <ptr> [#uses=2] |
| 23 | + store i32 1, ptr %X |
| 24 | + store i32 2, ptr %X2 |
| 25 | + br i1 %C, label %cond_true.i, label %cond_continue.i |
14 | 26 |
|
15 | 27 | cond_true.i: ; preds = %entry |
16 | | - br label %cond_continue.i |
| 28 | + br label %cond_continue.i |
17 | 29 |
|
18 | 30 | cond_continue.i: ; preds = %cond_true.i, %entry |
19 | | - %mem_tmp.i.0 = phi ptr [ %X, %cond_true.i ], [ %X2, %entry ] ; <ptr> [#uses=1] |
20 | | - store i32 3, ptr %X |
21 | | - %tmp.3 = load i32, ptr %mem_tmp.i.0 ; <i32> [#uses=1] |
22 | | - ret i32 %tmp.3 |
| 31 | + %mem_tmp.i.0 = phi ptr [ %X, %cond_true.i ], [ %X2, %entry ] ; <ptr> [#uses=1] |
| 32 | + store i32 3, ptr %X |
| 33 | + %tmp.3 = load i32, ptr %mem_tmp.i.0 ; <i32> [#uses=1] |
| 34 | + ret i32 %tmp.3 |
23 | 35 | } |
24 | | - |
25 | | - |
|
0 commit comments