llvm/llvm/test/CodeGen/AArch64/get_vector_length.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc < %s -mtriple=aarch64-linux-gnu -mattr=+sve | FileCheck %s

declare i32 @llvm.experimental.get.vector.length.i16(i16, i32, i1)
declare i32 @llvm.experimental.get.vector.length.i32(i32, i32, i1)
declare i32 @llvm.experimental.get.vector.length.i64(i64, i32, i1)

define i32 @vector_length_i16(i16 zeroext %tc) {
; CHECK-LABEL: vector_length_i16:
; CHECK:       // %bb.0:
; CHECK-NEXT:    cntd x8
; CHECK-NEXT:    cmp w0, w8
; CHECK-NEXT:    csel w0, w0, w8, lo
; CHECK-NEXT:    ret
  %a = call i32 @llvm.experimental.get.vector.length.i16(i16 %tc, i32 2, i1 true)
  ret i32 %a
}

define i32 @vector_length_i32(i32 zeroext %tc) {
; CHECK-LABEL: vector_length_i32:
; CHECK:       // %bb.0:
; CHECK-NEXT:    cntd x8
; CHECK-NEXT:    cmp w0, w8
; CHECK-NEXT:    csel w0, w0, w8, lo
; CHECK-NEXT:    ret
  %a = call i32 @llvm.experimental.get.vector.length.i32(i32 %tc, i32 2, i1 true)
  ret i32 %a
}

define i32 @vector_length_i64(i64 %tc) {
; CHECK-LABEL: vector_length_i64:
; CHECK:       // %bb.0:
; CHECK-NEXT:    cntd x8
; CHECK-NEXT:    cmp x0, x8
; CHECK-NEXT:    csel x0, x0, x8, lo
; CHECK-NEXT:    // kill: def $w0 killed $w0 killed $x0
; CHECK-NEXT:    ret
  %a = call i32 @llvm.experimental.get.vector.length.i64(i64 %tc, i32 2, i1 true)
  ret i32 %a
}