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

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 14:22:00 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))))
----------------
hvdijk wrote:

> That does not sound safe to me.

Understandable. It's still safer than the status quo where we miscompile code and have tests to ensure that we miscompile code, but if we can do better that would be great.

The two options I see are adding that dummy node type and then treating that exactly as I am currently treating `FREEZE`, or just saying that `FP_ROUND` and `FP_EXTEND` do not canonicalise and ignoring any performance degradations due to redundant recanonicalisations. Would either of those approaches be acceptable? Or is there some other option that I am just not seeing?

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


More information about the llvm-commits mailing list