[llvm] [MachineCSE] Walk the terminator the hoisted copy is placed in front of (PR #215158)
Matt Turner via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 05:28:55 PDT 2026
================
@@ -860,11 +870,15 @@ bool MachineCSEImpl::ProcessBlockPRE(MachineDominatorTree *DT,
// If this instruction uses physical registers then we can only do PRE
// if it's using the value that is live at the place we're hoisting to.
- bool NonLocal;
+ bool NonLocal = false;
PhysDefVector PhysDefs;
+ // The copy lands in front of CMBB's first terminator, so the walk has
+ // to start there: the terminator itself lies between the copy and MI.
+ // getFirstTerminator() is end() when CMBB falls through.
----------------
mattst88 wrote:
No, I double checked and can't construct a test. `CMBB` is a strict dominator of both blocks (`CMBB == MBB1` is rejected above, and `CMBB == MBB` would contradict the assert), so it has at least two successors and therefore a terminator. The one way to get two successors without one is a call with a landing pad successor, and `isLegalToHoistInto` rejects those via `hasEHPadSuccessor()`.
I asserted on it and ran llvm/test/CodeGen but it never fires. Passing the iterator just removes a dereference that happened to always be valid. Reworded that paragraph.
https://github.com/llvm/llvm-project/pull/215158
More information about the llvm-commits
mailing list