mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
R600/SI: Only form min/max with 1 use.
If the condition is used for something else, this increases the number of instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b60b7360f5
commit
7fc3bdab6a
@ -2300,7 +2300,7 @@ SDValue AMDGPUTargetLowering::PerformDAGCombine(SDNode *N,
|
||||
}
|
||||
case ISD::SELECT: {
|
||||
SDValue Cond = N->getOperand(0);
|
||||
if (Cond.getOpcode() == ISD::SETCC) {
|
||||
if (Cond.getOpcode() == ISD::SETCC && Cond.hasOneUse()) {
|
||||
SDLoc DL(N);
|
||||
EVT VT = N->getValueType(0);
|
||||
SDValue LHS = Cond.getOperand(0);
|
||||
|
@ -79,5 +79,30 @@ define void @test_fmax_legacy_ogt_f32(float addrspace(1)* %out, float addrspace(
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; FUNC-LABEL: @test_fmax_legacy_ogt_f32_multi_use
|
||||
; SI: buffer_load_dword [[A:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
||||
; SI: buffer_load_dword [[B:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
|
||||
; SI-NOT: v_max_
|
||||
; SI: v_cmp_gt_f32
|
||||
; SI-NEXT: v_cndmask_b32
|
||||
; SI-NOT: v_max_
|
||||
|
||||
; EG: MAX
|
||||
define void @test_fmax_legacy_ogt_f32_multi_use(float addrspace(1)* %out0, i1 addrspace(1)* %out1, float addrspace(1)* %in) #0 {
|
||||
%tid = call i32 @llvm.r600.read.tidig.x() #1
|
||||
%gep.0 = getelementptr float addrspace(1)* %in, i32 %tid
|
||||
%gep.1 = getelementptr float addrspace(1)* %gep.0, i32 1
|
||||
|
||||
%a = load float addrspace(1)* %gep.0, align 4
|
||||
%b = load float addrspace(1)* %gep.1, align 4
|
||||
|
||||
%cmp = fcmp ogt float %a, %b
|
||||
%val = select i1 %cmp, float %a, float %b
|
||||
store float %val, float addrspace(1)* %out0, align 4
|
||||
store i1 %cmp, i1addrspace(1)* %out1
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind }
|
||||
attributes #1 = { nounwind readnone }
|
||||
|
@ -88,5 +88,28 @@ define void @test_fmin_legacy_ult_f32(float addrspace(1)* %out, float addrspace(
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @test_fmin_legacy_ole_f32_multi_use
|
||||
; SI: buffer_load_dword [[A:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
|
||||
; SI: buffer_load_dword [[B:v[0-9]+]], {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4
|
||||
; SI-NOT: v_min
|
||||
; SI: v_cmp_le_f32
|
||||
; SI-NEXT: v_cndmask_b32
|
||||
; SI-NOT: v_min
|
||||
; SI: s_endpgm
|
||||
define void @test_fmin_legacy_ole_f32_multi_use(float addrspace(1)* %out0, i1 addrspace(1)* %out1, float addrspace(1)* %in) #0 {
|
||||
%tid = call i32 @llvm.r600.read.tidig.x() #1
|
||||
%gep.0 = getelementptr float addrspace(1)* %in, i32 %tid
|
||||
%gep.1 = getelementptr float addrspace(1)* %gep.0, i32 1
|
||||
|
||||
%a = load float addrspace(1)* %gep.0, align 4
|
||||
%b = load float addrspace(1)* %gep.1, align 4
|
||||
|
||||
%cmp = fcmp ole float %a, %b
|
||||
%val0 = select i1 %cmp, float %a, float %b
|
||||
store float %val0, float addrspace(1)* %out0, align 4
|
||||
store i1 %cmp, i1 addrspace(1)* %out1
|
||||
ret void
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind }
|
||||
attributes #1 = { nounwind readnone }
|
||||
|
@ -97,3 +97,24 @@ define void @s_test_umin_ult_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @v_test_umin_ult_i32_multi_use
|
||||
; SI-NOT: v_min
|
||||
; SI: v_cmp_lt_u32
|
||||
; SI-NEXT: v_cndmask_b32
|
||||
; SI-NOT: v_min
|
||||
; SI: s_endpgm
|
||||
define void @v_test_umin_ult_i32_multi_use(i32 addrspace(1)* %out0, i1 addrspace(1)* %out1, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
|
||||
%gep0 = getelementptr i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep0 = getelementptr i32 addrspace(1)* %out0, i32 %tid
|
||||
%outgep1 = getelementptr i1 addrspace(1)* %out1, i32 %tid
|
||||
%a = load i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32 addrspace(1)* %gep1, align 4
|
||||
%cmp = icmp ult i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep0, align 4
|
||||
store i1 %cmp, i1 addrspace(1)* %outgep1
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user