1646e1f7bSPetar Avramovic# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2646e1f7bSPetar Avramovic# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
3646e1f7bSPetar Avramovic--- |
4646e1f7bSPetar Avramovic
5646e1f7bSPetar Avramovic  declare i32 @puts(i8*)
6646e1f7bSPetar Avramovic  declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i1)
7646e1f7bSPetar Avramovic
8646e1f7bSPetar Avramovic  define void @Print_c_N_times(i8 %c, i32 %N) {
9646e1f7bSPetar Avramovic  entry:
10646e1f7bSPetar Avramovic    %add = add i32 %N, 1
11646e1f7bSPetar Avramovic    %vla = alloca i8, i32 %add, align 1
12646e1f7bSPetar Avramovic    call void @llvm.memset.p0i8.i32(i8* align 1 %vla, i8 %c, i32 %N, i1 false)
13646e1f7bSPetar Avramovic    %arrayidx = getelementptr inbounds i8, i8* %vla, i32 %N
14646e1f7bSPetar Avramovic    store i8 0, i8* %arrayidx, align 1
15646e1f7bSPetar Avramovic    %call = call i32 @puts(i8* %vla)
16646e1f7bSPetar Avramovic    ret void
17646e1f7bSPetar Avramovic  }
18646e1f7bSPetar Avramovic
19646e1f7bSPetar Avramovic...
20646e1f7bSPetar Avramovic---
21646e1f7bSPetar Avramovicname:            Print_c_N_times
22646e1f7bSPetar Avramovicalignment:       4
23646e1f7bSPetar AvramovictracksRegLiveness: true
24646e1f7bSPetar Avramovicstack:
25646e1f7bSPetar Avramovic  - { id: 0, name: vla, type: variable-sized, alignment: 1 }
26646e1f7bSPetar Avramovicbody:             |
27646e1f7bSPetar Avramovic  bb.1.entry:
28646e1f7bSPetar Avramovic    liveins: $a0, $a1
29646e1f7bSPetar Avramovic
30646e1f7bSPetar Avramovic    ; MIPS32-LABEL: name: Print_c_N_times
31646e1f7bSPetar Avramovic    ; MIPS32: liveins: $a0, $a1
32646e1f7bSPetar Avramovic    ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
33646e1f7bSPetar Avramovic    ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1
34646e1f7bSPetar Avramovic    ; MIPS32: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
35646e1f7bSPetar Avramovic    ; MIPS32: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
36646e1f7bSPetar Avramovic    ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[C]]
37646e1f7bSPetar Avramovic    ; MIPS32: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[ADD]], [[C]]
38646e1f7bSPetar Avramovic    ; MIPS32: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 7
39044297ccSRoman Tereshin    ; MIPS32: [[ADD1:%[0-9]+]]:_(s32) = nuw G_ADD [[MUL]], [[C2]]
40646e1f7bSPetar Avramovic    ; MIPS32: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 -8
41044297ccSRoman Tereshin    ; MIPS32: [[AND:%[0-9]+]]:_(s32) = G_AND [[ADD1]], [[C3]]
42646e1f7bSPetar Avramovic    ; MIPS32: [[COPY2:%[0-9]+]]:_(p0) = COPY $sp
43646e1f7bSPetar Avramovic    ; MIPS32: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY2]](p0)
44646e1f7bSPetar Avramovic    ; MIPS32: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[PTRTOINT]], [[AND]]
45646e1f7bSPetar Avramovic    ; MIPS32: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s32)
46646e1f7bSPetar Avramovic    ; MIPS32: $sp = COPY [[INTTOPTR]](p0)
47646e1f7bSPetar Avramovic    ; MIPS32: [[COPY3:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0)
48646e1f7bSPetar Avramovic    ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
49646e1f7bSPetar Avramovic    ; MIPS32: $a0 = COPY [[COPY3]](p0)
50*2bf4eeeeSPetar Avramovic    ; MIPS32: $a1 = COPY [[COPY]](s32)
51646e1f7bSPetar Avramovic    ; MIPS32: $a2 = COPY [[COPY1]](s32)
52646e1f7bSPetar Avramovic    ; MIPS32: JAL &memset, csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit $a2
53646e1f7bSPetar Avramovic    ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
54fae05692SMatt Arsenault    ; MIPS32: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY3]], [[COPY1]](s32)
55*2bf4eeeeSPetar Avramovic    ; MIPS32: [[COPY4:%[0-9]+]]:_(p0) = COPY [[PTR_ADD]](p0)
56*2bf4eeeeSPetar Avramovic    ; MIPS32: G_STORE [[C1]](s32), [[COPY4]](p0) :: (store (s8) into %ir.arrayidx)
57646e1f7bSPetar Avramovic    ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
58646e1f7bSPetar Avramovic    ; MIPS32: $a0 = COPY [[COPY3]](p0)
59646e1f7bSPetar Avramovic    ; MIPS32: JAL @puts, csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit-def $v0
60646e1f7bSPetar Avramovic    ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
61646e1f7bSPetar Avramovic    ; MIPS32: RetRA
62646e1f7bSPetar Avramovic    %2:_(s32) = COPY $a0
63646e1f7bSPetar Avramovic    %0:_(s8) = G_TRUNC %2(s32)
64646e1f7bSPetar Avramovic    %1:_(s32) = COPY $a1
65646e1f7bSPetar Avramovic    %3:_(s32) = G_CONSTANT i32 1
66646e1f7bSPetar Avramovic    %13:_(s8) = G_CONSTANT i8 0
67646e1f7bSPetar Avramovic    %4:_(s32) = G_ADD %1, %3
68646e1f7bSPetar Avramovic    %5:_(s32) = G_MUL %4, %3
69646e1f7bSPetar Avramovic    %6:_(s32) = G_CONSTANT i32 7
70646e1f7bSPetar Avramovic    %7:_(s32) = nuw G_ADD %5, %6
71646e1f7bSPetar Avramovic    %8:_(s32) = G_CONSTANT i32 -8
72646e1f7bSPetar Avramovic    %9:_(s32) = G_AND %7, %8
73646e1f7bSPetar Avramovic    %10:_(p0) = G_DYN_STACKALLOC %9(s32), 0
74fae05692SMatt Arsenault    G_MEMSET %10(p0), %0(s8), %1(s32), 0 :: (store (s8) into %ir.vla)
75e74c5b96SDaniel Sanders    %11:_(p0) = G_PTR_ADD %10, %1(s32)
76646e1f7bSPetar Avramovic    %12:_(p0) = COPY %11(p0)
77fae05692SMatt Arsenault    G_STORE %13(s8), %12(p0) :: (store (s8) into %ir.arrayidx)
78646e1f7bSPetar Avramovic    ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
79646e1f7bSPetar Avramovic    $a0 = COPY %10(p0)
80646e1f7bSPetar Avramovic    JAL @puts, csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit-def $v0
81646e1f7bSPetar Avramovic    ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
82646e1f7bSPetar Avramovic    RetRA
83646e1f7bSPetar Avramovic
84646e1f7bSPetar Avramovic...
85