[llvm] [TTI] Check type legalization of both src and result for fpto{u|s}i.sat. (PR #147657)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 00:01:01 PDT 2025


================
@@ -2486,11 +2486,18 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
       ISD = ISD::UMULO;
       break;
     case Intrinsic::fptosi_sat:
-      ISD = ISD::FP_TO_SINT_SAT;
-      break;
-    case Intrinsic::fptoui_sat:
-      ISD = ISD::FP_TO_UINT_SAT;
+    case Intrinsic::fptoui_sat: {
+      std::pair<InstructionCost, MVT> SrcLT = getTypeLegalizationCost(Tys[0]);
+      std::pair<InstructionCost, MVT> RetLT = getTypeLegalizationCost(RetTy);
+
+      // For cast instructions, types are different between source and
+      // destination. Also need to check if the source type can be legalize.
----------------
arsenm wrote:

I don't understand this, any type should be legalizable. Why would this ever return an invalid cost? 

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


More information about the llvm-commits mailing list