[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
Mon Mar 11 21:56:46 PDT 2024
================
@@ -1953,13 +1966,22 @@ void CodeGenFunction::EmitAtomicStore(RValue rvalue, LValue dest,
}
// Okay, we're doing this natively.
- llvm::Value *intValue = atomics.convertRValueToInt(rvalue);
+ llvm::Value *ValToStore =
+ atomics.convertRValueToInt(rvalue, /*CastFP=*/false);
// Do the atomic store.
- Address addr = atomics.castToAtomicIntPointer(atomics.getAtomicAddress());
- intValue = Builder.CreateIntCast(
- intValue, addr.getElementType(), /*isSigned=*/false);
- llvm::StoreInst *store = Builder.CreateStore(intValue, addr);
+ Address Addr = atomics.getAtomicAddress();
+ bool ShouldCastToInt = true;
+ if (llvm::Value *Value = atomics.getScalarRValValueOrNull(rvalue))
+ if (isa<llvm::IntegerType>(Value->getType()) ||
+ Value->getType()->isIEEELikeFPTy())
+ ShouldCastToInt = false;
+ if (ShouldCastToInt) {
----------------
arsenm wrote:
Factoring this into a shouldCastToInt helper function would be better, but it matters little if you're just going to remove this soon anyway
https://github.com/llvm/llvm-project/pull/83446
More information about the cfe-commits
mailing list