Skip to content

Commit

Permalink
ARM: Don't rewrite add reg, $sp, 0 -> mov reg, $sp if the add defines…
Browse files Browse the repository at this point in the history
… CPSR.

Differential Revision: https://reviews.llvm.org/D43807

llvm-svn: 326226
  • Loading branch information
pcc committed Feb 27, 2018
1 parent c0a1291 commit e8436e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
Expand Up @@ -489,7 +489,8 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
Offset += MI.getOperand(FrameRegIdx+1).getImm();

unsigned PredReg;
if (Offset == 0 && getInstrPredicate(MI, PredReg) == ARMCC::AL) {
if (Offset == 0 && getInstrPredicate(MI, PredReg) == ARMCC::AL &&
!MI.definesRegister(ARM::CPSR)) {
// Turn it into a move.
MI.setDesc(TII.get(ARM::tMOVr));
MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg, false);
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/CodeGen/Thumb2/cmp-frame.ll
@@ -0,0 +1,11 @@
; RUN: llc < %s | FileCheck %s

target triple = "thumbv7-linux-androideabi"

define i1 @f() {
%a = alloca i8*
; CHECK: adds.w r0, sp, #0
; CHECK: it ne
%cmp = icmp ne i8** %a, null
ret i1 %cmp
}

0 comments on commit e8436e8

Please sign in to comment.