[PATCH] D74311: [CodeGen] Fix the computation of the alignment of split stores.

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 05:38:50 PST 2020


courbet updated this revision to Diff 243522.
courbet added a comment.

remove dplicate test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74311/new/

https://reviews.llvm.org/D74311

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/X86/split-store.ll


Index: llvm/test/CodeGen/X86/split-store.ll
===================================================================
--- llvm/test/CodeGen/X86/split-store.ll
+++ llvm/test/CodeGen/X86/split-store.ll
@@ -275,3 +275,19 @@
 exitbb:
   ret void
 }
+
+; See D73907
+define void @ttml_read_coords(float %x, i64* %p) {
+; CHECK-LABEL: ttml_read_coords:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movss %xmm0, (%rdi)
+; CHECK-NEXT:    movl $0, 4(%rdi)
+; CHECK-NEXT:    retq
+  %b = bitcast float %x to i32
+  %z = zext i32 0 to i64
+  %s = shl nuw nsw i64 %z, 32
+  %z2 = zext i32 %b to i64
+  %o = or i64 %s, %z2
+  store i64 %o, i64* %p, align 1
+  ret void
+}
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6868,8 +6868,13 @@
       Addr = Builder.CreateGEP(
           SplitStoreType, Addr,
           ConstantInt::get(Type::getInt32Ty(SI.getContext()), 1));
-    Builder.CreateAlignedStore(V, Addr,
-                               Upper ? SI.getAlign() / 2 : SI.getAlign());
+    MaybeAlign Alignment = SI.getAlign();
+    if (Upper && SI.getAlign()) {
+      // When the original store is aligned, the lower part has the same alignment.
+      // Find the best alignment for the upper part. 
+      Alignment = commonAlignment(SI.getAlign(), HalfValBitSize / 8);
+    }
+    Builder.CreateAlignedStore(V, Addr, Alignment);
   };
 
   CreateSplitStore(LValue, false);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74311.243522.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200210/43294b95/attachment.bin>


More information about the llvm-commits mailing list