[llvm] r244155 - Divide the primitive size in bits by eight so the initial load's alignment is in

Richard Diamond wichard at vitalitystudios.com
Wed Aug 5 15:10:57 PDT 2015


Author: diamond
Date: Wed Aug  5 17:10:57 2015
New Revision: 244155

URL: http://llvm.org/viewvc/llvm-project?rev=244155&view=rev
Log:
Divide the primitive size in bits by eight so the initial load's alignment is in
bytes as expected. Tested with the included unit test.

Added:
    llvm/trunk/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll
Modified:
    llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp

Modified: llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp?rev=244155&r1=244154&r2=244155&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp (original)
+++ llvm/trunk/lib/CodeGen/AtomicExpandPass.cpp Wed Aug  5 17:10:57 2015
@@ -550,7 +550,7 @@ bool llvm::expandAtomicRMWToCmpXchg(Atom
   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.

Added: llvm/trunk/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll?rev=244155&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll (added)
+++ llvm/trunk/test/Transforms/AtomicExpand/expand-atomic-rmw-initial-load.ll Wed Aug  5 17:10:57 2015
@@ -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




More information about the llvm-commits mailing list