xref: /llvm-project/llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll (revision 16bb8c16aab32e2ee623a2b64d976548be247180)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2; Basic test to check that DominatorTreeAnalysis is preserved by IPSCCP and
3; the following analysis can re-use it. The test contains two trivial functions
4; IPSCCP can simplify, so we can test the case where IPSCCP makes changes.
5
6; RUN: opt -disable-verify -debug-pass-manager \
7; RUN: -passes='function(require<domtree>,require<postdomtree>),ipsccp,function(require<domtree>,require<postdomtree>)' -S  %s 2>&1 \
8; RUN:     | FileCheck -check-prefixes=IR,NEW-PM %s
9
10; RUN: opt -passes='function(require<postdomtree>),ipsccp,function(verify<domtree>)' -S  %s | FileCheck -check-prefixes=IR %s
11
12; NEW-PM: Running analysis: DominatorTreeAnalysis on f1
13; NEW-PM: Running analysis: PostDominatorTreeAnalysis on f1
14; NEW-PM: Running analysis: DominatorTreeAnalysis on f2
15; NEW-PM: Running analysis: PostDominatorTreeAnalysis on f2
16; NEW-PM: Running pass: IPSCCPPass
17; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f1
18; NEW-PM-DAG: Running analysis: AssumptionAnalysis on f2
19; NEW-PM-NOT: Running analysis: AssumptionAnalysis
20
21
22define internal i32 @f1() readnone {
23; IR-LABEL: define internal i32 @f1(
24; IR-SAME: ) #[[ATTR0:[0-9]+]] {
25; IR-NEXT:  [[ENTRY:.*:]]
26; IR-NEXT:    br label %[[BB2:.*]]
27; IR:       [[BB2]]:
28; IR-NEXT:    ret i32 poison
29;
30entry:
31  br i1 false, label %bb1, label %bb2
32bb1:
33  ret i32 10
34bb2:
35  ret i32 10
36}
37
38define i32 @f2(i32 %n) {
39; IR-LABEL: define i32 @f2(
40; IR-SAME: i32 [[N:%.*]]) {
41; IR-NEXT:    [[I:%.*]] = call i32 @f1()
42; IR-NEXT:    br label %[[BBTRUE:.*]]
43; IR:       [[BBTRUE]]:
44; IR-NEXT:    ret i32 0
45;
46  %i = call i32 @f1()
47  %cmp = icmp eq i32 %i, 10
48  br i1 %cmp, label %bbtrue, label %bbfalse
49
50bbtrue:
51  ret i32 0
52
53bbfalse:
54  %res = add i32 %n, %i
55  ret i32 %res
56}
57;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
58; NEW-PM: {{.*}}
59