[llvm] [AMDGPU] Do not treat bitcast across FP types as canonicality-preserving (PR #203560)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 08:40:48 PDT 2026


================
@@ -15795,11 +15795,15 @@ bool SITargetLowering::isCanonicalized(SelectionDAG &DAG, SDValue Op,
     // Could be anything.
     return false;
 
-  case ISD::BITCAST:
-    // TODO: This is incorrect as it loses track of the operand's type. We may
-    // end up effectively bitcasting from f32 to v2f16 or vice versa, and the
-    // same bits that are canonicalized in one type need not be in the other.
+  case ISD::BITCAST: {
+    // Canonicality isn't preserved across a bitcast that changes the FP type.
+    EVT SrcVT = Op.getOperand(0).getValueType();
+    EVT DstVT = Op.getValueType();
+    if (SrcVT.isFloatingPoint() && DstVT.isFloatingPoint() &&
+        SrcVT.getScalarType() != DstVT.getScalarType())
+      return false;
----------------
arsenm wrote:

I think we'd need to track the evaluated type through recursion. This logic will still break if we have pairs of bitcasts in the chain 

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


More information about the llvm-commits mailing list