]> granicus.if.org Git - llvm/commitdiff
[RISCV] Fix build after r351778
authorAlex Bradbury <asb@lowrisc.org>
Tue, 22 Jan 2019 05:06:57 +0000 (05:06 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Tue, 22 Jan 2019 05:06:57 +0000 (05:06 +0000)
Also add a comment to explain the expansion strategy for atomicrmw
{fadd,fsub}.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351782 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/RISCV/RISCVISelLowering.cpp

index f70ffaab0c18a99cd46ba535d03d3728fcc50bcc..b9e23df428e889056695b9277f95c35ddb44f010 100644 (file)
@@ -1720,6 +1720,12 @@ Instruction *RISCVTargetLowering::emitTrailingFence(IRBuilder<> &Builder,
 
 TargetLowering::AtomicExpansionKind
 RISCVTargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
+  // atomicrmw {fadd,fsub} must be expanded to use compare-exchange, as
+  // floating point operations can't be used in an lr/sc sequence without
+  // brekaing the forward-progress guarantee.
+  if (AI->isFloatingPointOperation())
+    return AtomicExpansionKind::CmpXChg;
+
   unsigned Size = AI->getType()->getPrimitiveSizeInBits();
   if (Size == 8 || Size == 16)
     return AtomicExpansionKind::MaskedIntrinsic;
@@ -1823,9 +1829,6 @@ Value *RISCVTargetLowering::emitMaskedAtomicRMWIntrinsic(
 TargetLowering::AtomicExpansionKind
 RISCVTargetLowering::shouldExpandAtomicCmpXchgInIR(
     AtomicCmpXchgInst *CI) const {
-  if (CI->isFloatingPointOperation())
-    return AtomicExpansionKind::CmpXChg;
-
   unsigned Size = CI->getCompareOperand()->getType()->getPrimitiveSizeInBits();
   if (Size == 8 || Size == 16)
     return AtomicExpansionKind::MaskedIntrinsic;