Skip to content

Commit bf0d067

Browse files
committed
[ARM] Make sure we don't transform unaligned store to stm on Thumb1.
This isn't likely to come up in practice; the combination of compiler flags required to hit this issue should be rare. Found by inspection.
1 parent c618692 commit bf0d067

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18169,6 +18169,8 @@ bool ARMTargetLowering::getPostIndexedAddressParts(SDNode *N, SDNode *Op,
1816918169
auto *RHS = dyn_cast<ConstantSDNode>(Op->getOperand(1));
1817018170
if (!RHS || RHS->getZExtValue() != 4)
1817118171
return false;
18172+
if (Alignment < Align(4))
18173+
return false;
1817218174

1817318175
Offset = Op->getOperand(1);
1817418176
Base = Op->getOperand(0);

llvm/test/CodeGen/Thumb/ldm-stm-postinc.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,23 @@ define void @j(i32* %a, i32* readnone %b) {
7979
._crit_edge: ; preds = %.lr.ph, %0
8080
ret void
8181
}
82+
83+
; Make sure we don't transform str->stm when unaligned loads are allowed.
84+
; CHECK-LABEL: @nostrictalign
85+
; CHECK: str r2, [r0]
86+
define void @nostrictalign(i32* %a, i32* readnone %b) "target-features"="-strict-align" {
87+
%1 = icmp eq i32* %a, %b
88+
br i1 %1, label %._crit_edge, label %.lr.ph
89+
90+
.lr.ph: ; preds = %.lr.ph, %0
91+
%i.02 = phi i32 [ %2, %.lr.ph ], [ 0, %0 ]
92+
%.01 = phi i32* [ %3, %.lr.ph ], [ %a, %0 ]
93+
%2 = add nsw i32 %i.02, 1
94+
store i32 %i.02, i32* %.01, align 1
95+
%3 = getelementptr inbounds i32, i32* %.01, i32 1
96+
%4 = icmp eq i32* %3, %b
97+
br i1 %4, label %._crit_edge, label %.lr.ph
98+
99+
._crit_edge: ; preds = %.lr.ph, %0
100+
ret void
101+
}

0 commit comments

Comments
 (0)