Home | History | Annotate | Download | only in AMDGPU
      1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
      2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
      3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
      4 
      5 ; FUNC-LABEL: {{^}}fmul_f32:
      6 ; GCN: v_mul_f32
      7 
      8 ; R600: MUL_IEEE {{\** *}}{{T[0-9]+\.[XYZW]}}, KC0[2].Z, KC0[2].W
      9 define void @fmul_f32(float addrspace(1)* %out, float %a, float %b) {
     10 entry:
     11   %0 = fmul float %a, %b
     12   store float %0, float addrspace(1)* %out
     13   ret void
     14 }
     15 
     16 declare float @llvm.R600.load.input(i32) readnone
     17 
     18 declare void @llvm.AMDGPU.store.output(float, i32)
     19 
     20 ; FUNC-LABEL: {{^}}fmul_v2f32:
     21 ; GCN: v_mul_f32
     22 ; GCN: v_mul_f32
     23 
     24 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW]}}
     25 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW]}}
     26 define void @fmul_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %a, <2 x float> %b) {
     27 entry:
     28   %0 = fmul <2 x float> %a, %b
     29   store <2 x float> %0, <2 x float> addrspace(1)* %out
     30   ret void
     31 }
     32 
     33 ; FUNC-LABEL: {{^}}fmul_v4f32:
     34 ; GCN: v_mul_f32
     35 ; GCN: v_mul_f32
     36 ; GCN: v_mul_f32
     37 ; GCN: v_mul_f32
     38 
     39 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
     40 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
     41 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
     42 ; R600: MUL_IEEE {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
     43 define void @fmul_v4f32(<4 x float> addrspace(1)* %out, <4 x float> addrspace(1)* %in) {
     44   %b_ptr = getelementptr <4 x float>, <4 x float> addrspace(1)* %in, i32 1
     45   %a = load <4 x float>, <4 x float> addrspace(1) * %in
     46   %b = load <4 x float>, <4 x float> addrspace(1) * %b_ptr
     47   %result = fmul <4 x float> %a, %b
     48   store <4 x float> %result, <4 x float> addrspace(1)* %out
     49   ret void
     50 }
     51 
     52 ; FUNC-LABEL: {{^}}test_mul_2_k:
     53 ; GCN: v_mul_f32
     54 ; GCN-NOT: v_mul_f32
     55 ; GCN: s_endpgm
     56 define void @test_mul_2_k(float addrspace(1)* %out, float %x) #0 {
     57   %y = fmul float %x, 2.0
     58   %z = fmul float %y, 3.0
     59   store float %z, float addrspace(1)* %out
     60   ret void
     61 }
     62 
     63 ; FUNC-LABEL: {{^}}test_mul_2_k_inv:
     64 ; GCN: v_mul_f32
     65 ; GCN-NOT: v_mul_f32
     66 ; GCN-NOT: v_mad_f32
     67 ; GCN: s_endpgm
     68 define void @test_mul_2_k_inv(float addrspace(1)* %out, float %x) #0 {
     69   %y = fmul float %x, 3.0
     70   %z = fmul float %y, 2.0
     71   store float %z, float addrspace(1)* %out
     72   ret void
     73 }
     74 
     75 ; There should be three multiplies here; %a should be used twice (once
     76 ; negated), not duplicated into mul x, 5.0 and mul x, -5.0.
     77 ; FUNC-LABEL: {{^}}test_mul_twouse:
     78 ; GCN: v_mul_f32
     79 ; GCN: v_mul_f32
     80 ; GCN: v_mul_f32
     81 ; GCN-NOT: v_mul_f32
     82 define void @test_mul_twouse(float addrspace(1)* %out, float %x, float %y) #0 {
     83   %a = fmul float %x, 5.0
     84   %b = fsub float -0.0, %a
     85   %c = fmul float %b, %y
     86   %d = fmul float %c, %a
     87   store float %d, float addrspace(1)* %out
     88   ret void
     89 }
     90 
     91 attributes #0 = { nounwind }
     92