blob: 4aae92df54d90dc4484f17befdaaf2bf536cb50a [file] [log] [blame]
Dan Gohman7d7409e2017-02-28 23:37:04 +00001; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -verify-machineinstrs | FileCheck %s
Dan Gohman25d2a0d2015-09-08 12:39:25 +00002
Dan Gohman25d2a0d2015-09-08 12:39:25 +00003; Test that phis are lowered.
4
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00005target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman7d7409e2017-02-28 23:37:04 +00006target triple = "wasm32-unknown-unknown-wasm"
Dan Gohman25d2a0d2015-09-08 12:39:25 +00007
Dan Gohman4f52e002015-09-09 00:52:47 +00008; Basic phi triangle.
9
Dan Gohmane51c0582015-10-06 00:27:55 +000010; CHECK-LABEL: test0:
Kyle Buttb15c0662017-01-31 23:48:32 +000011; CHECK: return $0
12; CHECK: div_s $push[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}}
13; CHECK: return $pop[[NUM0]]{{$}}
Dan Gohman25d2a0d2015-09-08 12:39:25 +000014define i32 @test0(i32 %p) {
15entry:
16 %t = icmp slt i32 %p, 0
17 br i1 %t, label %true, label %done
18true:
19 %a = sdiv i32 %p, 3
20 br label %done
21done:
22 %s = phi i32 [ %a, %true ], [ %p, %entry ]
23 ret i32 %s
24}
Dan Gohman4f52e002015-09-09 00:52:47 +000025
26; Swap phis.
27
Dan Gohmane51c0582015-10-06 00:27:55 +000028; CHECK-LABEL: test1:
Dan Gohmana4730cf2016-01-07 18:49:53 +000029; CHECK: .LBB1_1:
Dan Gohman700515f2015-11-23 21:55:57 +000030; CHECK: copy_local $[[NUM0:[0-9]+]]=, $[[NUM1:[0-9]+]]{{$}}
31; CHECK: copy_local $[[NUM1]]=, $[[NUM2:[0-9]+]]{{$}}
32; CHECK: copy_local $[[NUM2]]=, $[[NUM0]]{{$}}
Dan Gohman4f52e002015-09-09 00:52:47 +000033define i32 @test1(i32 %n) {
34entry:
35 br label %loop
36
37loop:
38 %a = phi i32 [ 0, %entry ], [ %b, %loop ]
39 %b = phi i32 [ 1, %entry ], [ %a, %loop ]
40 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
41
42 %i.next = add i32 %i, 1
43 %t = icmp slt i32 %i.next, %n
44 br i1 %t, label %loop, label %exit
45
46exit:
47 ret i32 %a
48}