llvm/llvm/test/CodeGen/AArch64/complex-deinterleaving-f64-mul-scalable.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s --mattr=+sve -o - | FileCheck %s

target triple = "aarch64"

; Expected to transform
define <vscale x 2 x double> @complex_mul_v2f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b) {
; CHECK-LABEL: complex_mul_v2f64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov z2.d, #0 // =0x0
; CHECK-NEXT:    ptrue p0.d
; CHECK-NEXT:    fcmla z2.d, p0/m, z1.d, z0.d, #0
; CHECK-NEXT:    fcmla z2.d, p0/m, z1.d, z0.d, #90
; CHECK-NEXT:    mov z0.d, z2.d
; CHECK-NEXT:    ret
entry:
  %a.deinterleaved = tail call { <vscale x 1 x double>, <vscale x 1 x double> } @llvm.vector.deinterleave2.nxv2f64(<vscale x 2 x double> %a)
  %a.real = extractvalue { <vscale x 1 x double>, <vscale x 1 x double> } %a.deinterleaved, 0
  %a.imag = extractvalue { <vscale x 1 x double>, <vscale x 1 x double> } %a.deinterleaved, 1
  %b.deinterleaved = tail call { <vscale x 1 x double>, <vscale x 1 x double> } @llvm.vector.deinterleave2.nxv2f64(<vscale x 2 x double> %b)
  %b.real = extractvalue { <vscale x 1 x double>, <vscale x 1 x double> } %b.deinterleaved, 0
  %b.imag = extractvalue { <vscale x 1 x double>, <vscale x 1 x double> } %b.deinterleaved, 1
  %0 = fmul fast <vscale x 1 x double> %b.imag, %a.real
  %1 = fmul fast <vscale x 1 x double> %b.real, %a.imag
  %2 = fadd fast <vscale x 1 x double> %1, %0
  %3 = fmul fast <vscale x 1 x double> %b.real, %a.real
  %4 = fmul fast <vscale x 1 x double> %a.imag, %b.imag
  %5 = fsub fast <vscale x 1 x double> %3, %4
  %interleaved.vec = tail call <vscale x 2 x double> @llvm.vector.interleave2.nxv2f64(<vscale x 1 x double> %5, <vscale x 1 x double> %2)
  ret <vscale x 2 x double> %interleaved.vec
}

; Expected to transform
define <vscale x 4 x double> @complex_mul_v4f64(<vscale x 4 x double> %a, <vscale x 4 x double> %b) {
; CHECK-LABEL: complex_mul_v4f64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov z4.d, #0 // =0x0
; CHECK-NEXT:    ptrue p0.d
; CHECK-NEXT:    mov z5.d, z4.d
; CHECK-NEXT:    fcmla z4.d, p0/m, z3.d, z1.d, #0
; CHECK-NEXT:    fcmla z5.d, p0/m, z2.d, z0.d, #0
; CHECK-NEXT:    fcmla z4.d, p0/m, z3.d, z1.d, #90
; CHECK-NEXT:    fcmla z5.d, p0/m, z2.d, z0.d, #90
; CHECK-NEXT:    mov z1.d, z4.d
; CHECK-NEXT:    mov z0.d, z5.d
; CHECK-NEXT:    ret
entry:
  %a.deinterleaved = tail call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %a)
  %a.real = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } %a.deinterleaved, 0
  %a.imag = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } %a.deinterleaved, 1
  %b.deinterleaved = tail call { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double> %b)
  %b.real = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } %b.deinterleaved, 0
  %b.imag = extractvalue { <vscale x 2 x double>, <vscale x 2 x double> } %b.deinterleaved, 1
  %0 = fmul fast <vscale x 2 x double> %b.imag, %a.real
  %1 = fmul fast <vscale x 2 x double> %b.real, %a.imag
  %2 = fadd fast <vscale x 2 x double> %1, %0
  %3 = fmul fast <vscale x 2 x double> %b.real, %a.real
  %4 = fmul fast <vscale x 2 x double> %a.imag, %b.imag
  %5 = fsub fast <vscale x 2 x double> %3, %4
  %interleaved.vec = tail call <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double> %5, <vscale x 2 x double> %2)
  ret <vscale x 4 x double> %interleaved.vec
}

; Expected to transform
define <vscale x 8 x double> @complex_mul_v8f64(<vscale x 8 x double> %a, <vscale x 8 x double> %b) {
; CHECK-LABEL: complex_mul_v8f64:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov z24.d, #0 // =0x0
; CHECK-NEXT:    ptrue p0.d
; CHECK-NEXT:    mov z25.d, z24.d
; CHECK-NEXT:    mov z26.d, z24.d
; CHECK-NEXT:    mov z27.d, z24.d
; CHECK-NEXT:    fcmla z24.d, p0/m, z7.d, z3.d, #0
; CHECK-NEXT:    fcmla z25.d, p0/m, z4.d, z0.d, #0
; CHECK-NEXT:    fcmla z26.d, p0/m, z5.d, z1.d, #0
; CHECK-NEXT:    fcmla z27.d, p0/m, z6.d, z2.d, #0
; CHECK-NEXT:    fcmla z24.d, p0/m, z7.d, z3.d, #90
; CHECK-NEXT:    fcmla z25.d, p0/m, z4.d, z0.d, #90
; CHECK-NEXT:    fcmla z26.d, p0/m, z5.d, z1.d, #90
; CHECK-NEXT:    fcmla z27.d, p0/m, z6.d, z2.d, #90
; CHECK-NEXT:    mov z3.d, z24.d
; CHECK-NEXT:    mov z0.d, z25.d
; CHECK-NEXT:    mov z1.d, z26.d
; CHECK-NEXT:    mov z2.d, z27.d
; CHECK-NEXT:    ret
entry:
  %a.deinterleaved = tail call { <vscale x 4 x double>, <vscale x 4 x double> } @llvm.vector.deinterleave2.nxv8f64(<vscale x 8 x double> %a)
  %a.real = extractvalue { <vscale x 4 x double>, <vscale x 4 x double> } %a.deinterleaved, 0
  %a.imag = extractvalue { <vscale x 4 x double>, <vscale x 4 x double> } %a.deinterleaved, 1
  %b.deinterleaved = tail call { <vscale x 4 x double>, <vscale x 4 x double> } @llvm.vector.deinterleave2.nxv8f64(<vscale x 8 x double> %b)
  %b.real = extractvalue { <vscale x 4 x double>, <vscale x 4 x double> } %b.deinterleaved, 0
  %b.imag = extractvalue { <vscale x 4 x double>, <vscale x 4 x double> } %b.deinterleaved, 1
  %0 = fmul fast <vscale x 4 x double> %b.imag, %a.real
  %1 = fmul fast <vscale x 4 x double> %b.real, %a.imag
  %2 = fadd fast <vscale x 4 x double> %1, %0
  %3 = fmul fast <vscale x 4 x double> %b.real, %a.real
  %4 = fmul fast <vscale x 4 x double> %a.imag, %b.imag
  %5 = fsub fast <vscale x 4 x double> %3, %4
  %interleaved.vec = tail call <vscale x 8 x double> @llvm.vector.interleave2.nxv8f64(<vscale x 4 x double> %5, <vscale x 4 x double> %2)
  ret <vscale x 8 x double> %interleaved.vec
}

declare { <vscale x 1 x double>, <vscale x 1 x double> } @llvm.vector.deinterleave2.nxv2f64(<vscale x 2 x double>)
declare <vscale x 2 x double> @llvm.vector.interleave2.nxv2f64(<vscale x 1 x double>, <vscale x 1 x double>)

declare { <vscale x 2 x double>, <vscale x 2 x double> } @llvm.vector.deinterleave2.nxv4f64(<vscale x 4 x double>)
declare <vscale x 4 x double> @llvm.vector.interleave2.nxv4f64(<vscale x 2 x double>, <vscale x 2 x double>)

declare { <vscale x 4 x double>, <vscale x 4 x double> } @llvm.vector.deinterleave2.nxv8f64(<vscale x 8 x double>)
declare <vscale x 8 x double> @llvm.vector.interleave2.nxv8f64(<vscale x 4 x double>, <vscale x 4 x double>)