[llvm] [SDag][ARM][RISCV] Allow lowering CTPOP into a libcall (PR #99752)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 10:37:27 PDT 2024
================
@@ -3847,15 +3847,36 @@ void DAGTypeLegalizer::ExpandIntRes_CTLZ(SDNode *N,
Hi = DAG.getConstant(0, dl, NVT);
}
-void DAGTypeLegalizer::ExpandIntRes_CTPOP(SDNode *N,
- SDValue &Lo, SDValue &Hi) {
- SDLoc dl(N);
+void DAGTypeLegalizer::ExpandIntRes_CTPOP(SDNode *N, SDValue &Lo, SDValue &Hi) {
+ SDValue Op = N->getOperand(0);
+ EVT VT = N->getValueType(0);
+ SDLoc DL(N);
+
+ // If the narrow CTPOP is not supported by the target, try to convert it
+ // to a libcall.
+ EVT ExpandedVT = TLI.getTypeToExpandTo(*DAG.getContext(), VT);
+ if (!TLI.isOperationLegalOrCustom(ISD::CTPOP, ExpandedVT)) {
----------------
arsenm wrote:
Yes. This is a stalled migration. Ideally the Expand action would never produce a libcall.
https://github.com/llvm/llvm-project/pull/99752
More information about the llvm-commits
mailing list