[PATCH] ARM: When re-creating a branch via InsertBranch, preserve CPSR flags.
Peter Collingbourne
peter at pcc.me.uk
Thu Apr 23 13:34:55 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9184
Files:
llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/trunk/test/CodeGen/ARM/sjlj-prepare-critical-edge.ll
llvm/trunk/test/CodeGen/Thumb2/v8_IT_5.ll
Index: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -410,21 +410,23 @@
assert((Cond.size() == 2 || Cond.size() == 0) &&
"ARM branch conditions have two components!");
+ // For conditional branches, we use addOperand to preserve CPSR flags.
+
if (!FBB) {
if (Cond.empty()) { // Unconditional branch?
if (isThumb)
BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB).addImm(ARMCC::AL).addReg(0);
else
BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
} else
BuildMI(&MBB, DL, get(BccOpc)).addMBB(TBB)
- .addImm(Cond[0].getImm()).addReg(Cond[1].getReg());
+ .addImm(Cond[0].getImm()).addOperand(Cond[1]);
return 1;
}
// Two-way conditional branch.
BuildMI(&MBB, DL, get(BccOpc)).addMBB(TBB)
- .addImm(Cond[0].getImm()).addReg(Cond[1].getReg());
+ .addImm(Cond[0].getImm()).addOperand(Cond[1]);
if (isThumb)
BuildMI(&MBB, DL, get(BOpc)).addMBB(FBB).addImm(ARMCC::AL).addReg(0);
else
Index: llvm/trunk/test/CodeGen/Thumb2/v8_IT_5.ll
===================================================================
--- llvm/trunk/test/CodeGen/Thumb2/v8_IT_5.ll
+++ llvm/trunk/test/CodeGen/Thumb2/v8_IT_5.ll
@@ -3,8 +3,7 @@
; CHECK: it ne
; CHECK-NEXT: cmpne
; CHECK-NEXT: bne [[JUMPTARGET:.LBB[0-9]+_[0-9]+]]
-; CHECK: cmp
-; CHECK-NEXT: beq
+; CHECK: cbz
; CHECK-NEXT: %if.else163
; CHECK-NEXT: mov.w
; CHECK-NEXT: b
Index: llvm/trunk/test/CodeGen/ARM/sjlj-prepare-critical-edge.ll
===================================================================
--- llvm/trunk/test/CodeGen/ARM/sjlj-prepare-critical-edge.ll
+++ llvm/trunk/test/CodeGen/ARM/sjlj-prepare-critical-edge.ll
@@ -79,7 +79,7 @@
; CHECK: str r0, [sp, [[OFFSET:#[0-9]+]]]
; CHECK: ldr [[R0:r[0-9]+]], [sp, [[OFFSET]]]
; CHECK: {{.*}}@ %do.body.i.i.i
-; CHECK: cmp [[R0]], #0
+; CHECK: cbz [[R0]]
%"class.std::__1::basic_string" = type { %"class.std::__1::__compressed_pair" }
%"class.std::__1::__compressed_pair" = type { %"class.std::__1::__libcpp_compressed_pair_imp" }
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9184.24330.patch
Type: text/x-patch
Size: 2199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150423/76c36bec/attachment.bin>
More information about the llvm-commits
mailing list