[llvm] edab411 - AArch64: copy all parts of the mem operand across when combining a store

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 19 10:26:43 PDT 2021


Author: Tim Northover
Date: 2021-08-19T18:26:39+01:00
New Revision: edab411ee6cc67687fcc0a8cf702d1113abe9eb1

URL: https://github.com/llvm/llvm-project/commit/edab411ee6cc67687fcc0a8cf702d1113abe9eb1
DIFF: https://github.com/llvm/llvm-project/commit/edab411ee6cc67687fcc0a8cf702d1113abe9eb1.diff

LOG: AArch64: copy all parts of the mem operand across when combining a store

In particular we were dropping volatility, which can lead to unwanted
transformations.

Added: 
    llvm/test/CodeGen/AArch64/volatile-combine.ll

Modified: 
    llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 2ec9f84f48ec..338145b86490 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -15381,8 +15381,7 @@ static SDValue foldTruncStoreOfExt(SelectionDAG &DAG, SDNode *N) {
     if (Store->getMemoryVT() != Orig.getValueType())
       return SDValue();
     return DAG.getStore(Store->getChain(), SDLoc(Store), Orig,
-                        Store->getBasePtr(), Store->getPointerInfo(),
-                        Store->getAlign());
+                        Store->getBasePtr(), Store->getMemOperand());
   }
 
   return SDValue();

diff  --git a/llvm/test/CodeGen/AArch64/volatile-combine.ll b/llvm/test/CodeGen/AArch64/volatile-combine.ll
new file mode 100644
index 000000000000..32fea1990ce7
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/volatile-combine.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mtriple=arm64-apple-ios %s -o - -stop-after=finalize-isel 2>&1 | FileCheck %s
+
+define void @foo(i64 %a, i64 %b, i32* %ptr) {
+; CHECK-LABEL: name: foo
+; CHECK: STRWui {{.*}} (volatile store (s32) into %ir.ptr)
+  %sum = add i64 %a, 1
+  %sum.32 = trunc i64 %sum to i32
+  store volatile i32 %sum.32, i32* %ptr
+  ret void
+}


        


More information about the llvm-commits mailing list