mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-27 07:12:06 +00:00
SelectionDAG: Implement expansion of {S,U}MIN/MAX in integer legalization
Fixes {u,}long_{min,max,clamp} opencl piglit regressions on EG. Reviewers: arsenm Differential Revision: http://reviews.llvm.org/D17898 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272272 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5fe52b9fdf
commit
406c47ff89
@ -1371,6 +1371,11 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
|
||||
case ISD::OR:
|
||||
case ISD::XOR: ExpandIntRes_Logical(N, Lo, Hi); break;
|
||||
|
||||
case ISD::UMAX:
|
||||
case ISD::SMAX:
|
||||
case ISD::UMIN:
|
||||
case ISD::SMIN: ExpandIntRes_MINMAX(N, Lo, Hi); break;
|
||||
|
||||
case ISD::ADD:
|
||||
case ISD::SUB: ExpandIntRes_ADDSUB(N, Lo, Hi); break;
|
||||
|
||||
@ -1663,6 +1668,54 @@ ExpandShiftWithUnknownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::pair<ISD::CondCode, ISD::NodeType> getExpandedMinMaxOps(int Op) {
|
||||
|
||||
switch (Op) {
|
||||
default: llvm_unreachable("invalid min/max opcode");
|
||||
case ISD::SMAX:
|
||||
return std::make_pair(ISD::SETGT, ISD::UMAX);
|
||||
case ISD::UMAX:
|
||||
return std::make_pair(ISD::SETUGT, ISD::UMAX);
|
||||
case ISD::SMIN:
|
||||
return std::make_pair(ISD::SETLT, ISD::UMIN);
|
||||
case ISD::UMIN:
|
||||
return std::make_pair(ISD::SETULT, ISD::UMIN);
|
||||
}
|
||||
}
|
||||
|
||||
void DAGTypeLegalizer::ExpandIntRes_MINMAX(SDNode *N,
|
||||
SDValue &Lo, SDValue &Hi) {
|
||||
SDLoc DL(N);
|
||||
ISD::NodeType LoOpc;
|
||||
ISD::CondCode CondC;
|
||||
std::tie(CondC, LoOpc) = getExpandedMinMaxOps(N->getOpcode());
|
||||
|
||||
// Expand the subcomponents.
|
||||
SDValue LHSL, LHSH, RHSL, RHSH;
|
||||
GetExpandedInteger(N->getOperand(0), LHSL, LHSH);
|
||||
GetExpandedInteger(N->getOperand(1), RHSL, RHSH);
|
||||
|
||||
// Value types
|
||||
EVT NVT = LHSL.getValueType();
|
||||
EVT CCT = getSetCCResultType(NVT);
|
||||
|
||||
// Hi part is always the same op
|
||||
Hi = DAG.getNode(N->getOpcode(), DL, {NVT, NVT}, {LHSH, RHSH});
|
||||
|
||||
// We need to know whether to select Lo part that corresponds to 'winning'
|
||||
// Hi part or if Hi parts are equal.
|
||||
SDValue IsHiLeft = DAG.getSetCC(DL, CCT, LHSH, RHSH, CondC);
|
||||
SDValue IsHiEq = DAG.getSetCC(DL, CCT, LHSH, RHSH, ISD::SETEQ);
|
||||
|
||||
// Lo part corresponding to the 'winning' Hi part
|
||||
SDValue LoCmp = DAG.getSelect(DL, NVT, IsHiLeft, LHSL, RHSL);
|
||||
|
||||
// Recursed Lo part if Hi parts are equal, this uses unsigned version
|
||||
SDValue LoMinMax = DAG.getNode(LoOpc, DL, {NVT, NVT}, {LHSL, RHSL});
|
||||
|
||||
Lo = DAG.getSelect(DL, NVT, IsHiEq, LoMinMax, LoCmp);
|
||||
}
|
||||
|
||||
void DAGTypeLegalizer::ExpandIntRes_ADDSUB(SDNode *N,
|
||||
SDValue &Lo, SDValue &Hi) {
|
||||
SDLoc dl(N);
|
||||
|
@ -361,6 +361,8 @@ private:
|
||||
void ExpandIntRes_UREM (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
void ExpandIntRes_Shift (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
|
||||
void ExpandIntRes_MINMAX (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
|
||||
void ExpandIntRes_SADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
void ExpandIntRes_UADDSUBO (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
void ExpandIntRes_XMULO (SDNode *N, SDValue &Lo, SDValue &Hi);
|
||||
|
@ -1,19 +1,17 @@
|
||||
; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
||||
; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
||||
|
||||
declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
|
||||
; FUNC-LABEL: {{^}}v_test_imax_sge_i32:
|
||||
; SI: v_max_i32_e32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @v_test_imax_sge_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp sge i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -22,21 +20,25 @@ define void @v_test_imax_sge_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr
|
||||
; SI: v_max_i32_e32
|
||||
; SI: v_max_i32_e32
|
||||
; SI: v_max_i32_e32
|
||||
|
||||
; These could be merged into one
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
define void @v_test_imax_sge_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %aptr, <4 x i32> addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %out, i32 %tid
|
||||
%a = load <4 x i32>, <4 x i32> addrspace(1)* %gep0, align 4
|
||||
%b = load <4 x i32>, <4 x i32> addrspace(1)* %gep1, align 4
|
||||
%a = load <4 x i32>, <4 x i32> addrspace(1)* %aptr, align 4
|
||||
%b = load <4 x i32>, <4 x i32> addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp sge <4 x i32> %a, %b
|
||||
%val = select <4 x i1> %cmp, <4 x i32> %a, <4 x i32> %b
|
||||
store <4 x i32> %val, <4 x i32> addrspace(1)* %outgep, align 4
|
||||
store <4 x i32> %val, <4 x i32> addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @s_test_imax_sge_i32
|
||||
; SI: s_max_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @s_test_imax_sge_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp sge i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -46,6 +48,8 @@ define void @s_test_imax_sge_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imax_sge_imm_i32:
|
||||
; SI: s_max_i32 {{s[0-9]+}}, {{s[0-9]+}}, 9
|
||||
|
||||
; EG: MAX_INT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_imax_sge_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
%cmp = icmp sge i32 %a, 9
|
||||
%val = select i1 %cmp, i32 %a, i32 9
|
||||
@ -57,21 +61,21 @@ define void @s_test_imax_sge_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
; SI: buffer_load_sbyte
|
||||
; SI: buffer_load_sbyte
|
||||
; SI: v_max_i32_e32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @v_test_imax_sge_i8(i8 addrspace(1)* %out, i8 addrspace(1)* %aptr, i8 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i8, i8 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i8, i8 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i8, i8 addrspace(1)* %out, i32 %tid
|
||||
%a = load i8, i8 addrspace(1)* %gep0, align 1
|
||||
%b = load i8, i8 addrspace(1)* %gep1, align 1
|
||||
%a = load i8, i8 addrspace(1)* %aptr, align 1
|
||||
%b = load i8, i8 addrspace(1)* %bptr, align 1
|
||||
%cmp = icmp sge i8 %a, %b
|
||||
%val = select i1 %cmp, i8 %a, i8 %b
|
||||
store i8 %val, i8 addrspace(1)* %outgep, align 1
|
||||
store i8 %val, i8 addrspace(1)* %out, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imax_sgt_imm_i32:
|
||||
; SI: s_max_i32 {{s[0-9]+}}, {{s[0-9]+}}, 9
|
||||
|
||||
; EG: MAX_INT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_imax_sgt_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
%cmp = icmp sgt i32 %a, 9
|
||||
%val = select i1 %cmp, i32 %a, i32 9
|
||||
@ -82,29 +86,33 @@ define void @s_test_imax_sgt_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
; FUNC-LABEL: {{^}}s_test_imax_sgt_imm_v2i32:
|
||||
; SI: s_max_i32 {{s[0-9]+}}, {{s[0-9]+}}, 9
|
||||
; SI: s_max_i32 {{s[0-9]+}}, {{s[0-9]+}}, 9
|
||||
|
||||
; EG: MAX_INT {{.*}}literal.{{[xyzw]}}
|
||||
; EG: MAX_INT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_imax_sgt_imm_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a) nounwind {
|
||||
%cmp = icmp sgt <2 x i32> %a, <i32 9, i32 9>
|
||||
%val = select <2 x i1> %cmp, <2 x i32> %a, <2 x i32> <i32 9, i32 9>
|
||||
store <2 x i32> %val, <2 x i32> addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @v_test_imax_sgt_i32
|
||||
; SI: v_max_i32_e32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @v_test_imax_sgt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp sgt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @s_test_imax_sgt_i32
|
||||
; SI: s_max_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @s_test_imax_sgt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp sgt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -114,21 +122,21 @@ define void @s_test_imax_sgt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
|
||||
; FUNC-LABEL: @v_test_umax_uge_i32
|
||||
; SI: v_max_u32_e32
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @v_test_umax_uge_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp uge i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @s_test_umax_uge_i32
|
||||
; SI: s_max_u32
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @s_test_umax_uge_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp uge i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -142,6 +150,11 @@ define void @s_test_umax_uge_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
; SI: s_max_u32
|
||||
; SI-NOT: s_max_u32
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MAX_UINT
|
||||
; EG: MAX_UINT
|
||||
; EG: MAX_UINT
|
||||
; EG-NOT: MAX_UINT
|
||||
define void @s_test_umax_uge_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> %a, <3 x i32> %b) nounwind {
|
||||
%cmp = icmp uge <3 x i32> %a, %b
|
||||
%val = select <3 x i1> %cmp, <3 x i32> %a, <3 x i32> %b
|
||||
@ -153,36 +166,34 @@ define void @s_test_umax_uge_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> %a, <
|
||||
; SI: buffer_load_ubyte
|
||||
; SI: buffer_load_ubyte
|
||||
; SI: v_max_u32_e32
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @v_test_umax_uge_i8(i8 addrspace(1)* %out, i8 addrspace(1)* %aptr, i8 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i8, i8 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i8, i8 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i8, i8 addrspace(1)* %out, i32 %tid
|
||||
%a = load i8, i8 addrspace(1)* %gep0, align 1
|
||||
%b = load i8, i8 addrspace(1)* %gep1, align 1
|
||||
%a = load i8, i8 addrspace(1)* %aptr, align 1
|
||||
%b = load i8, i8 addrspace(1)* %bptr, align 1
|
||||
%cmp = icmp uge i8 %a, %b
|
||||
%val = select i1 %cmp, i8 %a, i8 %b
|
||||
store i8 %val, i8 addrspace(1)* %outgep, align 1
|
||||
store i8 %val, i8 addrspace(1)* %out, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @v_test_umax_ugt_i32
|
||||
; SI: v_max_u32_e32
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @v_test_umax_ugt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp ugt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_umax_ugt_i32:
|
||||
; SI: s_max_u32
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @s_test_umax_ugt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp ugt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -193,6 +204,9 @@ define void @s_test_umax_ugt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
; FUNC-LABEL: {{^}}s_test_umax_ugt_imm_v2i32:
|
||||
; SI-DAG: s_max_u32 {{s[0-9]+}}, {{s[0-9]+}}, 15
|
||||
; SI-DAG: s_max_u32 {{s[0-9]+}}, {{s[0-9]+}}, 23
|
||||
|
||||
; EG: MAX_UINT {{.*}}literal.{{[xyzw]}}
|
||||
; EG: MAX_UINT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_umax_ugt_imm_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a) nounwind {
|
||||
%cmp = icmp ugt <2 x i32> %a, <i32 15, i32 23>
|
||||
%val = select <2 x i1> %cmp, <2 x i32> %a, <2 x i32> <i32 15, i32 23>
|
||||
@ -207,6 +221,8 @@ define void @s_test_umax_ugt_imm_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %
|
||||
; SI: s_max_u32 [[MAX:s[0-9]+]], [[A]], [[B]]
|
||||
; SI: v_mov_b32_e32 [[VMAX:v[0-9]+]], [[MAX]]
|
||||
; SI: buffer_store_dword [[VMAX]]
|
||||
|
||||
; EG: MAX_UINT
|
||||
define void @simplify_demanded_bits_test_umax_ugt_i16(i32 addrspace(1)* %out, i16 zeroext %a, i16 zeroext %b) nounwind {
|
||||
%a.ext = zext i16 %a to i32
|
||||
%b.ext = zext i16 %b to i32
|
||||
@ -225,6 +241,8 @@ define void @simplify_demanded_bits_test_umax_ugt_i16(i32 addrspace(1)* %out, i1
|
||||
; SI: s_max_i32 [[MAX:s[0-9]+]], [[A]], [[B]]
|
||||
; SI: v_mov_b32_e32 [[VMAX:v[0-9]+]], [[MAX]]
|
||||
; SI: buffer_store_dword [[VMAX]]
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @simplify_demanded_bits_test_max_slt_i16(i32 addrspace(1)* %out, i16 signext %a, i16 signext %b) nounwind {
|
||||
%a.ext = sext i16 %a to i32
|
||||
%b.ext = sext i16 %b to i32
|
||||
@ -242,9 +260,60 @@ define void @simplify_demanded_bits_test_max_slt_i16(i32 addrspace(1)* %out, i16
|
||||
; SI: s_sext_i32_i16
|
||||
; SI: s_sext_i32_i16
|
||||
; SI: s_max_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @s_test_imax_sge_i16(i16 addrspace(1)* %out, i16 %a, i16 %b) nounwind {
|
||||
%cmp = icmp sge i16 %a, %b
|
||||
%val = select i1 %cmp, i16 %a, i16 %b
|
||||
store i16 %val, i16 addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
|
||||
; 64 bit
|
||||
; FUNC-LABEL: {{^}}test_umax_ugt_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MAX_UINT
|
||||
; EG: MAX_UINT
|
||||
define void @test_umax_ugt_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp ugt i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_umax_uge_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MAX_UINT
|
||||
; EG: MAX_UINT
|
||||
define void @test_umax_uge_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp uge i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_imax_sgt_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG-DAG: MAX_UINT
|
||||
; EG-DAG: MAX_INT
|
||||
define void @test_imax_sgt_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp sgt i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_imax_sge_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG-DAG: MAX_UINT
|
||||
; EG-DAG: MAX_INT
|
||||
define void @test_imax_sge_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp sge i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
||||
; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
||||
|
||||
declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
|
||||
; FUNC-LABEL: {{^}}v_test_imin_sle_i32:
|
||||
; SI: v_min_i32_e32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @v_test_imin_sle_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp sle i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imin_sle_i32:
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp sle i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -28,6 +29,8 @@ define void @s_test_imin_sle_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imin_sle_v1i32:
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_v1i32(<1 x i32> addrspace(1)* %out, <1 x i32> %a, <1 x i32> %b) nounwind {
|
||||
%cmp = icmp sle <1 x i32> %a, %b
|
||||
%val = select <1 x i1> %cmp, <1 x i32> %a, <1 x i32> %b
|
||||
@ -40,6 +43,11 @@ define void @s_test_imin_sle_v1i32(<1 x i32> addrspace(1)* %out, <1 x i32> %a, <
|
||||
; SI: s_min_i32
|
||||
; SI: s_min_i32
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %a, <4 x i32> %b) nounwind {
|
||||
%cmp = icmp sle <4 x i32> %a, %b
|
||||
%val = select <4 x i1> %cmp, <4 x i32> %a, <4 x i32> %b
|
||||
@ -79,6 +87,11 @@ define void @s_test_imin_sle_i8(i8 addrspace(1)* %out, i8 %a, i8 %b) nounwind {
|
||||
; SI: v_min_i32
|
||||
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_v4i8(<4 x i8> addrspace(1)* %out, <4 x i8> %a, <4 x i8> %b) nounwind {
|
||||
%cmp = icmp sle <4 x i8> %a, %b
|
||||
%val = select <4 x i1> %cmp, <4 x i8> %a, <4 x i8> %b
|
||||
@ -91,6 +104,11 @@ define void @s_test_imin_sle_v4i8(<4 x i8> addrspace(1)* %out, <4 x i8> %a, <4 x
|
||||
; SI: v_min_i32
|
||||
; SI: v_min_i32
|
||||
; SI: v_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_v4i16(<4 x i16> addrspace(1)* %out, <4 x i16> %a, <4 x i16> %b) nounwind {
|
||||
%cmp = icmp sle <4 x i16> %a, %b
|
||||
%val = select <4 x i1> %cmp, <4 x i16> %a, <4 x i16> %b
|
||||
@ -100,21 +118,21 @@ define void @s_test_imin_sle_v4i16(<4 x i16> addrspace(1)* %out, <4 x i16> %a, <
|
||||
|
||||
; FUNC-LABEL: @v_test_imin_slt_i32
|
||||
; SI: v_min_i32_e32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @v_test_imin_slt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp slt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @s_test_imin_slt_i32
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_slt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp slt i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -125,6 +143,9 @@ define void @s_test_imin_slt_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
; FUNC-LABEL: {{^}}s_test_imin_slt_v2i32:
|
||||
; SI: s_min_i32
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_slt_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <2 x i32> %b) nounwind {
|
||||
%cmp = icmp slt <2 x i32> %a, %b
|
||||
%val = select <2 x i1> %cmp, <2 x i32> %a, <2 x i32> %b
|
||||
@ -134,6 +155,8 @@ define void @s_test_imin_slt_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %a, <
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imin_slt_imm_i32:
|
||||
; SI: s_min_i32 {{s[0-9]+}}, {{s[0-9]+}}, 8
|
||||
|
||||
; EG: MIN_INT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_imin_slt_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
%cmp = icmp slt i32 %a, 8
|
||||
%val = select i1 %cmp, i32 %a, i32 8
|
||||
@ -143,6 +166,8 @@ define void @s_test_imin_slt_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imin_sle_imm_i32:
|
||||
; SI: s_min_i32 {{s[0-9]+}}, {{s[0-9]+}}, 8
|
||||
|
||||
; EG: MIN_INT {{.*}}literal.{{[xyzw]}}
|
||||
define void @s_test_imin_sle_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
%cmp = icmp sle i32 %a, 8
|
||||
%val = select i1 %cmp, i32 %a, i32 8
|
||||
@ -152,16 +177,14 @@ define void @s_test_imin_sle_imm_i32(i32 addrspace(1)* %out, i32 %a) nounwind {
|
||||
|
||||
; FUNC-LABEL: @v_test_umin_ule_i32
|
||||
; SI: v_min_u32_e32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @v_test_umin_ule_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, align 4
|
||||
%cmp = icmp ule i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -171,20 +194,22 @@ define void @v_test_umin_ule_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr
|
||||
; SI: v_min_u32_e32
|
||||
; SI-NOT: v_min_u32_e32
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
define void @v_test_umin_ule_v3i32(<3 x i32> addrspace(1)* %out, <3 x i32> addrspace(1)* %aptr, <3 x i32> addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr <3 x i32>, <3 x i32> addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr <3 x i32>, <3 x i32> addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr <3 x i32>, <3 x i32> addrspace(1)* %out, i32 %tid
|
||||
%a = load <3 x i32>, <3 x i32> addrspace(1)* %gep0
|
||||
%b = load <3 x i32>, <3 x i32> addrspace(1)* %gep1
|
||||
%a = load <3 x i32>, <3 x i32> addrspace(1)* %aptr
|
||||
%b = load <3 x i32>, <3 x i32> addrspace(1)* %bptr
|
||||
%cmp = icmp ule <3 x i32> %a, %b
|
||||
%val = select <3 x i1> %cmp, <3 x i32> %a, <3 x i32> %b
|
||||
store <3 x i32> %val, <3 x i32> addrspace(1)* %outgep
|
||||
store <3 x i32> %val, <3 x i32> addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
; FUNC-LABEL: @s_test_umin_ule_i32
|
||||
; SI: s_min_u32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @s_test_umin_ule_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp ule i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -194,16 +219,14 @@ define void @s_test_umin_ule_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
|
||||
; FUNC-LABEL: @v_test_umin_ult_i32
|
||||
; SI: v_min_u32_e32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @v_test_umin_ult_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%cmp = icmp ult i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
store i32 %val, i32 addrspace(1)* %outgep, align 4
|
||||
store i32 %val, i32 addrspace(1)* %out, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -211,21 +234,21 @@ define void @v_test_umin_ult_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr
|
||||
; SI: buffer_load_ubyte
|
||||
; SI: buffer_load_ubyte
|
||||
; SI: v_min_u32_e32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @v_test_umin_ult_i8(i8 addrspace(1)* %out, i8 addrspace(1)* %aptr, i8 addrspace(1)* %bptr) nounwind {
|
||||
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i8, i8 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i8, i8 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep = getelementptr i8, i8 addrspace(1)* %out, i32 %tid
|
||||
%a = load i8, i8 addrspace(1)* %gep0, align 1
|
||||
%b = load i8, i8 addrspace(1)* %gep1, align 1
|
||||
%a = load i8, i8 addrspace(1)* %aptr, align 1
|
||||
%b = load i8, i8 addrspace(1)* %bptr, align 1
|
||||
%cmp = icmp ult i8 %a, %b
|
||||
%val = select i1 %cmp, i8 %a, i8 %b
|
||||
store i8 %val, i8 addrspace(1)* %outgep, align 1
|
||||
store i8 %val, i8 addrspace(1)* %out, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: @s_test_umin_ult_i32
|
||||
; SI: s_min_u32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @s_test_umin_ult_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwind {
|
||||
%cmp = icmp ult i32 %a, %b
|
||||
%val = select i1 %cmp, i32 %a, i32 %b
|
||||
@ -239,24 +262,23 @@ define void @s_test_umin_ult_i32(i32 addrspace(1)* %out, i32 %a, i32 %b) nounwin
|
||||
; SI-NEXT: v_cndmask_b32
|
||||
; SI-NOT: v_min
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG-NOT: MIN_UINT
|
||||
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.amdgcn.workitem.id.x() nounwind readnone
|
||||
%gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
|
||||
%gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
|
||||
%outgep0 = getelementptr i32, i32 addrspace(1)* %out0, i32 %tid
|
||||
%outgep1 = getelementptr i1, i1 addrspace(1)* %out1, i32 %tid
|
||||
%a = load i32, i32 addrspace(1)* %gep0, align 4
|
||||
%b = load i32, i32 addrspace(1)* %gep1, align 4
|
||||
%a = load i32, i32 addrspace(1)* %aptr, align 4
|
||||
%b = load i32, i32 addrspace(1)* %bptr, 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
|
||||
store i32 %val, i32 addrspace(1)* %out0, align 4
|
||||
store i1 %cmp, i1 addrspace(1)* %out1
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; FUNC-LABEL: @s_test_umin_ult_v1i32
|
||||
; SI: s_min_u32
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @s_test_umin_ult_v1i32(<1 x i32> addrspace(1)* %out, <1 x i32> %a, <1 x i32> %b) nounwind {
|
||||
%cmp = icmp ult <1 x i32> %a, %b
|
||||
%val = select <1 x i1> %cmp, <1 x i32> %a, <1 x i32> %b
|
||||
@ -273,6 +295,15 @@ define void @s_test_umin_ult_v1i32(<1 x i32> addrspace(1)* %out, <1 x i32> %a, <
|
||||
; SI: s_min_u32
|
||||
; SI: s_min_u32
|
||||
; SI: s_min_u32
|
||||
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
define void @s_test_umin_ult_v8i32(<8 x i32> addrspace(1)* %out, <8 x i32> %a, <8 x i32> %b) nounwind {
|
||||
%cmp = icmp ult <8 x i32> %a, %b
|
||||
%val = select <8 x i1> %cmp, <8 x i32> %a, <8 x i32> %b
|
||||
@ -289,6 +320,15 @@ define void @s_test_umin_ult_v8i32(<8 x i32> addrspace(1)* %out, <8 x i32> %a, <
|
||||
; SI: v_min_u32
|
||||
; SI: v_min_u32
|
||||
; SI: v_min_u32
|
||||
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
define void @s_test_umin_ult_v8i16(<8 x i16> addrspace(1)* %out, <8 x i16> %a, <8 x i16> %b) nounwind {
|
||||
%cmp = icmp ult <8 x i16> %a, %b
|
||||
%val = select <8 x i1> %cmp, <8 x i16> %a, <8 x i16> %b
|
||||
@ -303,6 +343,8 @@ define void @s_test_umin_ult_v8i16(<8 x i16> addrspace(1)* %out, <8 x i16> %a, <
|
||||
; SI: s_min_u32 [[MIN:s[0-9]+]], [[A]], [[B]]
|
||||
; SI: v_mov_b32_e32 [[VMIN:v[0-9]+]], [[MIN]]
|
||||
; SI: buffer_store_dword [[VMIN]]
|
||||
|
||||
; EG: MIN_UINT
|
||||
define void @simplify_demanded_bits_test_umin_ult_i16(i32 addrspace(1)* %out, i16 zeroext %a, i16 zeroext %b) nounwind {
|
||||
%a.ext = zext i16 %a to i32
|
||||
%b.ext = zext i16 %b to i32
|
||||
@ -321,6 +363,8 @@ define void @simplify_demanded_bits_test_umin_ult_i16(i32 addrspace(1)* %out, i1
|
||||
; SI: s_min_i32 [[MIN:s[0-9]+]], [[A]], [[B]]
|
||||
; SI: v_mov_b32_e32 [[VMIN:v[0-9]+]], [[MIN]]
|
||||
; SI: buffer_store_dword [[VMIN]]
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @simplify_demanded_bits_test_min_slt_i16(i32 addrspace(1)* %out, i16 signext %a, i16 signext %b) nounwind {
|
||||
%a.ext = sext i16 %a to i32
|
||||
%b.ext = sext i16 %b to i32
|
||||
@ -334,9 +378,60 @@ define void @simplify_demanded_bits_test_min_slt_i16(i32 addrspace(1)* %out, i16
|
||||
|
||||
; FUNC-LABEL: {{^}}s_test_imin_sle_i16:
|
||||
; SI: s_min_i32
|
||||
|
||||
; EG: MIN_INT
|
||||
define void @s_test_imin_sle_i16(i16 addrspace(1)* %out, i16 %a, i16 %b) nounwind {
|
||||
%cmp = icmp sle i16 %a, %b
|
||||
%val = select i1 %cmp, i16 %a, i16 %b
|
||||
store i16 %val, i16 addrspace(1)* %out
|
||||
ret void
|
||||
}
|
||||
|
||||
; 64 bit
|
||||
; FUNC-LABEL: {{^}}test_umin_ult_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
define void @test_umin_ult_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp ult i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_umin_ule_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG: MIN_UINT
|
||||
; EG: MIN_UINT
|
||||
define void @test_umin_ule_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp ule i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_imin_slt_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG-DAG: MIN_UINT
|
||||
; EG-DAG: MIN_INT
|
||||
define void @test_imin_slt_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp slt i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; FUNC-LABEL: {{^}}test_imin_sle_i64
|
||||
; SI: s_endpgm
|
||||
|
||||
; EG-DAG: MIN_UINT
|
||||
; EG-DAG: MIN_INT
|
||||
define void @test_imin_sle_i64(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
|
||||
%tmp = icmp sle i64 %a, %b
|
||||
%val = select i1 %tmp, i64 %a, i64 %b
|
||||
store i64 %val, i64 addrspace(1)* %out, align 8
|
||||
ret void
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
|
||||
; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=FUNC %s
|
||||
; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
||||
|
||||
; FUNC-LABEL: {{^}}s_abs_i32:
|
||||
; GCN: s_abs_i32
|
||||
; GCN: s_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @s_abs_i32(i32 addrspace(1)* %out, i32 %val) nounwind {
|
||||
%neg = sub i32 0, %val
|
||||
%cond = icmp sgt i32 %val, %neg
|
||||
@ -17,6 +20,8 @@ define void @s_abs_i32(i32 addrspace(1)* %out, i32 %val) nounwind {
|
||||
; GCN: v_sub_i32_e32 [[NEG:v[0-9]+]], vcc, 0, [[SRC:v[0-9]+]]
|
||||
; GCN: v_max_i32_e32 {{v[0-9]+}}, [[NEG]], [[SRC]]
|
||||
; GCN: v_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
define void @v_abs_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %src) nounwind {
|
||||
%val = load i32, i32 addrspace(1)* %src, align 4
|
||||
%neg = sub i32 0, %val
|
||||
@ -32,6 +37,9 @@ define void @v_abs_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %src) nounwind
|
||||
; GCN: s_abs_i32
|
||||
; GCN: s_add_i32
|
||||
; GCN: s_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
define void @s_abs_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %val) nounwind {
|
||||
%z0 = insertelement <2 x i32> undef, i32 0, i32 0
|
||||
%z1 = insertelement <2 x i32> %z0, i32 0, i32 1
|
||||
@ -54,6 +62,9 @@ define void @s_abs_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> %val) nounwind
|
||||
|
||||
; GCN: v_add_i32
|
||||
; GCN: v_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
define void @v_abs_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %src) nounwind {
|
||||
%z0 = insertelement <2 x i32> undef, i32 0, i32 0
|
||||
%z1 = insertelement <2 x i32> %z0, i32 0, i32 1
|
||||
@ -79,6 +90,11 @@ define void @v_abs_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %
|
||||
; GCN: s_add_i32
|
||||
; GCN: s_add_i32
|
||||
; GCN: s_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
define void @s_abs_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %val) nounwind {
|
||||
%z0 = insertelement <4 x i32> undef, i32 0, i32 0
|
||||
%z1 = insertelement <4 x i32> %z0, i32 0, i32 1
|
||||
@ -111,6 +127,11 @@ define void @s_abs_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> %val) nounwind
|
||||
; GCN: v_add_i32
|
||||
; GCN: v_add_i32
|
||||
; GCN: v_add_i32
|
||||
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
; EG: MAX_INT
|
||||
define void @v_abs_v4i32(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %src) nounwind {
|
||||
%z0 = insertelement <4 x i32> undef, i32 0, i32 0
|
||||
%z1 = insertelement <4 x i32> %z0, i32 0, i32 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user