[llvm] [DAG] expandAVG - attempt to extend to a wider integer type for the add/shift to avoid overflow handling (PR #95788)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 07:54:12 PDT 2024
================
@@ -9262,12 +9265,28 @@ SDValue TargetLowering::expandAVG(SDNode *N, SelectionDAG &DAG) const {
DAG.getShiftAmountConstant(1, VT, dl));
}
+ // For scalars, see if we can efficiently extend/truncate to use add+shift.
+ if (VT.isScalarInteger()) {
+ unsigned BW = VT.getScalarSizeInBits();
+ EVT ExtVT = VT.getIntegerVT(*DAG.getContext(), 2 * BW);
+ if (isTypeLegal(ExtVT) &&
+ ((!IsSigned && isZExtFree(VT, ExtVT)) || isTruncateFree(ExtVT, VT))) {
----------------
RKSimon wrote:
TBH the isZExtFree is useless as well as isTruncateFree works fine for the x86 cases
https://github.com/llvm/llvm-project/pull/95788
More information about the llvm-commits
mailing list