• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by update_test_checks.py
2; Test merging of blocks that only have PHI nodes in them
3;
4; RUN: opt < %s -simplifycfg -S | FileCheck %s
5;
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
30