llvm/llvm/test/CodeGen/X86/issue76416.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=x86_64-unknown-freebsd15.0 < %s | FileCheck %s

%struct.anon.5.28.78.99.149.119 = type { [4 x i8] }

@vga_load_state_p = external dso_local global ptr, align 8
@vga_load_state_data = external dso_local global i8, align 1

define dso_local void @vga_load_state() #0 {
; CHECK-LABEL: vga_load_state:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    movl $0, -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    cmpl $3, -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    jg .LBB0_3
; CHECK-NEXT:    .p2align 4, 0x90
; CHECK-NEXT:  .LBB0_2: # %for.body
; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    xorl %eax, %eax
; CHECK-NEXT:    #APP
; CHECK-NEXT:    #NO_APP
; CHECK-NEXT:    incl -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    cmpl $3, -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    jle .LBB0_2
; CHECK-NEXT:  .LBB0_3: # %for.end
; CHECK-NEXT:    movl $0, -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    .p2align 4, 0x90
; CHECK-NEXT:  .LBB0_4: # %for.cond1
; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    #APP
; CHECK-NEXT:    #NO_APP
; CHECK-NEXT:    movq vga_load_state_p(%rip), %rax
; CHECK-NEXT:    movslq -{{[0-9]+}}(%rsp), %rcx
; CHECK-NEXT:    movzbl (%rax,%rcx), %eax
; CHECK-NEXT:    movb %al, vga_load_state_data(%rip)
; CHECK-NEXT:    leal 1(%rcx), %eax
; CHECK-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
; CHECK-NEXT:    jmp .LBB0_4
entry:
  %i = alloca i32, align 4
  store i32 0, ptr %i, align 4
  br label %for.cond

for.cond:                                         ; preds = %for.body, %entry
  %i1 = load i32, ptr %i, align 4
  %cmp = icmp slt i32 %i1, 4
  br i1 %cmp, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  call void asm sideeffect "", "{ax},~{dirflag},~{fpsr},~{flags}"(i8 0) #1
  %i2 = load i32, ptr %i, align 4
  %inc = add nsw i32 %i2, 1
  store i32 %inc, ptr %i, align 4
  br label %for.cond

for.end:                                          ; preds = %for.cond
  store i32 0, ptr %i, align 4
  br label %for.cond1

for.cond1:                                        ; preds = %for.cond1, %for.end
  call void asm sideeffect "", "N{dx},~{dirflag},~{fpsr},~{flags}"(i32 poison) #1
  %i3 = load ptr, ptr @vga_load_state_p, align 8
  %regs = getelementptr inbounds %struct.anon.5.28.78.99.149.119, ptr %i3, i32 0, i32 0
  %i4 = load i32, ptr %i, align 4
  %idxprom = sext i32 %i4 to i64
  %arrayidx = getelementptr inbounds [4 x i8], ptr %regs, i64 0, i64 %idxprom
  %i5 = load i8, ptr %arrayidx, align 1
  store i8 %i5, ptr @vga_load_state_data, align 1
  %i6 = load i32, ptr %i, align 4
  %inc5 = add nsw i32 %i6, 1
  store i32 %inc5, ptr %i, align 4
  br label %for.cond1, !llvm.loop !0
}

attributes #0 = { "tune-cpu"="generic" }
attributes #1 = { nounwind }

!0 = distinct !{!0, !1}
!1 = !{!"llvm.loop.mustprogress"}