[llvm] [AMDGPU] Fix canonicalization of truncated values. (PR #83054)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 02:22:26 PST 2024


================
@@ -26258,6 +26258,24 @@ SDValue DAGCombiner::visitFP_TO_FP16(SDNode *N) {
   if (N0->getOpcode() == ISD::FP16_TO_FP)
     return N0->getOperand(0);
 
+  // fold (fp_to_fp16 (freeze (fp16_to_fp (fp_to_fp16 op))))
----------------
jayfoad wrote:

> > That does not sound safe to me.
> 
> Understandable.

That was a bit of a drive-by comment (sorry) since I am not deeply involved in this code. I'm not sure I understand the underlying problem. Why is it OK to optimize away a rounding, if we are relying on it also canonicalizing? Is this because we're running in a mode where general fp operations are not required to canonicalize, but we do want to preserve explicit canonicalization ops?

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


More information about the llvm-commits mailing list