[llvm] [CodeGen] Pass the atomic instruction to supportsUnalignedAtomics. NFC (PR #216621)

Fabian Ritter via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 00:04:30 PDT 2026


================
@@ -5369,7 +5369,7 @@ void SelectionDAGBuilder::visitAtomicLoad(const LoadInst &I) {
   EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType());
   EVT MemVT = TLI.getMemValueType(DAG.getDataLayout(), I.getType());
 
-  if (!TLI.supportsUnalignedAtomics() &&
+  if (!TLI.supportsUnalignedAtomics(&I) &&
       I.getAlign().value() < MemVT.getSizeInBits() / 8)
----------------
ritter-x2a wrote:

Are "only supports this atomic instruction if it is naturally aligned" and "supports any alignment for this atomic instruction", which this version enables, the only options we need? I could imagine wanting, e.g., the behavior "only supports this atomic instruction if it is at least 4 aligned", which this can't capture.

We could get this flexibility by moving the check for natural alignment here into the `supportsUnalignedAtomics` function (and probably renaming the function in that case).

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


More information about the llvm-commits mailing list