[PATCH] D143941: AMDGPU: Teach getNegatedExpression about rcp
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 12:32:13 PST 2023
arsenm created this revision.
arsenm added reviewers: AMDGPU, foad, rampitec, Pierre-vh, sebastian-ne.
Herald added subscribers: kosarev, StephenFan, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
https://reviews.llvm.org/D143941
Files:
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/test/CodeGen/AMDGPU/fneg-combines.new.ll
Index: llvm/test/CodeGen/AMDGPU/fneg-combines.new.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/fneg-combines.new.ll
+++ llvm/test/CodeGen/AMDGPU/fneg-combines.new.ll
@@ -2030,9 +2030,9 @@
; GCN-LABEL: v_negated_rcp_f32:
; GCN: ; %bb.0:
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
-; GCN-NEXT: v_fma_f32 v0, -v0, v1, -2.0
+; GCN-NEXT: v_fma_f32 v0, v0, v1, 2.0
; GCN-NEXT: v_rcp_f32_e32 v0, v0
-; GCN-NEXT: v_sub_f32_e32 v0, v1, v0
+; GCN-NEXT: v_add_f32_e32 v0, v1, v0
; GCN-NEXT: s_setpc_b64 s[30:31]
%neg.arg0 = fneg float %arg0
%fma = call nsz float @llvm.fma.f32(float %neg.arg0, float %arg1, float -2.0)
Index: llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
@@ -800,6 +800,17 @@
return SDValue();
break;
}
+ case AMDGPUISD::RCP: {
+ SDValue Src = Op.getOperand(0);
+ EVT VT = Op.getValueType();
+ SDLoc SL(Op);
+
+ SDValue NegSrc = getNegatedExpression(Src, DAG, LegalOperations,
+ ForCodeSize, Cost, Depth);
+ if (NegSrc)
+ return DAG.getNode(AMDGPUISD::RCP, SL, VT, NegSrc, Op->getFlags());
+ return SDValue();
+ }
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143941.497074.patch
Type: text/x-patch
Size: 1400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230213/fe0c111d/attachment.bin>
More information about the llvm-commits
mailing list