• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -verify-machineinstrs | FileCheck %s
2
3; Test that phis are lowered.
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8; Basic phi triangle.
9
10; CHECK-LABEL: test0:
11; CHECK: div_s $[[NUM0:[0-9]+]]=, $0, $pop[[NUM1:[0-9]+]]{{$}}
12; CHECK: return $[[NUM0]]{{$}}
13define 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}
24
25; Swap phis.
26
27; CHECK-LABEL: test1:
28; CHECK: .LBB{{[0-9]+}}_1:
29; CHECK: local.copy $[[NUM0:[0-9]+]]=, $[[NUM1:[0-9]+]]{{$}}
30; CHECK: local.copy $[[NUM1]]=, $[[NUM2:[0-9]+]]{{$}}
31; CHECK: local.copy $[[NUM2]]=, $[[NUM0]]{{$}}
32define 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}
48