Skip to content

Commit 0d4a615

Browse files
authored
[InstCombine] Make test resilient to metadata presence (llvm#157607)
Modernized it to using `update_test_checks`​ which addresses an ambgiuty in the previous test formulation, where a profile metadaat of value `i32 1`​ would have (incorrectly matched.
1 parent 8f25ea2 commit 0d4a615

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
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
33

44
; Test to make sure that instcombine does not accidentally propagate the load
55
; into the PHI, which would break the program.
66

77
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+
;
820
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
1426

1527
cond_true.i: ; preds = %entry
16-
br label %cond_continue.i
28+
br label %cond_continue.i
1729

1830
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
2335
}
24-
25-

llvm/utils/profcheck-xfail.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
830830
Transforms/IndVarSimplify/pr45835.ll
831831
Transforms/IndVarSimplify/preserving-debugloc-rem-div.ll
832832
Transforms/Inline/optimization-remarks-hotness-threshold.ll
833-
Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
834833
Transforms/InstCombine/2004-09-20-BadLoadCombine.ll
835834
Transforms/InstCombine/2005-04-07-UDivSelectCrash.ll
836835
Transforms/InstCombine/2011-02-14-InfLoop.ll

0 commit comments

Comments
 (0)