]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/R600/mul_uint24.ll
Vendor import of llvm RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
[FreeBSD/FreeBSD.git] / test / CodeGen / R600 / mul_uint24.ll
1 ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=EG --check-prefix=FUNC
2 ; RUN: llc < %s -march=r600 -mcpu=cayman | FileCheck %s --check-prefix=EG --check-prefix=FUNC
3 ; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s --check-prefix=SI --check-prefix=FUNC
4
5 ; FUNC-LABEL: @u32_mul24
6 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]\.[XYZW]}}, KC0[2].Z, KC0[2].W
7 ; SI: V_MUL_U32_U24
8
9 define void @u32_mul24(i32 addrspace(1)* %out, i32 %a, i32 %b) {
10 entry:
11   %0 = shl i32 %a, 8
12   %a_24 = lshr i32 %0, 8
13   %1 = shl i32 %b, 8
14   %b_24 = lshr i32 %1, 8
15   %2 = mul i32 %a_24, %b_24
16   store i32 %2, i32 addrspace(1)* %out
17   ret void
18 }
19
20 ; FUNC-LABEL: @i16_mul24
21 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]}}.[[MUL_CHAN:[XYZW]]]
22 ; The result must be sign-extended
23 ; EG: BFE_INT {{[* ]*}}T{{[0-9]}}.{{[XYZW]}}, PV.[[MUL_CHAN]], 0.0, literal.x
24 ; EG: 16
25 ; SI: V_MUL_U32_U24_e{{(32|64)}} [[MUL:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
26 ; SI: V_BFE_I32 v{{[0-9]}}, [[MUL]], 0, 16,
27 define void @i16_mul24(i32 addrspace(1)* %out, i16 %a, i16 %b) {
28 entry:
29   %0 = mul i16 %a, %b
30   %1 = sext i16 %0 to i32
31   store i32 %1, i32 addrspace(1)* %out
32   ret void
33 }
34
35 ; FUNC-LABEL: @i8_mul24
36 ; EG: MUL_UINT24 {{[* ]*}}T{{[0-9]}}.[[MUL_CHAN:[XYZW]]]
37 ; The result must be sign-extended
38 ; EG: BFE_INT {{[* ]*}}T{{[0-9]}}.{{[XYZW]}}, PV.[[MUL_CHAN]], 0.0, literal.x
39 ; SI: V_MUL_U32_U24_e{{(32|64)}} [[MUL:v[0-9]]], {{[sv][0-9], [sv][0-9]}}
40 ; SI: V_BFE_I32 v{{[0-9]}}, [[MUL]], 0, 8,
41
42 define void @i8_mul24(i32 addrspace(1)* %out, i8 %a, i8 %b) {
43 entry:
44   %0 = mul i8 %a, %b
45   %1 = sext i8 %0 to i32
46   store i32 %1, i32 addrspace(1)* %out
47   ret void
48 }
49
50 ; Multiply with 24-bit inputs and 64-bit output
51 ; FUNC_LABEL: @mul24_i64
52 ; EG; MUL_UINT24
53 ; EG: MULHI
54 ; SI: V_MUL_U32_U24
55 ; FIXME: SI support 24-bit mulhi
56 ; SI: V_MUL_HI_U32
57 define void @mul24_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
58 entry:
59   %0 = shl i64 %a, 40
60   %a_24 = lshr i64 %0, 40
61   %1 = shl i64 %b, 40
62   %b_24 = lshr i64 %1, 40
63   %2 = mul i64 %a_24, %b_24
64   store i64 %2, i64 addrspace(1)* %out
65   ret void
66 }