Skip to content

Commit e8436e8

Browse files
committed
ARM: Don't rewrite add reg, $sp, 0 -> mov reg, $sp if the add defines CPSR.
Differential Revision: https://reviews.llvm.org/D43807 llvm-svn: 326226
1 parent c0a1291 commit e8436e8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/Target/ARM/Thumb2InstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
489489
Offset += MI.getOperand(FrameRegIdx+1).getImm();
490490

491491
unsigned PredReg;
492-
if (Offset == 0 && getInstrPredicate(MI, PredReg) == ARMCC::AL) {
492+
if (Offset == 0 && getInstrPredicate(MI, PredReg) == ARMCC::AL &&
493+
!MI.definesRegister(ARM::CPSR)) {
493494
// Turn it into a move.
494495
MI.setDesc(TII.get(ARM::tMOVr));
495496
MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg, false);

llvm/test/CodeGen/Thumb2/cmp-frame.ll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc < %s | FileCheck %s
2+
3+
target triple = "thumbv7-linux-androideabi"
4+
5+
define i1 @f() {
6+
%a = alloca i8*
7+
; CHECK: adds.w r0, sp, #0
8+
; CHECK: it ne
9+
%cmp = icmp ne i8** %a, null
10+
ret i1 %cmp
11+
}

0 commit comments

Comments
 (0)