[PATCH] D78151: [AArch64InstrInfo] Ignore debug insts in canInstrSubstituteCmpInstr
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 14:19:40 PDT 2020
vsk updated this revision to Diff 257842.
vsk added a comment.
Introduce a range helper to visit instructions (skipping debug insts)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78151/new/
https://reviews.llvm.org/D78151
Files:
llvm/include/llvm/CodeGen/MachineBasicBlock.h
llvm/lib/CodeGen/PeepholeOptimizer.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/arm64-arm64-dead-def-elimination-flag.ll
Index: llvm/test/CodeGen/AArch64/arm64-arm64-dead-def-elimination-flag.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-arm64-dead-def-elimination-flag.ll
+++ llvm/test/CodeGen/AArch64/arm64-arm64-dead-def-elimination-flag.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=arm64-apple-ios7.0.0 -aarch64-enable-dead-defs=false < %s | FileCheck %s
+; RUN: llc -debugify-and-strip-all-safe -mtriple=arm64-apple-ios7.0.0 -aarch64-enable-dead-defs=false < %s | FileCheck %s
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -1443,10 +1443,9 @@
return false;
UsedNZCV NZCVUsedAfterCmp;
- for (auto I = std::next(CmpInstr->getIterator()),
- E = CmpInstr->getParent()->instr_end();
- I != E; ++I) {
- const MachineInstr &Instr = *I;
+ for (const MachineInstr &Instr :
+ instructionsWithoutDebug(std::next(CmpInstr->getIterator()),
+ CmpInstr->getParent()->instr_end())) {
if (Instr.readsRegister(AArch64::NZCV, TRI)) {
AArch64CC::CondCode CC = findCondCodeUsedByInstr(Instr);
if (CC == AArch64CC::Invalid) // Unsupported conditional instruction
Index: llvm/lib/CodeGen/PeepholeOptimizer.cpp
===================================================================
--- llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -614,6 +614,7 @@
return false;
// Attempt to optimize the comparison instruction.
+ LLVM_DEBUG(dbgs() << "Attempting to optimize compare: " << MI);
if (TII->optimizeCompareInstr(MI, SrcReg, SrcReg2, CmpMask, CmpValue, MRI)) {
++NumCmps;
return true;
@@ -635,6 +636,7 @@
return false;
if (!TII->optimizeSelect(MI, LocalMIs))
return false;
+ LLVM_DEBUG(dbgs() << "Deleting select: " << MI);
MI.eraseFromParent();
++NumSelects;
return true;
@@ -1299,6 +1301,7 @@
}
// MI is now dead.
+ LLVM_DEBUG(dbgs() << "Deleting uncoalescable copy: " << MI);
MI.eraseFromParent();
++NumUncoalescableCopies;
return true;
@@ -1723,6 +1726,7 @@
(foldRedundantCopy(*MI, CopySrcRegs, CopySrcMIs) ||
foldRedundantNAPhysCopy(*MI, NAPhysToVirtMIs))) {
LocalMIs.erase(MI);
+ LLVM_DEBUG(dbgs() << "Deleting redundant copy: " << *MI << "\n");
MI->eraseFromParent();
Changed = true;
continue;
Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -1061,6 +1061,23 @@
return It;
}
+/// Construct a range iterator which begins at \p It and moves forwards until
+/// \p End is reached, skipping any debug instructions.
+template <typename IterT>
+inline auto instructionsWithoutDebug(IterT It, IterT End) {
+ return make_filter_range(make_range(It, End), [](const MachineInstr &MI) {
+ return !MI.isDebugInstr();
+ });
+}
+
+/// Construct a range iterator which begins at \p It and moves backwards until
+/// \p Begin is reached, skipping any debug instructions.
+template <typename IterT>
+inline auto reversedInstructionsWithoutDebug(IterT It, IterT Begin) {
+ return instructionsWithoutDebug(make_reverse_iterator(It),
+ make_reverse_iterator(Begin));
+}
+
} // end namespace llvm
#endif // LLVM_CODEGEN_MACHINEBASICBLOCK_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78151.257842.patch
Type: text/x-patch
Size: 3655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/656513f3/attachment.bin>
More information about the llvm-commits
mailing list