[llvm] [RISCV][ISel] Add codegen support for the experimental zabha extension (PR #80192)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 16:07:44 PST 2024


================
@@ -19512,8 +19515,13 @@ RISCVTargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
     return AtomicExpansionKind::None;
 
   unsigned Size = AI->getType()->getPrimitiveSizeInBits();
-  if (Size == 8 || Size == 16)
-    return AtomicExpansionKind::MaskedIntrinsic;
+  if (Size == 8 || Size == 16) {
+    if (!Subtarget.hasStdExtZabha())
+      return AtomicExpansionKind::MaskedIntrinsic;
+    if (AI->getOperation() == AtomicRMWInst::Nand)
----------------
topperc wrote:

I think that causes i8/i16 Nand to return None with Zbha and no Zacas. We need to keep MaskIntrin.

How about 

```
  unsigned Size = AI->getType()->getPrimitiveSizeInBits();                       
  if (AI->getOperation() == AtomicRMWInst::Nand) {                               
    if (Subtarget.hasStdExtZacas() &&                                            
        (Size >= 32 || Subtarget.hasStdExtZabha()))                              
      return AtomicExpansionKind::CmpXChg;                                       
    return AtomicExpansionKind::MaskedIntrinsic;                                 
  }                                                                              
                                                                                 
  if (Size < 32 && !Subtarget.hasStdExtZabha())                                  
    return AtomicExpansionKind::MaskedIntrinsic;                                 
                                                                                 
  return AtomicExpansionKind::None;
```

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


More information about the llvm-commits mailing list