; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc --mtriple=loongarch32 --mattr=+32s,+lasx < %s | FileCheck %s
; RUN: llc --mtriple=loongarch64 --mattr=+lasx < %s | FileCheck %s

declare <8 x float> @llvm.log2.v8f32(<8 x float>)
declare <4 x double> @llvm.log2.v4f64(<4 x double>)

define void @flog2_v8f32(ptr %res, ptr %a) nounwind {
; CHECK-LABEL: flog2_v8f32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xvld $xr0, $a1, 0
; CHECK-NEXT:    xvflogb.s $xr0, $xr0
; CHECK-NEXT:    xvst $xr0, $a0, 0
; CHECK-NEXT:    ret
entry:
  %v = load <8 x float>, ptr %a
  %r = call <8 x float> @llvm.log2.v8f32(<8 x float> %v)
  store <8 x float> %r, ptr %res
  ret void
}

define void @flog2_v4f64(ptr %res, ptr %a) nounwind {
; CHECK-LABEL: flog2_v4f64:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    xvld $xr0, $a1, 0
; CHECK-NEXT:    xvflogb.d $xr0, $xr0
; CHECK-NEXT:    xvst $xr0, $a0, 0
; CHECK-NEXT:    ret
entry:
  %v = load <4 x double>, ptr %a
  %r = call <4 x double> @llvm.log2.v4f64(<4 x double> %v)
  store <4 x double> %r, ptr %res
  ret void
}
