3174cb899d32470a29c3d7410d0c57c797bda52a
[oota-llvm.git] / test / CodeGen / WebAssembly / dead-vreg.ll
1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3 ; Check that unused vregs aren't assigned registers.
4
5 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
7
8 define void @foo(i32* nocapture %a, i32 %w, i32 %h) {
9 ; CHECK-LABEL: foo:
10 ; CHECK-NEXT: .param i32
11 ; CHECK-NEXT: .param i32
12 ; CHECK-NEXT: .param i32
13 ; CHECK-NEXT: .local i32, i32, i32, i32, i32, i32, i32, i32, i32{{$}}
14 entry:
15   %cmp.19 = icmp sgt i32 %h, 0
16   br i1 %cmp.19, label %for.cond.1.preheader.lr.ph, label %for.end.7
17
18 for.cond.1.preheader.lr.ph:
19   %cmp2.17 = icmp sgt i32 %w, 0
20   br label %for.cond.1.preheader
21
22 for.cond.1.preheader:
23   %y.020 = phi i32 [ 0, %for.cond.1.preheader.lr.ph ], [ %inc6, %for.inc.5 ]
24   br i1 %cmp2.17, label %for.body.3.lr.ph, label %for.inc.5
25
26 for.body.3.lr.ph:
27   %mul4 = mul nsw i32 %y.020, %w
28   br label %for.body.3
29
30 for.body.3:
31   %x.018 = phi i32 [ 0, %for.body.3.lr.ph ], [ %inc, %for.body.3 ]
32   %mul = mul nsw i32 %x.018, %y.020
33   %add = add nsw i32 %x.018, %mul4
34   %arrayidx = getelementptr inbounds i32, i32* %a, i32 %add
35   store i32 %mul, i32* %arrayidx, align 4
36   %inc = add nuw nsw i32 %x.018, 1
37   %exitcond = icmp eq i32 %inc, %w
38   br i1 %exitcond, label %for.inc.5.loopexit, label %for.body.3
39
40 for.inc.5.loopexit:
41   br label %for.inc.5
42
43 for.inc.5:
44   %inc6 = add nuw nsw i32 %y.020, 1
45   %exitcond22 = icmp eq i32 %inc6, %h
46   br i1 %exitcond22, label %for.end.7.loopexit, label %for.cond.1.preheader
47
48 for.end.7.loopexit:
49   br label %for.end.7
50
51 for.end.7:
52   ret void
53 }