[llvm] 94a2f9c - [GlobalISel] Fix CombinerHelper::isPredecessor for same def/use MI.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 15 16:45:46 PDT 2021
Author: Ahmed Bougacha
Date: 2021-09-15T16:45:27-07:00
New Revision: 94a2f9cdb6f9ef9843057030159ee69f76722121
URL: https://github.com/llvm/llvm-project/commit/94a2f9cdb6f9ef9843057030159ee69f76722121
DIFF: https://github.com/llvm/llvm-project/commit/94a2f9cdb6f9ef9843057030159ee69f76722121.diff
LOG: [GlobalISel] Fix CombinerHelper::isPredecessor for same def/use MI.
The doc comment for isPredecessor says:
Returns true if \p DefMI precedes \p UseMI or they are the same
instruction.
And dominates relies on that behavior for its own:
Returns true if \p DefMI dominates \p UseMI. By definition an
instruction dominates itself.
Make both statements correct by fixing isPredecessor.
Found by inspection.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 701753b9c11ba..4cd4e2de73941 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -639,7 +639,7 @@ bool CombinerHelper::isPredecessor(const MachineInstr &DefMI,
"shouldn't consider debug uses");
assert(DefMI.getParent() == UseMI.getParent());
if (&DefMI == &UseMI)
- return false;
+ return true;
const MachineBasicBlock &MBB = *DefMI.getParent();
auto DefOrUse = find_if(MBB, [&DefMI, &UseMI](const MachineInstr &MI) {
return &MI == &DefMI || &MI == &UseMI;
More information about the llvm-commits
mailing list