summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/AtomicExpandPass.cpp2
-rw-r--r--llvm/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll8
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 03b0ff32f15..c10648c6e3b 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -550,7 +550,7 @@ bool llvm::expandAtomicRMWToCmpXchg(AtomicRMWInst *AI,
Builder.SetInsertPoint(BB);
LoadInst *InitLoaded = Builder.CreateLoad(Addr);
// Atomics require at least natural alignment.
- InitLoaded->setAlignment(AI->getType()->getPrimitiveSizeInBits());
+ InitLoaded->setAlignment(AI->getType()->getPrimitiveSizeInBits() / 8);
Builder.CreateBr(LoopBB);
// Start the main loop block now that we've taken care of the preliminaries.
diff --git a/llvm/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll b/llvm/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll
new file mode 100644
index 00000000000..197250ef455
--- /dev/null
+++ b/llvm/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll
@@ -0,0 +1,8 @@
+; RUN: opt -S %s -atomic-expand -mtriple=i686-linux-gnu | FileCheck %s
+
+define i8 @test_initial_load(i8* %ptr, i8 %value) {
+ %res = atomicrmw nand i8* %ptr, i8 %value seq_cst
+ ret i8 %res
+}
+; CHECK-LABEL: @test_initial_load
+; CHECK-NEXT: %1 = load i8, i8* %ptr, align 1
OpenPOWER on IntegriCloud