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
This commit is contained in:
Peter Collingbourne 2018-02-27 19:00:59 +00:00
parent c0a1291478
commit e8436e8631
2 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -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
}