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