[llvm] [AMDGPU][SDAG] Try folding "lshr i64 + mad" to "mad_[iu]64_[iu]32" (PR #119218)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 18:28:13 PST 2024


================
@@ -13857,6 +13857,39 @@ static SDValue getMad64_32(SelectionDAG &DAG, const SDLoc &SL, EVT VT,
   return DAG.getNode(ISD::TRUNCATE, SL, VT, Mad);
 }
 
+// Fold
+//     y = lshr i64 x, 32
+//     res = add (mul i64 y, Const), x   where "Const" is a 64-bit constant
+//     with Const.hi == -1
+// To
+//     res = mad_u64_u32 y.lo ,Const.lo, x.lo
+static SDValue tryFoldMADwithSRL(SelectionDAG &DAG, const SDLoc &SL,
----------------
arsenm wrote:

Can you also implement the same in globalisel? Not sure if the original combine is there, or if that needs porting as well 

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


More information about the llvm-commits mailing list