Skip to content

Commit 02ba5b8

Browse files
committed
Ignore load/store until stack address computation
No longer conservatively assume a load/store accesses the stack when we can prove that we did not compute any stack-relative address up to this point in the program. We do this in a cheap not-quite-a-dataflow-analysis: Assume `NoStackAddressUsed` when all predecessors of a block already guarantee it. Process blocks in reverse post order to guarantee that except for loop headers we have processed all predecessors of a block before processing the block itself. For loops we accept the conservative answer as they are unlikely to be shrink-wrappable anyway. Differential Revision: https://reviews.llvm.org/D152213
1 parent 759b217 commit 02ba5b8

27 files changed

+855
-842
lines changed

llvm/lib/CodeGen/ShrinkWrap.cpp

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,16 @@ class ShrinkWrap : public MachineFunctionPass {
161161
/// Current MachineFunction.
162162
MachineFunction *MachineFunc = nullptr;
163163

164+
/// Is `true` for block numbers where we can guarantee no stack access
165+
/// or computation of stack-relative addresses on any CFG path including
166+
/// the block itself.
167+
BitVector StackAddressUsedBlockInfo;
168+
164169
/// Check if \p MI uses or defines a callee-saved register or
165170
/// a frame index. If this is the case, this means \p MI must happen
166171
/// after Save and before Restore.
167-
bool useOrDefCSROrFI(const MachineInstr &MI, RegScavenger *RS) const;
172+
bool useOrDefCSROrFI(const MachineInstr &MI, RegScavenger *RS,
173+
bool StackAddressUsed) const;
168174

169175
const SetOfRegs &getCurrentCSRs(RegScavenger *RS) const {
170176
if (CurrentCSRs.empty()) {
@@ -190,7 +196,9 @@ class ShrinkWrap : public MachineFunctionPass {
190196

191197
// Try to find safe point based on dominance and block frequency without
192198
// any change in IR.
193-
bool performShrinkWrapping(MachineFunction &MF, RegScavenger *RS);
199+
bool performShrinkWrapping(
200+
const ReversePostOrderTraversal<MachineBasicBlock *> &RPOT,
201+
RegScavenger *RS);
194202

195203
/// This function tries to split the restore point if doing so can shrink the
196204
/// save point further. \return True if restore point is split.
@@ -285,8 +293,8 @@ INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
285293
INITIALIZE_PASS_DEPENDENCY(MachineOptimizationRemarkEmitterPass)
286294
INITIALIZE_PASS_END(ShrinkWrap, DEBUG_TYPE, "Shrink Wrap Pass", false, false)
287295

288-
bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
289-
RegScavenger *RS) const {
296+
bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI, RegScavenger *RS,
297+
bool StackAddressUsed) const {
290298
/// Check if \p Op is known to access an address not on the function's stack .
291299
/// At the moment, accesses where the underlying object is a global, function
292300
/// argument, or jump table are considered non-stack accesses. Note that the
@@ -306,12 +314,9 @@ bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
306314
return PSV->isJumpTable();
307315
return false;
308316
};
309-
// This prevents premature stack popping when occurs a indirect stack
310-
// access. It is overly aggressive for the moment.
311-
// TODO:
312-
// - Further, data dependency and alias analysis can validate
313-
// that load and stores never derive from the stack pointer.
314-
if (MI.mayLoadOrStore() &&
317+
// Load/store operations may access the stack indirectly when we previously
318+
// computed an address to a stack location.
319+
if (StackAddressUsed && MI.mayLoadOrStore() &&
315320
(MI.isCall() || MI.hasUnmodeledSideEffects() || MI.memoperands_empty() ||
316321
!all_of(MI.memoperands(), IsKnownNonStackPtr)))
317322
return true;
@@ -553,7 +558,7 @@ bool ShrinkWrap::checkIfRestoreSplittable(
553558
SmallVectorImpl<MachineBasicBlock *> &CleanPreds,
554559
const TargetInstrInfo *TII, RegScavenger *RS) {
555560
for (const MachineInstr &MI : *CurRestore)
556-
if (useOrDefCSROrFI(MI, RS))
561+
if (useOrDefCSROrFI(MI, RS, /*StackAddressUsed=*/true))
557562
return false;
558563

559564
for (MachineBasicBlock *PredBB : CurRestore->predecessors()) {
@@ -613,7 +618,7 @@ bool ShrinkWrap::postShrinkWrapping(bool HasCandidate, MachineFunction &MF,
613618
continue;
614619
}
615620
for (const MachineInstr &MI : MBB)
616-
if (useOrDefCSROrFI(MI, RS)) {
621+
if (useOrDefCSROrFI(MI, RS, /*StackAddressUsed=*/true)) {
617622
DirtyBBs.insert(&MBB);
618623
break;
619624
}
@@ -700,7 +705,7 @@ void ShrinkWrap::updateSaveRestorePoints(MachineBasicBlock &MBB,
700705
// terminator.
701706
if (Restore == &MBB) {
702707
for (const MachineInstr &Terminator : MBB.terminators()) {
703-
if (!useOrDefCSROrFI(Terminator, RS))
708+
if (!useOrDefCSROrFI(Terminator, RS, /*StackAddressUsed=*/true))
704709
continue;
705710
// One of the terminator needs to happen before the restore point.
706711
if (MBB.succ_empty()) {
@@ -807,46 +812,62 @@ static bool giveUpWithRemarks(MachineOptimizationRemarkEmitter *ORE,
807812
return false;
808813
}
809814

810-
bool ShrinkWrap::performShrinkWrapping(MachineFunction &MF, RegScavenger *RS) {
811-
for (MachineBasicBlock &MBB : MF) {
812-
LLVM_DEBUG(dbgs() << "Look into: " << MBB.getNumber() << ' '
813-
<< MBB.getName() << '\n');
815+
bool ShrinkWrap::performShrinkWrapping(
816+
const ReversePostOrderTraversal<MachineBasicBlock *> &RPOT,
817+
RegScavenger *RS) {
818+
for (MachineBasicBlock *MBB : RPOT) {
819+
LLVM_DEBUG(dbgs() << "Look into: " << printMBBReference(*MBB) << '\n');
814820

815-
if (MBB.isEHFuncletEntry())
821+
if (MBB->isEHFuncletEntry())
816822
return giveUpWithRemarks(ORE, "UnsupportedEHFunclets",
817823
"EH Funclets are not supported yet.",
818-
MBB.front().getDebugLoc(), &MBB);
824+
MBB->front().getDebugLoc(), MBB);
819825

820-
if (MBB.isEHPad() || MBB.isInlineAsmBrIndirectTarget()) {
826+
if (MBB->isEHPad() || MBB->isInlineAsmBrIndirectTarget()) {
821827
// Push the prologue and epilogue outside of the region that may throw (or
822828
// jump out via inlineasm_br), by making sure that all the landing pads
823829
// are at least at the boundary of the save and restore points. The
824830
// problem is that a basic block can jump out from the middle in these
825831
// cases, which we do not handle.
826-
updateSaveRestorePoints(MBB, RS);
832+
updateSaveRestorePoints(*MBB, RS);
827833
if (!ArePointsInteresting()) {
828834
LLVM_DEBUG(dbgs() << "EHPad/inlineasm_br prevents shrink-wrapping\n");
829835
return false;
830836
}
831837
continue;
832838
}
833839

834-
for (const MachineInstr &MI : MBB) {
835-
if (!useOrDefCSROrFI(MI, RS))
836-
continue;
837-
// Save (resp. restore) point must dominate (resp. post dominate)
838-
// MI. Look for the proper basic block for those.
839-
updateSaveRestorePoints(MBB, RS);
840-
// If we are at a point where we cannot improve the placement of
841-
// save/restore instructions, just give up.
842-
if (!ArePointsInteresting()) {
843-
LLVM_DEBUG(dbgs() << "No Shrink wrap candidate found\n");
844-
return false;
840+
bool StackAddressUsed = false;
841+
// Check if we found any stack accesses in the predecessors. We are not
842+
// doing a full dataflow analysis here to keep things simple but just
843+
// rely on a reverse portorder traversal (RPOT) to guarantee predecessors
844+
// are already processed except for loops (and accept the conservative
845+
// result for loops).
846+
for (const MachineBasicBlock *Pred : MBB->predecessors()) {
847+
if (StackAddressUsedBlockInfo.test(Pred->getNumber())) {
848+
StackAddressUsed = true;
849+
break;
845850
}
846-
// No need to look for other instructions, this basic block
847-
// will already be part of the handled region.
848-
break;
849851
}
852+
853+
for (const MachineInstr &MI : *MBB) {
854+
if (useOrDefCSROrFI(MI, RS, StackAddressUsed)) {
855+
// Save (resp. restore) point must dominate (resp. post dominate)
856+
// MI. Look for the proper basic block for those.
857+
updateSaveRestorePoints(*MBB, RS);
858+
// If we are at a point where we cannot improve the placement of
859+
// save/restore instructions, just give up.
860+
if (!ArePointsInteresting()) {
861+
LLVM_DEBUG(dbgs() << "No Shrink wrap candidate found\n");
862+
return false;
863+
}
864+
// No need to look for other instructions, this basic block
865+
// will already be part of the handled region.
866+
StackAddressUsed = true;
867+
break;
868+
}
869+
}
870+
StackAddressUsedBlockInfo[MBB->getNumber()] = StackAddressUsed;
850871
}
851872
if (!ArePointsInteresting()) {
852873
// If the points are not interesting at this point, then they must be null
@@ -860,13 +881,13 @@ bool ShrinkWrap::performShrinkWrapping(MachineFunction &MF, RegScavenger *RS) {
860881
LLVM_DEBUG(dbgs() << "\n ** Results **\nFrequency of the Entry: " << EntryFreq
861882
<< '\n');
862883

863-
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
884+
const TargetFrameLowering *TFI =
885+
MachineFunc->getSubtarget().getFrameLowering();
864886
do {
865887
LLVM_DEBUG(dbgs() << "Shrink wrap candidates (#, Name, Freq):\nSave: "
866-
<< Save->getNumber() << ' ' << Save->getName() << ' '
888+
<< printMBBReference(*Save) << ' '
867889
<< MBFI->getBlockFreq(Save).getFrequency()
868-
<< "\nRestore: " << Restore->getNumber() << ' '
869-
<< Restore->getName() << ' '
890+
<< "\nRestore: " << printMBBReference(*Restore) << ' '
870891
<< MBFI->getBlockFreq(Restore).getFrequency() << '\n');
871892

872893
bool IsSaveCheap, TargetCanUseSaveAsPrologue = false;
@@ -927,17 +948,18 @@ bool ShrinkWrap::runOnMachineFunction(MachineFunction &MF) {
927948

928949
bool Changed = false;
929950

930-
bool HasCandidate = performShrinkWrapping(MF, RS.get());
951+
StackAddressUsedBlockInfo.resize(MF.getNumBlockIDs(), true);
952+
bool HasCandidate = performShrinkWrapping(RPOT, RS.get());
953+
StackAddressUsedBlockInfo.clear();
931954
Changed = postShrinkWrapping(HasCandidate, MF, RS.get());
932955
if (!HasCandidate && !Changed)
933956
return false;
934957
if (!ArePointsInteresting())
935958
return Changed;
936959

937960
LLVM_DEBUG(dbgs() << "Final shrink wrap candidates:\nSave: "
938-
<< Save->getNumber() << ' ' << Save->getName()
939-
<< "\nRestore: " << Restore->getNumber() << ' '
940-
<< Restore->getName() << '\n');
961+
<< printMBBReference(*Save) << ' '
962+
<< "\nRestore: " << printMBBReference(*Restore) << '\n');
941963

942964
MachineFrameInfo &MFI = MF.getFrameInfo();
943965
MFI.setSavePoint(Save);

llvm/test/CodeGen/AArch64/branch-relax-cbz.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
define void @split_block_no_fallthrough(i64 %val) #0 {
66
; CHECK-LABEL: split_block_no_fallthrough:
77
; CHECK: ; %bb.0: ; %bb
8-
; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
98
; CHECK-NEXT: cmn x0, #5
109
; CHECK-NEXT: b.le LBB0_3
1110
; CHECK-NEXT: ; %bb.1: ; %b3
1211
; CHECK-NEXT: ldr w8, [x8]
1312
; CHECK-NEXT: cbnz w8, LBB0_2
1413
; CHECK-NEXT: b LBB0_4
1514
; CHECK-NEXT: LBB0_2: ; %common.ret
16-
; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
1715
; CHECK-NEXT: ret
1816
; CHECK-NEXT: LBB0_3: ; %b2
19-
; CHECK-NEXT: mov w0, #93
17+
; CHECK-NEXT: stp x29, x30, [sp, #-16]! ; 16-byte Folded Spill
18+
; CHECK-NEXT: mov w0, #93 ; =0x5d
2019
; CHECK-NEXT: bl _extfunc
21-
; CHECK-NEXT: cbnz w0, LBB0_2
22-
; CHECK-NEXT: LBB0_4: ; %b7
23-
; CHECK-NEXT: mov w0, #13
2420
; CHECK-NEXT: ldp x29, x30, [sp], #16 ; 16-byte Folded Reload
21+
; CHECK-NEXT: cbz w0, LBB0_4
22+
; CHECK-NEXT: b LBB0_2
23+
; CHECK-NEXT: LBB0_4: ; %b7
24+
; CHECK-NEXT: mov w0, #13 ; =0xd
2525
; CHECK-NEXT: b _extfunc
2626
bb:
2727
%c0 = icmp sgt i64 %val, -5

llvm/test/CodeGen/AArch64/optimize-cond-branch.ll

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,20 @@ target triple = "arm64--"
1313
define void @func() uwtable {
1414
; CHECK-LABEL: func:
1515
; CHECK: // %bb.0:
16-
; CHECK-NEXT: mov w8, #1
16+
; CHECK-NEXT: mov w8, #1 // =0x1
1717
; CHECK-NEXT: cbnz w8, .LBB0_3
1818
; CHECK-NEXT: // %bb.1: // %b1
19-
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
20-
; CHECK-NEXT: .cfi_def_cfa_offset 16
21-
; CHECK-NEXT: .cfi_offset w30, -16
22-
; CHECK-NEXT: .cfi_remember_state
2319
; CHECK-NEXT: cbz wzr, .LBB0_4
2420
; CHECK-NEXT: // %bb.2: // %b3
2521
; CHECK-NEXT: ldr w8, [x8]
2622
; CHECK-NEXT: and w0, w8, #0x100
27-
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
28-
; CHECK-NEXT: .cfi_def_cfa_offset 0
29-
; CHECK-NEXT: .cfi_restore w30
3023
; CHECK-NEXT: cbz w0, .LBB0_5
3124
; CHECK-NEXT: .LBB0_3: // %common.ret.sink.split
3225
; CHECK-NEXT: b extfunc
3326
; CHECK-NEXT: .LBB0_4: // %b2
34-
; CHECK-NEXT: .cfi_restore_state
27+
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
28+
; CHECK-NEXT: .cfi_def_cfa_offset 16
29+
; CHECK-NEXT: .cfi_offset w30, -16
3530
; CHECK-NEXT: bl extfunc
3631
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
3732
; CHECK-NEXT: .cfi_def_cfa_offset 0

llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,23 +1960,24 @@ define float @debug_info(float %gamma, float %slopeLimit, i1 %or.cond, double %t
19601960
; ARM-ENABLE-LABEL: debug_info:
19611961
; ARM-ENABLE: Lfunc_begin12:
19621962
; ARM-ENABLE-NEXT: @ %bb.0: @ %bb
1963+
; ARM-ENABLE-NEXT: tst r2, #1
1964+
; ARM-ENABLE-NEXT: beq LBB12_2
1965+
; ARM-ENABLE-NEXT: @ %bb.1: @ %bb3
19631966
; ARM-ENABLE-NEXT: push {r4, r7, lr}
19641967
; ARM-ENABLE-NEXT: add r7, sp, #4
19651968
; ARM-ENABLE-NEXT: sub r4, sp, #16
19661969
; ARM-ENABLE-NEXT: bfc r4, #0, #4
19671970
; ARM-ENABLE-NEXT: mov sp, r4
1968-
; ARM-ENABLE-NEXT: tst r2, #1
1969-
; ARM-ENABLE-NEXT: vst1.64 {d8, d9}, [r4:128]
1970-
; ARM-ENABLE-NEXT: beq LBB12_2
1971-
; ARM-ENABLE-NEXT: @ %bb.1: @ %bb3
19721971
; ARM-ENABLE-NEXT: ldr r1, [r7, #8]
1972+
; ARM-ENABLE-NEXT: mov r2, r3
1973+
; ARM-ENABLE-NEXT: vst1.64 {d8, d9}, [r4:128]
19731974
; ARM-ENABLE-NEXT: vmov s16, r0
19741975
; ARM-ENABLE-NEXT: mov r0, r3
1975-
; ARM-ENABLE-NEXT: mov r2, r3
19761976
; ARM-ENABLE-NEXT: vmov d9, r3, r1
19771977
; ARM-ENABLE-NEXT: mov r3, r1
19781978
; ARM-ENABLE-NEXT: bl _pow
19791979
; ARM-ENABLE-NEXT: vmov.f32 s0, #1.000000e+00
1980+
; ARM-ENABLE-NEXT: mov r4, sp
19801981
; ARM-ENABLE-NEXT: vmov.f64 d16, #1.000000e+00
19811982
; ARM-ENABLE-NEXT: vadd.f64 d16, d9, d16
19821983
; ARM-ENABLE-NEXT: vcmp.f32 s16, s0
@@ -1989,17 +1990,17 @@ define float @debug_info(float %gamma, float %slopeLimit, i1 %or.cond, double %t
19891990
; ARM-ENABLE-NEXT: vmrs APSR_nzcv, fpscr
19901991
; ARM-ENABLE-NEXT: vmovne.f64 d9, d17
19911992
; ARM-ENABLE-NEXT: vcvt.f32.f64 s0, d9
1992-
; ARM-ENABLE-NEXT: b LBB12_3
1993+
; ARM-ENABLE-NEXT: vld1.64 {d8, d9}, [r4:128]
1994+
; ARM-ENABLE-NEXT: sub sp, r7, #4
1995+
; ARM-ENABLE-NEXT: pop {r4, r7, lr}
1996+
; ARM-ENABLE-NEXT: vmov r0, s0
1997+
; ARM-ENABLE-NEXT: bx lr
19931998
; ARM-ENABLE-NEXT: LBB12_2:
19941999
; ARM-ENABLE-NEXT: vldr s0, LCPI12_0
1995-
; ARM-ENABLE-NEXT: LBB12_3: @ %bb13
1996-
; ARM-ENABLE-NEXT: mov r4, sp
1997-
; ARM-ENABLE-NEXT: vld1.64 {d8, d9}, [r4:128]
19982000
; ARM-ENABLE-NEXT: vmov r0, s0
1999-
; ARM-ENABLE-NEXT: sub sp, r7, #4
2000-
; ARM-ENABLE-NEXT: pop {r4, r7, pc}
2001+
; ARM-ENABLE-NEXT: bx lr
20012002
; ARM-ENABLE-NEXT: .p2align 2
2002-
; ARM-ENABLE-NEXT: @ %bb.4:
2003+
; ARM-ENABLE-NEXT: @ %bb.3:
20032004
; ARM-ENABLE-NEXT: .data_region
20042005
; ARM-ENABLE-NEXT: LCPI12_0:
20052006
; ARM-ENABLE-NEXT: .long 0x00000000 @ float 0
@@ -2058,23 +2059,24 @@ define float @debug_info(float %gamma, float %slopeLimit, i1 %or.cond, double %t
20582059
; THUMB-ENABLE-LABEL: debug_info:
20592060
; THUMB-ENABLE: Lfunc_begin12:
20602061
; THUMB-ENABLE-NEXT: @ %bb.0: @ %bb
2062+
; THUMB-ENABLE-NEXT: lsls r1, r2, #31
2063+
; THUMB-ENABLE-NEXT: beq LBB12_2
2064+
; THUMB-ENABLE-NEXT: @ %bb.1: @ %bb3
20612065
; THUMB-ENABLE-NEXT: push {r4, r7, lr}
20622066
; THUMB-ENABLE-NEXT: add r7, sp, #4
20632067
; THUMB-ENABLE-NEXT: sub.w r4, sp, #16
20642068
; THUMB-ENABLE-NEXT: bfc r4, #0, #4
20652069
; THUMB-ENABLE-NEXT: mov sp, r4
2066-
; THUMB-ENABLE-NEXT: lsls r1, r2, #31
2067-
; THUMB-ENABLE-NEXT: vst1.64 {d8, d9}, [r4:128]
2068-
; THUMB-ENABLE-NEXT: beq LBB12_2
2069-
; THUMB-ENABLE-NEXT: @ %bb.1: @ %bb3
20702070
; THUMB-ENABLE-NEXT: ldr r1, [r7, #8]
2071+
; THUMB-ENABLE-NEXT: mov r2, r3
2072+
; THUMB-ENABLE-NEXT: vst1.64 {d8, d9}, [r4:128]
20712073
; THUMB-ENABLE-NEXT: vmov s16, r0
20722074
; THUMB-ENABLE-NEXT: mov r0, r3
2073-
; THUMB-ENABLE-NEXT: mov r2, r3
20742075
; THUMB-ENABLE-NEXT: vmov d9, r3, r1
20752076
; THUMB-ENABLE-NEXT: mov r3, r1
20762077
; THUMB-ENABLE-NEXT: bl _pow
20772078
; THUMB-ENABLE-NEXT: vmov.f32 s0, #1.000000e+00
2079+
; THUMB-ENABLE-NEXT: mov r4, sp
20782080
; THUMB-ENABLE-NEXT: vmov.f64 d16, #1.000000e+00
20792081
; THUMB-ENABLE-NEXT: vmov.f64 d18, d9
20802082
; THUMB-ENABLE-NEXT: vcmp.f32 s16, s0
@@ -2089,18 +2091,18 @@ define float @debug_info(float %gamma, float %slopeLimit, i1 %or.cond, double %t
20892091
; THUMB-ENABLE-NEXT: it ne
20902092
; THUMB-ENABLE-NEXT: vmovne.f64 d9, d17
20912093
; THUMB-ENABLE-NEXT: vcvt.f32.f64 s0, d9
2092-
; THUMB-ENABLE-NEXT: b LBB12_3
2093-
; THUMB-ENABLE-NEXT: LBB12_2:
2094-
; THUMB-ENABLE-NEXT: vldr s0, LCPI12_0
2095-
; THUMB-ENABLE-NEXT: LBB12_3: @ %bb13
2096-
; THUMB-ENABLE-NEXT: mov r4, sp
20972094
; THUMB-ENABLE-NEXT: vld1.64 {d8, d9}, [r4:128]
20982095
; THUMB-ENABLE-NEXT: subs r4, r7, #4
2099-
; THUMB-ENABLE-NEXT: vmov r0, s0
21002096
; THUMB-ENABLE-NEXT: mov sp, r4
2101-
; THUMB-ENABLE-NEXT: pop {r4, r7, pc}
2097+
; THUMB-ENABLE-NEXT: pop.w {r4, r7, lr}
2098+
; THUMB-ENABLE-NEXT: vmov r0, s0
2099+
; THUMB-ENABLE-NEXT: bx lr
2100+
; THUMB-ENABLE-NEXT: LBB12_2:
2101+
; THUMB-ENABLE-NEXT: vldr s0, LCPI12_0
2102+
; THUMB-ENABLE-NEXT: vmov r0, s0
2103+
; THUMB-ENABLE-NEXT: bx lr
21022104
; THUMB-ENABLE-NEXT: .p2align 2
2103-
; THUMB-ENABLE-NEXT: @ %bb.4:
2105+
; THUMB-ENABLE-NEXT: @ %bb.3:
21042106
; THUMB-ENABLE-NEXT: .data_region
21052107
; THUMB-ENABLE-NEXT: LCPI12_0:
21062108
; THUMB-ENABLE-NEXT: .long 0x00000000 @ float 0

llvm/test/CodeGen/ARM/machine-cse-cmp.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ entry:
3131
define void @f2() nounwind ssp {
3232
; CHECK-LABEL: f2:
3333
; CHECK: @ %bb.0: @ %entry
34-
; CHECK-NEXT: push {lr}
3534
; CHECK-NEXT: movw r0, :lower16:(L_foo$non_lazy_ptr-(LPC1_0+8))
3635
; CHECK-NEXT: movt r0, :upper16:(L_foo$non_lazy_ptr-(LPC1_0+8))
3736
; CHECK-NEXT: LPC1_0:
3837
; CHECK-NEXT: ldr r0, [pc, r0]
3938
; CHECK-NEXT: ldr r2, [r0]
4039
; CHECK-NEXT: cmp r2, #1
41-
; CHECK-NEXT: poplt {lr}
4240
; CHECK-NEXT: bxlt lr
4341
; CHECK-NEXT: LBB1_1: @ %for.body.lr.ph
42+
; CHECK-NEXT: push {lr}
4443
; CHECK-NEXT: movw r0, :lower16:(L_bar$non_lazy_ptr-(LPC1_1+8))
4544
; CHECK-NEXT: movle r2, #1
4645
; CHECK-NEXT: movt r0, :upper16:(L_bar$non_lazy_ptr-(LPC1_1+8))

0 commit comments

Comments
 (0)