1 ; RUN: llc -march=r600 -mcpu=cayman < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4 ; FUNC-LABEL: {{^}}test_umul24_i32:
5 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]\.[XYZW]}}, KC0[2].Z, KC0[2].W
6 define amdgpu_kernel void @test_umul24_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) {
11 %b_24 = lshr i32 %1, 8
12 %2 = mul i32 %a_24, %b_24
13 store i32 %2, i32 addrspace(1)* %out
17 ; The result must be sign-extended.
18 ; FUNC-LABEL: {{^}}test_umul24_i16_sext:
19 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]}}.[[MUL_CHAN:[XYZW]]]
20 ; EG: BFE_INT {{[* ]*}}T{{[0-9]}}.{{[XYZW]}}, PV.[[MUL_CHAN]], 0.0, literal.x
22 define amdgpu_kernel void @test_umul24_i16_sext(i32 addrspace(1)* %out, i16 %a, i16 %b) {
25 %ext = sext i16 %mul to i32
26 store i32 %ext, i32 addrspace(1)* %out
30 ; The result must be sign-extended.
31 ; FUNC-LABEL: {{^}}test_umul24_i8:
32 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]}}.[[MUL_CHAN:[XYZW]]]
33 ; EG: BFE_INT {{[* ]*}}T{{[0-9]}}.{{[XYZW]}}, PV.[[MUL_CHAN]], 0.0, literal.x
34 define amdgpu_kernel void @test_umul24_i8(i32 addrspace(1)* %out, i8 %a, i8 %b) {
37 %ext = sext i8 %mul to i32
38 store i32 %ext, i32 addrspace(1)* %out
42 ; FUNC-LABEL: {{^}}test_umulhi24_i32_i64:
43 ; EG: MULHI_UINT24 {{[* ]*}}T{{[0-9]\.[XYZW]}}, KC0[2].Z, KC0[2].W
44 define amdgpu_kernel void @test_umulhi24_i32_i64(i32 addrspace(1)* %out, i32 %a, i32 %b) {
46 %a.24 = and i32 %a, 16777215
47 %b.24 = and i32 %b, 16777215
48 %a.24.i64 = zext i32 %a.24 to i64
49 %b.24.i64 = zext i32 %b.24 to i64
50 %mul48 = mul i64 %a.24.i64, %b.24.i64
51 %mul48.hi = lshr i64 %mul48, 32
52 %mul24hi = trunc i64 %mul48.hi to i32
53 store i32 %mul24hi, i32 addrspace(1)* %out
57 ; FUNC-LABEL: {{^}}test_umulhi24:
58 ; EG: MULHI_UINT24 {{[* ]*}}T{{[0-9]\.[XYZW]}}, KC0[2].W, KC0[3].Y
59 define amdgpu_kernel void @test_umulhi24(i32 addrspace(1)* %out, i64 %a, i64 %b) {
61 %a.24 = and i64 %a, 16777215
62 %b.24 = and i64 %b, 16777215
63 %mul48 = mul i64 %a.24, %b.24
64 %mul48.hi = lshr i64 %mul48, 32
65 %mul24.hi = trunc i64 %mul48.hi to i32
66 store i32 %mul24.hi, i32 addrspace(1)* %out
70 ; Multiply with 24-bit inputs and 64-bit output.
71 ; FUNC-LABEL: {{^}}test_umul24_i64:
74 define amdgpu_kernel void @test_umul24_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
76 %tmp0 = shl i64 %a, 40
77 %a_24 = lshr i64 %tmp0, 40
78 %tmp1 = shl i64 %b, 40
79 %b_24 = lshr i64 %tmp1, 40
80 %tmp2 = mul i64 %a_24, %b_24
81 store i64 %tmp2, i64 addrspace(1)* %out