• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test merging of blocks containing complex expressions,
2; with various folding thresholds
3;
4; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | grep N:
5; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | not grep N:
6; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | grep M:
7; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | not grep M:
8;
9
10define i32 @test(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) {
11entry:
12        br i1 %a, label %M, label %O
13O:
14        br i1 %b, label %P, label %Q
15P:
16        %iaj = add i32 %i, %j
17        %iajak = add i32 %iaj, %k
18        br label %N
19Q:
20        %ixj = xor i32 %i, %j
21        %ixjxk = xor i32 %ixj, %k
22        br label %N
23N:
24        ; This phi should be foldable if threshold >= 2
25        %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ]
26        %Wp2 = add i32 %Wp, %Wp
27        br label %M
28M:
29        ; This phi should be foldable if threshold >= 7
30        %W = phi i32 [ %Wp2, %N ], [ 2, %entry ]
31        %R = add i32 %W, 1
32        ret i32 %R
33}
34
35