blob: 9b1d506e29ceb736c573b241cc5f73312b10d54a [file] [log] [blame]
Dan Gohman25d2a0d2015-09-08 12:39:25 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
Dan Gohman25d2a0d2015-09-08 12:39:25 +00003; Test that phis are lowered.
4
Dan Gohman5e066842015-09-09 20:54:31 +00005target datalayout = "e-p:32:32-i64:64-n32:64-S128"
Dan Gohman25d2a0d2015-09-08 12:39:25 +00006target triple = "wasm32-unknown-unknown"
7
Dan Gohman4f52e002015-09-09 00:52:47 +00008; Basic phi triangle.
9
Dan Gohmane51c0582015-10-06 00:27:55 +000010; CHECK-LABEL: test0:
11; CHECK: @0{{$}}
12; CHECK: set_local [[REG:@.*]], pop
13; CHECK: sdiv [[REG]], {{.*}}
14; CHECK: set_local [[REG]], pop
15; CHECK: return [[REG]]
Dan Gohman25d2a0d2015-09-08 12:39:25 +000016define i32 @test0(i32 %p) {
17entry:
18 %t = icmp slt i32 %p, 0
19 br i1 %t, label %true, label %done
20true:
21 %a = sdiv i32 %p, 3
22 br label %done
23done:
24 %s = phi i32 [ %a, %true ], [ %p, %entry ]
25 ret i32 %s
26}
Dan Gohman4f52e002015-09-09 00:52:47 +000027
28; Swap phis.
29
Dan Gohmane51c0582015-10-06 00:27:55 +000030; CHECK-LABEL: test1:
Dan Gohman950a13c2015-09-16 16:51:30 +000031; CHECK: BB1_1:
Dan Gohmane51c0582015-10-06 00:27:55 +000032; CHECK: [[REG1:@.*]]
33; CHECK: set_local [[REG0:@.*]], pop
34; CHECK: [[REG2:@.*]]
35; CHECK: set_local [[REG1]], pop
36; CHECK: [[REG0]]
37; CHECK: set_local [[REG2]], pop
Dan Gohman4f52e002015-09-09 00:52:47 +000038define i32 @test1(i32 %n) {
39entry:
40 br label %loop
41
42loop:
43 %a = phi i32 [ 0, %entry ], [ %b, %loop ]
44 %b = phi i32 [ 1, %entry ], [ %a, %loop ]
45 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
46
47 %i.next = add i32 %i, 1
48 %t = icmp slt i32 %i.next, %n
49 br i1 %t, label %loop, label %exit
50
51exit:
52 ret i32 %a
53}