1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=1 | FileCheck %s
3 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=2 | FileCheck %s
4 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -phi-node-folding-threshold=7 | FileCheck %s
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 ; CHECK-NEXT: br i1 [[A:%.*]], label [[M:%.*]], label [[O:%.*]]
14 ; CHECK-NEXT: [[IAJ:%.*]] = add i32 [[I:%.*]], [[J:%.*]]
15 ; CHECK-NEXT: [[IAJAK:%.*]] = add i32 [[IAJ]], [[K:%.*]]
16 ; CHECK-NEXT: [[IXJ:%.*]] = xor i32 [[I]], [[J]]
17 ; CHECK-NEXT: [[IXJXK:%.*]] = xor i32 [[IXJ]], [[K]]
18 ; CHECK-NEXT: [[WP:%.*]] = select i1 [[B:%.*]], i32 [[IAJAK]], i32 [[IXJXK]]
19 ; CHECK-NEXT: [[WP2:%.*]] = add i32 [[WP]], [[WP]]
20 ; CHECK-NEXT: br label [[M]]
22 ; CHECK-NEXT: [[W:%.*]] = phi i32 [ [[WP2]], [[O]] ], [ 2, [[ENTRY:%.*]] ]
23 ; CHECK-NEXT: [[R:%.*]] = add i32 [[W]], 1
24 ; CHECK-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 ]