blob: 24cab2f66077ddea48f9242394178f9cf68701d2 [file] [log] [blame]
Dan Gohman25d2a0d2015-09-08 12:39:25 +00001; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
Dan Gohmand4a12d22015-09-08 13:21:12 +00003; This test depends on branching support, which is not yet checked in.
4; XFAIL: *
5
Dan Gohman25d2a0d2015-09-08 12:39:25 +00006; Test that phis are lowered.
7
8target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
9target triple = "wasm32-unknown-unknown"
10
Dan Gohman4f52e002015-09-09 00:52:47 +000011; Basic phi triangle.
12
Dan Gohman25d2a0d2015-09-08 12:39:25 +000013; CHECK-LABEL: test0
14; CHECK: (setlocal [[REG:@.*]] (argument 0))
15; CHECK: (setlocal [[REG]] (sdiv [[REG]] {{.*}}))
16; CHECK: (return [[REG]])
17define i32 @test0(i32 %p) {
18entry:
19 %t = icmp slt i32 %p, 0
20 br i1 %t, label %true, label %done
21true:
22 %a = sdiv i32 %p, 3
23 br label %done
24done:
25 %s = phi i32 [ %a, %true ], [ %p, %entry ]
26 ret i32 %s
27}
Dan Gohman4f52e002015-09-09 00:52:47 +000028
29; Swap phis.
30
31; CHECK-LABEL: test1
32; CHECK: BB0_1:
33; CHECK: (setlocal [[REG0:@.*]] [[REG1:@.*]])
34; CHECK: (setlocal [[REG1]] [[REG2:@.*]])
35; CHECK: (setlocal [[REG2]] [[REG0]])
36define i32 @test1(i32 %n) {
37entry:
38 br label %loop
39
40loop:
41 %a = phi i32 [ 0, %entry ], [ %b, %loop ]
42 %b = phi i32 [ 1, %entry ], [ %a, %loop ]
43 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
44
45 %i.next = add i32 %i, 1
46 %t = icmp slt i32 %i.next, %n
47 br i1 %t, label %loop, label %exit
48
49exit:
50 ret i32 %a
51}