[llvm] [AMDGPU] Fold isnan+fptosi select to fptosi (PR #200960)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 04:23:03 PDT 2026


================
@@ -18412,6 +18412,41 @@ SDValue SITargetLowering::performSelectCombine(SDNode *N,
   SDValue RHS = Cond.getOperand(1);
   ISD::CondCode CC = cast<CondCodeSDNode>(Cond.getOperand(2))->get();
 
+  // Fold: select (setcc X, NonNaN, SETUO), 0, (fp_to_sint X) -> fp_to_sint X
+  // Fold: select (setcc X, NonNaN, SETO), (fp_to_sint X), 0 -> fp_to_sint X
+  // Also look through an AND mask on the fp_to_sint result.
+  // V_CVT_I32_F32, V_CVT_U32_F32, V_CVT_I32_F64, V_CVT_U32_F64 already
+  // return 0 for NaN inputs, so the isnan guard is redundant.
----------------
arsenm wrote:

Might be able to turn this into whatever the ISD node name of llvm.fptosi.sat is 

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


More information about the llvm-commits mailing list