[PATCH] D58176: [ARM] Ensure we update the correct flags in the peephole optimiser

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 13 08:38:54 PST 2019


dmgreen updated this revision to Diff 186678.
dmgreen added a comment.

Update comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58176/new/

https://reviews.llvm.org/D58176

Files:
  lib/Target/ARM/ARMBaseInstrInfo.cpp
  test/CodeGen/Thumb2/peephole-addsub.mir


Index: test/CodeGen/Thumb2/peephole-addsub.mir
===================================================================
--- test/CodeGen/Thumb2/peephole-addsub.mir
+++ test/CodeGen/Thumb2/peephole-addsub.mir
@@ -29,7 +29,7 @@
     tBX_RET 14, $noreg, implicit $r0
 
 # CHECK-LABEL: name: test
-# CHECK:      %3:gprnopc = t2ADDrr %0, %1, 14, $noreg, def $cpsr
-# CHECK-NEXT: %4:gprnopc = t2SUBri %3, 0, 14, $noreg, def dead $cpsr
+# CHECK:      %3:gprnopc = t2ADDrr %0, %1, 14, $noreg, $noreg
+# CHECK-NEXT: %4:gprnopc = t2SUBri %3, 0, 14, $noreg, def $cpsr
 # CHECK-NEXT: %5:rgpr = t2MOVCCi %2, 0, 7, $cpsr
 ...
Index: lib/Target/ARM/ARMBaseInstrInfo.cpp
===================================================================
--- lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -2825,8 +2825,11 @@
   if (!MI && !SubAdd)
     return false;
 
-  // The single candidate is called MI.
-  if (!MI) MI = SubAdd;
+  // If we found a SubAdd, use it as it will be closer to the CMP
+  if (SubAdd) {
+    MI = SubAdd;
+    IsThumb1 = false;
+  }
 
   // We can't use a predicated instruction - it doesn't always write the flags.
   if (isPredicated(*MI))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58176.186678.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190213/be49e754/attachment.bin>


More information about the llvm-commits mailing list