[llvm] AMDGPU: Make v2f64 -> v2f16 conversion Legal only when unsafe fast math is set (PR #134738)

Changpeng Fang via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 10:05:13 PDT 2025


changpeng wrote:

> > Or do you prefer a combination of fast math flag and global option, like this? const SDNodeFlags Flags = Op->getFlags(); bool AllowInaccurateFP_ROUND = Flags.hasApproximateFuncs() || DAG.getTarget().Options.UnsafeFPMath;
> 
> You can do that, but it still needs to be a contextual use transformation, not modify the legality rules

I do not fully understand what did you mean "modify the legality rules", and why we should not modify.

Here is the example in custom lowering for FP_TO_FP16: 

  if (getTargetMachine().Options.UnsafeFPMath) {
    // There is a generic expand for FP_TO_FP16 with unsafe fast math.
    return **SDValue();**
  }

Do you mean this is to change from Custom to Expand, and is not allowed?   Thanks.

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


More information about the llvm-commits mailing list