[PATCH] D151055: [PowerPC] Use ABDU node when operands are known to be zero extended
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 20:52:45 PDT 2023
lkail created this revision.
Herald added subscribers: shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: All.
lkail requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For pwr9 cpu, we can save `xvnegsp` instruction. Alive2 proof https://alive2.llvm.org/ce/z/LWaEEg.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151055
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h
Index: llvm/lib/Target/PowerPC/PPCISelLowering.h
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.h
+++ llvm/lib/Target/PowerPC/PPCISelLowering.h
@@ -1421,6 +1421,7 @@
SelectionDAG &DAG) const;
SDValue combineVReverseMemOP(ShuffleVectorSDNode *SVN, LSBaseSDNode *LSBase,
DAGCombinerInfo &DCI) const;
+ SDValue combineABDS(SDNode *N, DAGCombinerInfo &DCI) const;
/// ConvertSETCCToSubtract - looks at SETCC that compares ints. It replaces
/// SETCC with integer subtraction when (1) there is a legal way of doing it
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1397,6 +1397,9 @@
setTargetDAGCombine({ISD::TRUNCATE, ISD::SETCC, ISD::SELECT_CC});
}
+ if (Subtarget.hasP9Altivec())
+ setTargetDAGCombine({ISD::ABDS});
+
setLibcallName(RTLIB::LOG_F128, "logf128");
setLibcallName(RTLIB::LOG2_F128, "log2f128");
setLibcallName(RTLIB::LOG10_F128, "log10f128");
@@ -16231,6 +16234,8 @@
}
case ISD::BUILD_VECTOR:
return DAGCombineBuildVector(N, DCI);
+ case ISD::ABDS:
+ return combineABDS(N, DCI);
}
return SDValue();
@@ -18524,3 +18529,20 @@
return Builder.CreateOr(
Lo, Builder.CreateShl(Hi, ConstantInt::get(ValTy, 64)), "val64");
}
+
+SDValue PPCTargetLowering::combineABDS(SDNode *N, DAGCombinerInfo &DCI) const {
+ assert((N->getOpcode() == ISD::ABDS) && "Need ABDS node here");
+ assert(Subtarget.hasP9Altivec() &&
+ "Only combine this when P9 altivec supported!");
+ EVT VT = N->getValueType(0);
+ if (VT != MVT::v4i32 && VT != MVT::v8i16 && VT != MVT::v16i8)
+ return SDValue();
+ // If we know sign bits of elements to be zeros, we can convert ABDS to
+ // ABDU.
+ SDValue Op0 = N->getOperand(0);
+ SDValue Op1 = N->getOperand(1);
+ if (!DCI.DAG.SignBitIsZero(Op0) || !DCI.DAG.SignBitIsZero(Op1))
+ return SDValue();
+ SDLoc DL(N);
+ return DCI.DAG.getNode(ISD::ABDU, DL, VT, Op0, Op1);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151055.524152.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/1e8d2e16/attachment-0001.bin>
More information about the llvm-commits
mailing list