; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 -verify-machineinstrs | FileCheck %s

define i32 @fun0(i32 %n) #0 {
; CHECK-LABEL: fun0:
; CHECK:       # %bb.0:
; CHECK-NEXT:    stmg %r11, %r15, 88(%r15)
; CHECK-NEXT:    .cfi_offset %r11, -72
; CHECK-NEXT:    .cfi_offset %r15, -40
; CHECK-NEXT:    aghi %r15, -160
; CHECK-NEXT:    .cfi_def_cfa_offset 320
; CHECK-NEXT:    lgr %r11, %r15
; CHECK-NEXT:    .cfi_def_cfa_register %r11
; CHECK-NEXT:    # kill: def $r2l killed $r2l def $r2d
; CHECK-NEXT:    risbgn %r1, %r2, 30, 189, 2
; CHECK-NEXT:    la %r0, 7(%r1)
; CHECK-NEXT:    risbgn %r1, %r0, 29, 188, 0
; CHECK-NEXT:    clgfi %r1, 4096
; CHECK-NEXT:    jl .LBB0_2
; CHECK-NEXT:  .LBB0_1: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    slgfi %r1, 4096
; CHECK-NEXT:    slgfi %r15, 4096
; CHECK-NEXT:    cg %r15, 4088(%r15)
; CHECK-NEXT:    clgfi %r1, 4096
; CHECK-NEXT:    jhe .LBB0_1
; CHECK-NEXT:  .LBB0_2:
; CHECK-NEXT:    cgije %r1, 0, .LBB0_4
; CHECK-NEXT:  # %bb.3:
; CHECK-NEXT:    slgr %r15, %r1
; CHECK-NEXT:    cg %r15, -8(%r1,%r15)
; CHECK-NEXT:  .LBB0_4:
; CHECK-NEXT:    la %r1, 160(%r15)
; CHECK-NEXT:    lhi %r0, 1
; CHECK-NEXT:    sty %r0, 4792(%r1)
; CHECK-NEXT:    l %r2, 0(%r1)
; CHECK-NEXT:    lmg %r11, %r15, 248(%r11)
; CHECK-NEXT:    br %r14

  %a = alloca i32, i32 %n
  %b = getelementptr inbounds i32, i32* %a, i64 1198
  store volatile i32 1, i32* %b
  %c = load volatile i32, i32* %a
  ret i32 %c
}

; Probe size should be modulo stack alignment.
define i32 @fun1(i32 %n) #0 "stack-probe-size"="1250" {
; CHECK-LABEL: fun1:
; CHECK:       # %bb.0:
; CHECK-NEXT:    stmg %r11, %r15, 88(%r15)
; CHECK-NEXT:    .cfi_offset %r11, -72
; CHECK-NEXT:    .cfi_offset %r15, -40
; CHECK-NEXT:    aghi %r15, -160
; CHECK-NEXT:    .cfi_def_cfa_offset 320
; CHECK-NEXT:    lgr %r11, %r15
; CHECK-NEXT:    .cfi_def_cfa_register %r11
; CHECK-NEXT:    # kill: def $r2l killed $r2l def $r2d
; CHECK-NEXT:    risbgn %r1, %r2, 30, 189, 2
; CHECK-NEXT:    la %r0, 7(%r1)
; CHECK-NEXT:    risbgn %r1, %r0, 29, 188, 0
; CHECK-NEXT:    clgfi %r1, 1248
; CHECK-NEXT:    jl .LBB1_2
; CHECK-NEXT:  .LBB1_1: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    slgfi %r1, 1248
; CHECK-NEXT:    slgfi %r15, 1248
; CHECK-NEXT:    cg %r15, 1240(%r15)
; CHECK-NEXT:    clgfi %r1, 1248
; CHECK-NEXT:    jhe .LBB1_1
; CHECK-NEXT:  .LBB1_2:
; CHECK-NEXT:    cgije %r1, 0, .LBB1_4
; CHECK-NEXT:  # %bb.3:
; CHECK-NEXT:    slgr %r15, %r1
; CHECK-NEXT:    cg %r15, -8(%r1,%r15)
; CHECK-NEXT:  .LBB1_4:
; CHECK-NEXT:    la %r1, 160(%r15)
; CHECK-NEXT:    lhi %r0, 1
; CHECK-NEXT:    sty %r0, 4792(%r1)
; CHECK-NEXT:    l %r2, 0(%r1)
; CHECK-NEXT:    lmg %r11, %r15, 248(%r11)
; CHECK-NEXT:    br %r14
  %a = alloca i32, i32 %n
  %b = getelementptr inbounds i32, i32* %a, i64 1198
  store volatile i32 1, i32* %b
  %c = load volatile i32, i32* %a
  ret i32 %c
}

; The minimum probe size is the stack alignment.
define i32 @fun2(i32 %n) #0 "stack-probe-size"="4" {
; CHECK-LABEL: fun2:
; CHECK:       # %bb.0:
; CHECK-NEXT:    stmg %r11, %r15, 88(%r15)
; CHECK-NEXT:    .cfi_offset %r11, -72
; CHECK-NEXT:    .cfi_offset %r15, -40
; CHECK-NEXT:    lgr %r0, %r15
; CHECK-NEXT:    .cfi_def_cfa_register %r0
; CHECK-NEXT:    aghi %r0, -160
; CHECK-NEXT:    .cfi_def_cfa_offset 320
; CHECK-NEXT:  .LBB2_1: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    aghi %r15, -8
; CHECK-NEXT:    cg %r0, 0(%r15)
; CHECK-NEXT:    clgrjh %r15, %r0, .LBB2_1
; CHECK-NEXT:  # %bb.2:
; CHECK-NEXT:    .cfi_def_cfa_register %r15
; CHECK-NEXT:    lgr %r11, %r15
; CHECK-NEXT:    .cfi_def_cfa_register %r11
; CHECK-NEXT:    # kill: def $r2l killed $r2l def $r2d
; CHECK-NEXT:    risbgn %r1, %r2, 30, 189, 2
; CHECK-NEXT:    la %r0, 7(%r1)
; CHECK-NEXT:    risbgn %r1, %r0, 29, 188, 0
; CHECK-NEXT:    clgijl %r1, 8, .LBB2_4
; CHECK-NEXT:  .LBB2_3: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    slgfi %r1, 8
; CHECK-NEXT:    slgfi %r15, 8
; CHECK-NEXT:    cg %r15, 0(%r15)
; CHECK-NEXT:    clgijhe %r1, 8, .LBB2_3
; CHECK-NEXT:  .LBB2_4:
; CHECK-NEXT:    cgije %r1, 0, .LBB2_6
; CHECK-NEXT:  # %bb.5:
; CHECK-NEXT:    slgr %r15, %r1
; CHECK-NEXT:    cg %r15, -8(%r1,%r15)
; CHECK-NEXT:  .LBB2_6:
; CHECK-NEXT:    la %r1, 160(%r15)
; CHECK-NEXT:    lhi %r0, 1
; CHECK-NEXT:    sty %r0, 4792(%r1)
; CHECK-NEXT:    l %r2, 0(%r1)
; CHECK-NEXT:    lmg %r11, %r15, 248(%r11)
; CHECK-NEXT:    br %r14
  %a = alloca i32, i32 %n
  %b = getelementptr inbounds i32, i32* %a, i64 1198
  store volatile i32 1, i32* %b
  %c = load volatile i32, i32* %a
  ret i32 %c
}

attributes #0 =  {"probe-stack"="inline-asm"}
