[llvm] 9877464 - [Verifier] Clean up load atomic elementwise mem access sizes check (NFC) (#213864)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 08:28:16 PDT 2026


Author: Yonah Goldberg
Date: 2026-08-04T08:28:11-07:00
New Revision: 98774647cfd7dc067e9fda9109a3f7dc1c2e91c3

URL: https://github.com/llvm/llvm-project/commit/98774647cfd7dc067e9fda9109a3f7dc1c2e91c3
DIFF: https://github.com/llvm/llvm-project/commit/98774647cfd7dc067e9fda9109a3f7dc1c2e91c3.diff

LOG: [Verifier] Clean up load atomic elementwise mem access sizes check (NFC) (#213864)

I refactored the `load atomic elementwise` check to have the same
cleaner pattern as `atomicrmw elementwise` and remove the `ScalarTy`
intermediate.

The previous code had this segment:

```
      if (VecTy) {
        checkAtomicMemAccessSize(ScalarTy, &LI);
        ScalarTy = VecTy->getElementType();
      }
```

Which is confusing because it's checking the atomic access size on the
whole vector and then assigning `ScalarTy` to the element type so that
the second check does the check on the element type. It's cleaner to
reverse this and have the first check operate on the element type so
that the second check always checks the entire type.

Added: 
    

Modified: 
    llvm/lib/IR/Verifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 1c2b716fefd7e..44d1843aa56a9 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4624,7 +4624,6 @@ void Verifier::visitLoadInst(LoadInst &LI) {
               LI.getOrdering() != AtomicOrdering::AcquireRelease,
           "Load cannot have Release ordering", &LI);
 
-    Type *ScalarTy = ElTy;
     if (LI.isElementwise()) {
       Check(LI.getOrdering() != AtomicOrdering::SequentiallyConsistent,
             "atomic elementwise load cannot be sequentially consistent.", &LI);
@@ -4632,20 +4631,18 @@ void Verifier::visitLoadInst(LoadInst &LI) {
       Check(VecTy,
             "atomic elementwise load operand must have fixed vector type!", &LI,
             ElTy);
-      if (VecTy) {
-        checkAtomicMemAccessSize(ScalarTy, &LI);
-        ScalarTy = VecTy->getElementType();
-      }
+      if (VecTy)
+        checkAtomicMemAccessSize(VecTy->getElementType(), &LI);
     }
 
-    Check(ScalarTy->getScalarType()->isIntOrPtrTy() ||
-              ScalarTy->getScalarType()->isByteTy() ||
-              ScalarTy->getScalarType()->isFloatingPointTy(),
+    Check(ElTy->getScalarType()->isIntOrPtrTy() ||
+              ElTy->getScalarType()->isByteTy() ||
+              ElTy->getScalarType()->isFloatingPointTy(),
           "atomic load operand must have integer, byte, pointer, floating "
           "point, or vector type!",
           ElTy, &LI);
 
-    checkAtomicMemAccessSize(ScalarTy, &LI);
+    checkAtomicMemAccessSize(ElTy, &LI);
   } else {
     Check(!LI.isElementwise(), "non-atomic load cannot be elementwise", &LI);
     Check(LI.getSyncScopeID() == SyncScope::System,


        


More information about the llvm-commits mailing list