1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | FileCheck %s --check-prefix=ALL --check-prefix=CHECK-ONE
3 ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | FileCheck %s --check-prefix=ALL --check-prefix=CHECK-TWO
4 ; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | FileCheck %s --check-prefix=ALL --check-prefix=CHECK-SEVEN
6 ; Test merging of blocks containing complex expressions,
7 ; with various folding thresholds
9 define i32 @test(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) {
12 ; ALL-NEXT: br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
14 ; ALL-NEXT: [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
15 ; ALL-NEXT: [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
16 ; ALL-NEXT: [[IXJ:%.*]] = xor i32 [[I]], [[J]]
17 ; ALL-NEXT: [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
18 ; ALL-NEXT: [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
19 ; ALL-NEXT: [[WP2:%.*]] = add i32 [[WP]], [[WP]]
20 ; ALL-NEXT: br label [[M]]
22 ; ALL-NEXT: [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
23 ; ALL-NEXT: [[R:%.*]] = add i32 [[W]], 1
24 ; ALL-NEXT: ret i32 [[R]]
27 br i1 %a, label %M, label %O
29 br i1 %b, label %P, label %Q
32 %iajak = add i32 %iaj, %k
36 %ixjxk = xor i32 %ixj, %k
39 ; This phi should be foldable if threshold >= 2
40 %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ]
41 %Wp2 = add i32 %Wp, %Wp
44 ; This phi should be foldable if threshold >= 7
45 %W = phi i32 [ %Wp2, %N ], [ 2, %entry ]