Compiler projects using llvm
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O2 -mtriple=aarch64-linux-gnu < %s | FileCheck %s

declare i32 @test(i32) local_unnamed_addr
declare i32 @test1(i64) local_unnamed_addr

define i32 @assertzext(i32 %n, i1 %a, i32* %b) local_unnamed_addr {
; CHECK-LABEL: assertzext:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
; CHECK-NEXT:    .cfi_def_cfa_offset 16
; CHECK-NEXT:    .cfi_offset w19, -8
; CHECK-NEXT:    .cfi_offset w30, -16
; CHECK-NEXT:    mov w8, #33066
; CHECK-NEXT:    tst w1, #0x1
; CHECK-NEXT:    movk w8, #28567, lsl #16
; CHECK-NEXT:    csel w19, wzr, w8, ne
; CHECK-NEXT:    cbnz w0, .LBB0_2
; CHECK-NEXT:  // %bb.1: // %if.then
; CHECK-NEXT:    mov w19, wzr
; CHECK-NEXT:    str wzr, [x2]
; CHECK-NEXT:  .LBB0_2: // %if.end
; CHECK-NEXT:    mov w0, w19
; CHECK-NEXT:    bl test
; CHECK-NEXT:    mov w0, w19
; CHECK-NEXT:    bl test1
; CHECK-NEXT:    mov w0, wzr
; CHECK-NEXT:    ldp x30, x19, [sp], #16 // 16-byte Folded Reload
; CHECK-NEXT:    ret
entry:
  %i = select i1 %a, i64 0, i64 66296709418
  %conv.i = trunc i64 %i to i32
  %cmp = icmp eq i32 %n, 0
  br i1 %cmp, label %if.then, label %if.end

if.then:                     ; preds = %entry
  store i32 0, i32* %b, align 4
  br label %if.end

if.end:                      ; preds = %if.then, %entry
  %i1 = phi i32 [ 0, %if.then ], [ %conv.i, %entry ]
  %call.i = tail call i32 @test(i32 %i1)
  %i2 = sext i32 %i1 to i64
  %call1.i = tail call i32 @test1(i64 %i2)
  ret i32 0
}

define i32 @assertsext(i32 %n, i8 %a) local_unnamed_addr {
; CHECK-LABEL: assertsext:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    cbz w0, .LBB1_2
; CHECK-NEXT:  // %bb.1:
; CHECK-NEXT:    mov x0, xzr
; CHECK-NEXT:    b .LBB1_3
; CHECK-NEXT:  .LBB1_2: // %if.then
; CHECK-NEXT:    mov x9, #24575
; CHECK-NEXT:    sxtb w8, w1
; CHECK-NEXT:    movk x9, #15873, lsl #16
; CHECK-NEXT:    movk x9, #474, lsl #32
; CHECK-NEXT:    udiv x0, x9, x8
; CHECK-NEXT:  .LBB1_3: // %if.end
; CHECK-NEXT:    str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT:    .cfi_def_cfa_offset 16
; CHECK-NEXT:    .cfi_offset w30, -16
; CHECK-NEXT:    bl test1
; CHECK-NEXT:    mov w0, wzr
; CHECK-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT:    ret
entry:
  %conv.i = sext i8 %a to i32
  %cmp = icmp eq i32 %n, 0
  br i1 %cmp, label %if.then, label %if.end

if.then:                     ; preds = %entry
  %conv1 = zext i32 %conv.i to i64
  %div = udiv i64 2036854775807, %conv1
  br label %if.end

if.end:                      ; preds = %if.then, %entry
  %i1 = phi i64 [ %div, %if.then ], [ 0, %entry ]
  %call1.i = tail call i32 @test1(i64 %i1)
  ret i32 0
}