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

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 29 16:46:50 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:

I'm slightly abusing the lack of `freeze` optimisations to use `freeze` as a general optimisation barrier. If we have a general `(freeze op) -> op` optimisation for when `op` is known to not be undef or poison, we would end up optimising `(fp_extend (freeze (fp_round x 1)))` to `(fp_extend (fp_round x 1))` to `x`, bypassing the barrier I tried to insert. If we do that, I need to update this PR to add some new `barrier` node and do exactly with that what I am currently doing with `freeze`, so I do not think that gets us anywhere.

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


More information about the llvm-commits mailing list