blob: b4730c27b2486654c659912ed82cf627b3958448 [file] [log] [blame]
Eric Christophercab9e7a2019-04-17 04:52:47 +00001; NOTE: Assertions have been autogenerated by update_test_checks.py
2; Test merging of blocks that only have PHI nodes in them
3;
Roman Lebedevafa7d492020-12-19 12:48:32 +03004; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
Eric Christophercab9e7a2019-04-17 04:52:47 +00005;
6
7define i32 @test(i1 %a, i1 %b) {
8; CHECK-LABEL: @test(
9; CHECK: M:
10; CHECK-NEXT: [[DOT:%.*]] = select i1 %b, i32 0, i32 1
11; CHECK-NEXT: [[W:%.*]] = select i1 %a, i32 2, i32 [[DOT]]
12; CHECK-NEXT: [[R:%.*]] = add i32 [[W]], 1
13; CHECK-NEXT: ret i32 [[R]]
14;
15 br i1 %a, label %M, label %O
16O: ; preds = %0
17 br i1 %b, label %N, label %Q
18Q: ; preds = %O
19 br label %N
20N: ; preds = %Q, %O
21 ; This block should be foldable into M
22 %Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1]
23 br label %M
24M: ; preds = %N, %0
25 %W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1]
26 %R = add i32 %W, 1 ; <i32> [#uses=1]
27 ret i32 %R
28}
29