[clang] Don't do casting of atomic FP loads/stores in FE. (PR #83446)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 1 02:33:15 PST 2024


================
@@ -1410,13 +1414,14 @@ RValue AtomicInfo::ConvertIntToValueOrAtomic(llvm::Value *IntVal,
     auto *ValTy = AsValue
                       ? CGF.ConvertTypeForMem(ValueTy)
                       : getAtomicAddress().getElementType();
-    if (ValTy->isIntegerTy()) {
-      assert(IntVal->getType() == ValTy && "Different integer types.");
-      return RValue::get(CGF.EmitFromMemory(IntVal, ValueTy));
+    if (ValTy->isIntegerTy() || (!CastFP && ValTy->isIEEELikeFPTy())) {
+      assert((!ValTy->isIntegerTy() || Val->getType() == ValTy) &&
+             "Different integer types.");
+      return RValue::get(CGF.EmitFromMemory(Val, ValueTy));
     } else if (ValTy->isPointerTy())
-      return RValue::get(CGF.Builder.CreateIntToPtr(IntVal, ValTy));
-    else if (llvm::CastInst::isBitCastable(IntVal->getType(), ValTy))
-      return RValue::get(CGF.Builder.CreateBitCast(IntVal, ValTy));
+      return RValue::get(CGF.Builder.CreateIntToPtr(Val, ValTy));
+    else if (llvm::CastInst::isBitCastable(Val->getType(), ValTy))
+      return RValue::get(CGF.Builder.CreateBitCast(Val, ValTy));
----------------
arsenm wrote:

https://github.com/llvm/llvm-project/blob/d1538c15f9c65a70f4650bd724972536f00f5094/llvm/lib/CodeGen/AtomicExpandPass.cpp#L256

It's wild how much junk clang ended up with to avoid writing proper backend support. It's fine to just do the FP in this patch, but I think all of this needs to be ripped out 

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


More information about the cfe-commits mailing list