Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/include/llvm/CodeGen/MachineInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1764,8 +1764,8 @@ class MachineInstr
bool isDereferenceableInvariantLoad() const;

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

/// Return true if this instruction has side effects that are not modeled
/// by mayLoad / mayStore, etc.
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,19 +1535,16 @@ bool MachineInstr::isDereferenceableInvariantLoad() const {
return true;
}

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

Register Reg = getOperand(1).getReg();
for (unsigned i = 3, e = getNumOperands(); i < e; i += 2)
if (getOperand(i).getReg() != Reg)
return 0;
return {};
return Reg;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineSSAUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Register MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB,

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