13fb5ebc53056fcd8d98a240e072e1e1faab81ec
[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-v128:8:128-n32:64-S128"
9 target triple = "wasm32-unknown-unknown"
10
11 ; CHECK-LABEL: test0
12 ; CHECK: (setlocal [[REG:@.*]] (argument 0))
13 ; CHECK: (setlocal [[REG]] (sdiv [[REG]] {{.*}}))
14 ; CHECK: (return [[REG]])
15 define i32 @test0(i32 %p) {
16 entry:
17   %t = icmp slt i32 %p, 0
18   br i1 %t, label %true, label %done
19 true:
20   %a = sdiv i32 %p, 3
21   br label %done
22 done:
23   %s = phi i32 [ %a, %true ], [ %p, %entry ]
24   ret i32 %s
25 }