[WebAssembly] Update target datalayout strings.
[oota-llvm.git] / test / CodeGen / WebAssembly / phi.ll
1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3 ; This test depends on branching support, which is not yet checked in.
4 ; XFAIL: *
5
6 ; Test that phis are lowered.
7
8 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
9 target triple = "wasm32-unknown-unknown"
10
11 ; Basic phi triangle.
12
13 ; CHECK-LABEL: test0
14 ; CHECK: (setlocal [[REG:@.*]] (argument 0))
15 ; CHECK: (setlocal [[REG]] (sdiv [[REG]] {{.*}}))
16 ; CHECK: (return [[REG]])
17 define i32 @test0(i32 %p) {
18 entry:
19   %t = icmp slt i32 %p, 0
20   br i1 %t, label %true, label %done
21 true:
22   %a = sdiv i32 %p, 3
23   br label %done
24 done:
25   %s = phi i32 [ %a, %true ], [ %p, %entry ]
26   ret i32 %s
27 }
28
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]])
36 define i32 @test1(i32 %n) {
37 entry:
38   br label %loop
39
40 loop:
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
49 exit:
50   ret i32 %a
51 }