Skip to content

Commit

Permalink
AArch64: copy all parts of the mem operand across when combining a store
Browse files Browse the repository at this point in the history
In particular we were dropping volatility, which can lead to unwanted
transformations.
  • Loading branch information
TNorthover committed Aug 19, 2021
1 parent 72ebcd3 commit edab411
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/CodeGen/AArch64/volatile-combine.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit edab411

Please sign in to comment.