[PATCH] D52558: [PHIElimination] Lower a PHI node with only undef uses as IMPLICIT_DEF
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 27 09:27:03 PDT 2018
MatzeB accepted this revision.
MatzeB added a comment.
This revision is now accepted and ready to land.
The patch on its own makes sense to me, so LGTM (comment below).
I didn't know `PHIElimination` looks for `IMPLICIT_DEF`s, do you have an idea why that is given that we run `ProcessImplicitDefs` immediately before `PHIElimination` and it has a rule to eliminate phi-nodes with all implicit-def inputs too...
================
Comment at: lib/CodeGen/PHIElimination.cpp:225-226
+/// Return true if all sources of the phi node are implicit_def's, or undef's.
+static bool isSourceUndefined(const MachineInstr *MPhi,
+ const MachineRegisterInfo *MRI) {
for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2)
----------------
If we touch this function anyway, should we take the opportunity to switch to a more modern style:
```
static bool isSourceUndefined(const MachineInstr &MPhi,
const MachineRegisterInfo &MRI) {
for (unsigned I = 1, E = MPhi->getNumOperands(); I != E; I += 2) {
const MachineOperand &MO = MPhi->getOperand(I);
if (!isImplicitlyDefined(MO.getReg(), MRI) && !MO.isUndef())
return false;
}
return true;
}
```
Repository:
rL LLVM
https://reviews.llvm.org/D52558
More information about the llvm-commits
mailing list