blob: 77feb8503698130e3c45f56d5fe56ff95ab0bd61 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
; RUN: | FileCheck %s --check-prefix=RV32
@.str = private unnamed_addr constant [13 x i8] c"Val[%d]: %d\0A\00", align 1
define i32 @printSomething(ptr %arr, i32 %len) #0 {
; RV32-LABEL: printSomething:
; RV32: # %bb.0: # %entry
; RV32-NEXT: sspush ra
; RV32-NEXT: cm.push {ra, s0-s3}, -32
; RV32-NEXT: .cfi_def_cfa_offset 32
; RV32-NEXT: .cfi_offset ra, -20
; RV32-NEXT: .cfi_offset s0, -16
; RV32-NEXT: .cfi_offset s1, -12
; RV32-NEXT: .cfi_offset s2, -8
; RV32-NEXT: .cfi_offset s3, -4
; RV32-NEXT: mv s0, a1
; RV32-NEXT: blez a1, .LBB0_3
; RV32-NEXT: # %bb.1: # %for.body.preheader
; RV32-NEXT: mv s1, a0
; RV32-NEXT: li s2, 0
; RV32-NEXT: lui s3, %hi(.L.str)
; RV32-NEXT: addi s3, s3, %lo(.L.str)
; RV32-NEXT: .LBB0_2: # %for.body
; RV32-NEXT: # =>This Inner Loop Header: Depth=1
; RV32-NEXT: lw a2, 0(s1)
; RV32-NEXT: cm.mva01s s3, s2
; RV32-NEXT: call printf
; RV32-NEXT: addi s2, s2, 1
; RV32-NEXT: addi s1, s1, 4
; RV32-NEXT: bne s0, s2, .LBB0_2
; RV32-NEXT: .LBB0_3: # %for.cond.cleanup
; RV32-NEXT: mv a0, s0
; RV32-NEXT: cm.pop {ra, s0-s3}, 32
; RV32-NEXT: sspopchk ra
; RV32-NEXT: ret
entry:
%cmp5 = icmp sgt i32 %len, 0
br i1 %cmp5, label %for.body, label %for.cond.cleanup
for.cond.cleanup: ; preds = %for.body, %entry
ret i32 %len
for.body: ; preds = %entry, %for.body
%i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
%arrayidx = getelementptr inbounds nuw [4 x i8], ptr %arr, i32 %i.06
%0 = load i32, ptr %arrayidx, align 4
%call = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %i.06, i32 noundef %0)
%inc = add nuw nsw i32 %i.06, 1
%exitcond.not = icmp eq i32 %inc, %len
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
}
; Function Attrs: nofree nounwind
declare dso_local noundef i32 @printf(ptr noundef readonly captures(none), ...) local_unnamed_addr #0
attributes #0 = { "hw-shadow-stack" "target-features"="+experimental-zicfiss,+zcmop,+zcmp" }