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