mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
R600/SI: Improve BFM support
llvm-svn: 233077
This commit is contained in:
parent
b3b6175988
commit
94b7dfa0f9
@ -1406,6 +1406,7 @@ unsigned SIInstrInfo::getVALUOp(const MachineInstr &MI) {
|
||||
case AMDGPU::S_SEXT_I32_I16: return AMDGPU::V_BFE_I32;
|
||||
case AMDGPU::S_BFE_U32: return AMDGPU::V_BFE_U32;
|
||||
case AMDGPU::S_BFE_I32: return AMDGPU::V_BFE_I32;
|
||||
case AMDGPU::S_BFM_B32: return AMDGPU::V_BFM_B32_e64;
|
||||
case AMDGPU::S_BREV_B32: return AMDGPU::V_BFREV_B32_e32;
|
||||
case AMDGPU::S_NOT_B32: return AMDGPU::V_NOT_B32_e32;
|
||||
case AMDGPU::S_NOT_B64: return AMDGPU::V_NOT_B32_e32;
|
||||
|
@ -308,7 +308,8 @@ defm S_ASHR_I64 : SOP2_64_32 <sop2<0x23, 0x21>, "s_ashr_i64",
|
||||
>;
|
||||
} // End Defs = [SCC]
|
||||
|
||||
defm S_BFM_B32 : SOP2_32 <sop2<0x24, 0x22>, "s_bfm_b32", []>;
|
||||
defm S_BFM_B32 : SOP2_32 <sop2<0x24, 0x22>, "s_bfm_b32",
|
||||
[(set i32:$dst, (AMDGPUbfm i32:$src0, i32:$src1))]>;
|
||||
defm S_BFM_B64 : SOP2_64 <sop2<0x25, 0x23>, "s_bfm_b64", []>;
|
||||
defm S_MUL_I32 : SOP2_32 <sop2<0x26, 0x24>, "s_mul_i32",
|
||||
[(set i32:$dst, (mul i32:$src0, i32:$src1))]
|
||||
@ -1613,8 +1614,8 @@ defm V_MAC_LEGACY_F32 : VOP2_VI3_Inst <vop23<0x6, 0x28e>, "v_mac_legacy_f32",
|
||||
>;
|
||||
} // End isCommutable = 1
|
||||
|
||||
defm V_BFM_B32 : VOP2_VI3_Inst <vop23<0x1e, 0x293>, "v_bfm_b32", VOP_I32_I32_I32,
|
||||
AMDGPUbfm
|
||||
defm V_BFM_B32 : VOP2_VI3_Inst <vop23<0x1e, 0x293>, "v_bfm_b32",
|
||||
VOP_I32_I32_I32
|
||||
>;
|
||||
defm V_BCNT_U32_B32 : VOP2_VI3_Inst <vop23<0x22, 0x28b>, "v_bcnt_u32_b32",
|
||||
VOP_I32_I32_I32
|
||||
@ -3323,6 +3324,21 @@ def : Pat <
|
||||
(V_CNDMASK_B32_e64 $src0, $src1, $src2)
|
||||
>;
|
||||
|
||||
multiclass BFMPatterns <ValueType vt, InstSI BFM, InstSI MOV> {
|
||||
def : Pat <
|
||||
(vt (shl (vt (add (vt (shl 1, vt:$a)), -1)), vt:$b)),
|
||||
(BFM $a, $b)
|
||||
>;
|
||||
|
||||
def : Pat <
|
||||
(vt (add (vt (shl 1, vt:$a)), -1)),
|
||||
(BFM $a, (MOV 0))
|
||||
>;
|
||||
}
|
||||
|
||||
defm : BFMPatterns <i32, S_BFM_B32, S_MOV_B32>;
|
||||
// FIXME: defm : BFMPatterns <i64, S_BFM_B64, S_MOV_B64>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Fract Patterns
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -5,7 +5,7 @@
|
||||
declare i32 @llvm.AMDGPU.bfm(i32, i32) nounwind readnone
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_arg_arg:
|
||||
; SI: v_bfm
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
|
||||
; EG: BFM_INT
|
||||
define void @bfm_arg_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind {
|
||||
%bfm = call i32 @llvm.AMDGPU.bfm(i32 %src0, i32 %src1) nounwind readnone
|
||||
@ -14,7 +14,7 @@ define void @bfm_arg_arg(i32 addrspace(1)* %out, i32 %src0, i32 %src1) nounwind
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_arg_imm:
|
||||
; SI: v_bfm
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0x7b
|
||||
; EG: BFM_INT
|
||||
define void @bfm_arg_imm(i32 addrspace(1)* %out, i32 %src0) nounwind {
|
||||
%bfm = call i32 @llvm.AMDGPU.bfm(i32 %src0, i32 123) nounwind readnone
|
||||
@ -23,7 +23,7 @@ define void @bfm_arg_imm(i32 addrspace(1)* %out, i32 %src0) nounwind {
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_imm_arg:
|
||||
; SI: v_bfm
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, 0x7b, {{s[0-9]+}}
|
||||
; EG: BFM_INT
|
||||
define void @bfm_imm_arg(i32 addrspace(1)* %out, i32 %src1) nounwind {
|
||||
%bfm = call i32 @llvm.AMDGPU.bfm(i32 123, i32 %src1) nounwind readnone
|
||||
@ -32,10 +32,29 @@ define void @bfm_imm_arg(i32 addrspace(1)* %out, i32 %src1) nounwind {
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_imm_imm:
|
||||
; SI: v_bfm
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, 0x7b, 0x1c8
|
||||
; EG: BFM_INT
|
||||
define void @bfm_imm_imm(i32 addrspace(1)* %out) nounwind {
|
||||
%bfm = call i32 @llvm.AMDGPU.bfm(i32 123, i32 456) nounwind readnone
|
||||
store i32 %bfm, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_pattern:
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, {{s[0-9]+}}
|
||||
define void @bfm_pattern(i32 addrspace(1)* %out, i32 %x, i32 %y) {
|
||||
%a = shl i32 1, %x
|
||||
%b = sub i32 %a, 1
|
||||
%c = shl i32 %b, %y
|
||||
store i32 %c, i32 addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}bfm_pattern_simple:
|
||||
; SI: s_bfm_b32 {{s[0-9]+}}, {{s[0-9]+}}, 0
|
||||
define void @bfm_pattern_simple(i32 addrspace(1)* %out, i32 %x) {
|
||||
%a = shl i32 1, %x
|
||||
%b = sub i32 %a, 1
|
||||
store i32 %b, i32 addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user