[llvm] [DAG] expandAVG - attempt to extend to a wider integer type for the add/shift to avoid overflow handling (PR #95788)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 04:16:54 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.
+  // We can always use SRL as we will be truncating away the extended sign bits.
----------------
goldsteinn wrote:

Nit: Think this line of the comment belongs where the SRL node is created.

https://github.com/llvm/llvm-project/pull/95788


More information about the llvm-commits mailing list