[llvm] [AMDGPU] Adjust amdgpu fmax/fmin legalization for DAG (PR #203150)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 05:03:34 PDT 2026
================
@@ -539,15 +539,35 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
setOperationAction({ISD::SADDSAT, ISD::SSUBSAT}, {MVT::i16, MVT::i32},
Legal);
- setOperationAction(
- {ISD::FMINNUM, ISD::FMAXNUM, ISD::FMINIMUMNUM, ISD::FMAXIMUMNUM},
- {MVT::f32, MVT::f64}, Custom);
-
- // These are really only legal for ieee_mode functions. We should be avoiding
- // them for functions that don't have ieee_mode enabled, so just say they are
- // legal.
- setOperationAction({ISD::FMINNUM_IEEE, ISD::FMAXNUM_IEEE},
- {MVT::f32, MVT::f64}, Legal);
+ // Do not have s_{min|max}_*f64 instruction f64 will only be lowered to
+ // v_{min|max}_*f64
+ if (Subtarget->hasIEEEMinimumMaximumInsts()) {
+ setOperationAction(
+ {ISD::FMINNUM, ISD::FMAXNUM, ISD::FMINIMUMNUM, ISD::FMAXIMUMNUM},
+ MVT::f64, Legal);
+ } else {
+ setOperationAction(
+ {ISD::FMINNUM, ISD::FMAXNUM, ISD::FMINIMUMNUM, ISD::FMAXIMUMNUM},
+ MVT::f64, Custom);
+ // These are really only legal for ieee_mode functions. We should be
+ // avoiding them for functions that don't have ieee_mode enabled, so just
+ // say they are legal.
+ setOperationAction({ISD::FMINNUM_IEEE, ISD::FMAXNUM_IEEE}, MVT::f64, Legal);
+ }
+
+ // If has v_{min|max}_num_f32 but no s_{min|max}_num_f32, leave it for custom
+ // function
----------------
arsenm wrote:
The scalar form shouldn't matter here? Both were introduced at the same time in gfx12 too. I'd just remove the hasSALU* check
https://github.com/llvm/llvm-project/pull/203150
More information about the llvm-commits
mailing list