[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 4 09:06:52 PDT 2024


================
@@ -1431,9 +1431,13 @@ Value *ScalarExprEmitter::EmitScalarCast(Value *Src, QualType SrcType,
     return Builder.CreateFPToUI(Src, DstTy, "conv");
   }
 
-  if (DstElementTy->getTypeID() < SrcElementTy->getTypeID())
+  if ((DstElementTy->is16bitFPTy() && SrcElementTy->is16bitFPTy())) {
+    Value *FloatVal = Builder.CreateFPExt(Src, Builder.getFloatTy(), "conv");
+    return Builder.CreateFPTrunc(FloatVal, DstTy, "conv");
+  } else if (DstElementTy->getTypeID() < SrcElementTy->getTypeID())
----------------
arsenm wrote:

Still needs to be resolved. Also should probably get a comment 

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


More information about the cfe-commits mailing list