[PATCH] D58481: [AMDGPU] fix commuted case of sub combine
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 16:14:36 PST 2019
rampitec created this revision.
rampitec added a reviewer: arsenm.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
rampitec retitled this revision from "PATCH] AMDGPU: fix commuted case of sub combine" to "[AMDGPU] fix commuted case of sub combine".
https://reviews.llvm.org/D58481
Files:
lib/Target/AMDGPU/SIISelLowering.cpp
test/CodeGen/AMDGPU/combine-cond-add-sub.ll
Index: test/CodeGen/AMDGPU/combine-cond-add-sub.ll
===================================================================
--- test/CodeGen/AMDGPU/combine-cond-add-sub.ll
+++ test/CodeGen/AMDGPU/combine-cond-add-sub.ll
@@ -127,6 +127,28 @@
ret void
}
+; GCN-LABEL: {{^}}sub_sube2:
+; GCN-DAG: v_cmp_gt_u32_e{{32|64}} [[CC:[^,]+]], v{{[0-9]+}}, v{{[0-9]+}}
+; GCN-DAG: _load_dword [[V:v[0-9]+]],
+; GCN: {{v_subb_co_u32|v_subb_u32}}_e{{32|64}} [[SUB:v[0-9]+]], {{[^,]+}}, v{{[0-9]+}}, [[V]], [[CC]]
+; GCN: v_add_{{[ui]}}32_e32 {{.*}}, 0x64, [[SUB]]
+; GCN-NOT: v_cndmask
+; GCN-NOT: v_sub
+define amdgpu_kernel void @sub_sube2(i32 addrspace(1)* nocapture %arg, i32 %a) {
+bb:
+ %x = tail call i32 @llvm.amdgcn.workitem.id.x()
+ %y = tail call i32 @llvm.amdgcn.workitem.id.y()
+ %gep = getelementptr inbounds i32, i32 addrspace(1)* %arg, i32 %x
+ %v = load i32, i32 addrspace(1)* %gep, align 4
+ %cmp = icmp ugt i32 %x, %y
+ %ext = sext i1 %cmp to i32
+ %adde = add i32 %v, %ext
+ %sub = sub i32 %adde, %a
+ %sub2 = sub i32 100, %sub
+ store i32 %sub2, i32 addrspace(1)* %gep, align 4
+ ret void
+}
+
; GCN-LABEL: {{^}}sube_sub:
; GCN: v_cmp_gt_u32_e{{32|64}} [[CC:[^,]+]], v{{[0-9]+}}, v{{[0-9]+}}
; GCN: v_subb_u32_e{{32|64}} v{{[0-9]+}}, {{[^,]+}}, v{{[0-9]+}}, v{{[0-9]+}}, [[CC]]
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -8617,7 +8617,8 @@
SDValue RHS = N->getOperand(1);
unsigned Opc = LHS.getOpcode();
- if (Opc != ISD::SUBCARRY)
+ bool NeedCommute = Opc != ISD::SUBCARRY;
+ if (NeedCommute)
std::swap(RHS, LHS);
if (LHS.getOpcode() == ISD::SUBCARRY) {
@@ -8626,6 +8627,8 @@
if (!C || C->getZExtValue() != 0)
return SDValue();
SDValue Args[] = { LHS.getOperand(0), RHS, LHS.getOperand(2) };
+ if (NeedCommute)
+ std::swap(Args[0], Args[1]);
return DAG.getNode(ISD::SUBCARRY, SDLoc(N), LHS->getVTList(), Args);
}
return SDValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58481.187692.patch
Type: text/x-patch
Size: 2073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190221/49cc0f6b/attachment-0001.bin>
More information about the llvm-commits
mailing list