Skip to content

Commit cea9dd8

Browse files
authored
[CodeGen] Change MachineInstr::isConstantValuePHI to return Register. NFC. (llvm#112901)
1 parent bc999ee commit cea9dd8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

llvm/include/llvm/CodeGen/MachineInstr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,8 +1764,8 @@ class MachineInstr
17641764
bool isDereferenceableInvariantLoad() const;
17651765

17661766
/// If the specified instruction is a PHI that always merges together the
1767-
/// same virtual register, return the register, otherwise return 0.
1768-
unsigned isConstantValuePHI() const;
1767+
/// same virtual register, return the register, otherwise return Register().
1768+
Register isConstantValuePHI() const;
17691769

17701770
/// Return true if this instruction has side effects that are not modeled
17711771
/// by mayLoad / mayStore, etc.

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,19 +1535,16 @@ bool MachineInstr::isDereferenceableInvariantLoad() const {
15351535
return true;
15361536
}
15371537

1538-
/// isConstantValuePHI - If the specified instruction is a PHI that always
1539-
/// merges together the same virtual register, return the register, otherwise
1540-
/// return 0.
1541-
unsigned MachineInstr::isConstantValuePHI() const {
1538+
Register MachineInstr::isConstantValuePHI() const {
15421539
if (!isPHI())
1543-
return 0;
1540+
return {};
15441541
assert(getNumOperands() >= 3 &&
15451542
"It's illegal to have a PHI without source operands");
15461543

15471544
Register Reg = getOperand(1).getReg();
15481545
for (unsigned i = 3, e = getNumOperands(); i < e; i += 2)
15491546
if (getOperand(i).getReg() != Reg)
1550-
return 0;
1547+
return {};
15511548
return Reg;
15521549
}
15531550

llvm/lib/CodeGen/MachineSSAUpdater.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB,
201201

202202
// See if the PHI node can be merged to a single value. This can happen in
203203
// loop cases when we get a PHI of itself and one other value.
204-
if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) {
204+
if (Register ConstVal = InsertedPHI->isConstantValuePHI()) {
205205
InsertedPHI->eraseFromParent();
206206
return ConstVal;
207207
}

0 commit comments

Comments
 (0)