[llvm] LowerAtomic: Use explicit alignment in lowerAtomicCmpXchgInst (PR #103767)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 03:51:02 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/103767.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/LowerAtomic.cpp (+3-2) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/LowerAtomic.cpp b/llvm/lib/Transforms/Utils/LowerAtomic.cpp
index b203970ef9c5a..f9bf419fb0225 100644
--- a/llvm/lib/Transforms/Utils/LowerAtomic.cpp
+++ b/llvm/lib/Transforms/Utils/LowerAtomic.cpp
@@ -25,10 +25,11 @@ bool llvm::lowerAtomicCmpXchgInst(AtomicCmpXchgInst *CXI) {
   Value *Cmp = CXI->getCompareOperand();
   Value *Val = CXI->getNewValOperand();
 
-  LoadInst *Orig = Builder.CreateLoad(Val->getType(), Ptr);
+  LoadInst *Orig =
+      Builder.CreateAlignedLoad(Val->getType(), Ptr, CXI->getAlign());
   Value *Equal = Builder.CreateICmpEQ(Orig, Cmp);
   Value *Res = Builder.CreateSelect(Equal, Val, Orig);
-  Builder.CreateStore(Res, Ptr);
+  Builder.CreateAlignedStore(Res, Ptr, CXI->getAlign());
 
   Res = Builder.CreateInsertValue(PoisonValue::get(CXI->getType()), Orig, 0);
   Res = Builder.CreateInsertValue(Res, Equal, 1);

``````````

</details>


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


More information about the llvm-commits mailing list