blob: 00e5859b75cf8f97de3f4bd0287cfe2260451d21 [file] [log] [blame]
Dan Gohman1cf96c02015-12-09 16:23:59 +00001; RUN: llc < %s -asm-verbose=false -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 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:
Dan Gohman700515f2015-11-23 21:55:57 +000011; CHECK: div_s $[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +000012; CHECK: return $[[NUM0]]{{$}}
Dan Gohman25d2a0d2015-09-08 12:39:25 +000013define i32 @test0(i32 %p) {
14entry:
15 %t = icmp slt i32 %p, 0
16 br i1 %t, label %true, label %done
17true:
18 %a = sdiv i32 %p, 3
19 br label %done
20done:
21 %s = phi i32 [ %a, %true ], [ %p, %entry ]
22 ret i32 %s
23}
Dan Gohman4f52e002015-09-09 00:52:47 +000024
25; Swap phis.
26
Dan Gohmane51c0582015-10-06 00:27:55 +000027; CHECK-LABEL: test1:
Dan Gohmana4730cf2016-01-07 18:49:53 +000028; CHECK: .LBB1_1:
Dan Gohman700515f2015-11-23 21:55:57 +000029; CHECK: copy_local $[[NUM0:[0-9]+]]=, $[[NUM1:[0-9]+]]{{$}}
30; CHECK: copy_local $[[NUM1]]=, $[[NUM2:[0-9]+]]{{$}}
31; CHECK: copy_local $[[NUM2]]=, $[[NUM0]]{{$}}
Dan Gohman4f52e002015-09-09 00:52:47 +000032define i32 @test1(i32 %n) {
33entry:
34 br label %loop
35
36loop:
37 %a = phi i32 [ 0, %entry ], [ %b, %loop ]
38 %b = phi i32 [ 1, %entry ], [ %a, %loop ]
39 %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
40
41 %i.next = add i32 %i, 1
42 %t = icmp slt i32 %i.next, %n
43 br i1 %t, label %loop, label %exit
44
45exit:
46 ret i32 %a
47}