[llvm] [CodeGen] Mark the undefined sub-registers of a tuple as IMPLICIT_DEF in two address instruction pass (PR #206442)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 05:36:57 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/CodeGen/RegisterCoalescer.cpp llvm/lib/CodeGen/TwoAddressInstructionPass.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index cd971e235..01272f0ee 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -2988,8 +2988,8 @@ JoinVals::ConflictResolution JoinVals::analyzeValue(unsigned ValNo,
// Check for simple erasable conflicts.
//
- // (WIP) A sub-register IMPLICIT_DEF that materializes a real undef lane consumed later
- // should not be erased here ?
+ // (WIP) A sub-register IMPLICIT_DEF that materializes a real undef lane
+ // consumed later should not be erased here ?
if (DefMI->isImplicitDef() && DefMI->getOperand(0).getSubReg() == 0)
return CR_Erase;
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 29c96aa71..247931e20 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -2056,18 +2056,18 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
}
MachineBasicBlock::iterator EndMBBI =
- std::next(MachineBasicBlock::iterator(MI));
+ std::next(MachineBasicBlock::iterator(MI));
// If there are no live intervals information, we scan the use list once
// in order to find which subregisters are used.
bool HasFullRegUse = false;
bool IsFullyUndef = true;
for (unsigned i = 1, e = MI.getNumOperands(); i < e; i += 2)
- if (!MI.getOperand(i).isUndef()) {
- IsFullyUndef = false;
- break;
- }
-
+ if (!MI.getOperand(i).isUndef()) {
+ IsFullyUndef = false;
+ break;
+ }
+
if (IsFullyUndef) {
LLVM_DEBUG(dbgs() << "Turned: " << MI << " into an IMPLICIT_DEF");
MI.setDesc(TII->get(TargetOpcode::IMPLICIT_DEF));
@@ -2076,22 +2076,21 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
return;
}
-
+
LaneBitmask UsedLanes = LaneBitmask::getNone();
if (!LIS) {
for (MachineOperand &Use : MRI->use_nodbg_operands(DstReg)) {
if (unsigned SubReg = Use.getSubReg())
UsedLanes |= TRI->getSubRegIndexLaneMask(SubReg);
else {
- for (unsigned i = 1, e = MI.getNumOperands(); i < e; i += 2)
- {
- unsigned SubIdx = MI.getOperand(i+1).getImm();
- UsedLanes |= TRI->getSubRegIndexLaneMask(SubIdx);
- }
- break;
+ for (unsigned i = 1, e = MI.getNumOperands(); i < e; i += 2) {
+ unsigned SubIdx = MI.getOperand(i + 1).getImm();
+ UsedLanes |= TRI->getSubRegIndexLaneMask(SubIdx);
}
+ break;
}
}
+ }
LaneBitmask UndefLanes = LaneBitmask::getNone();
bool DefEmitted = false;
@@ -2124,8 +2123,8 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
// Insert the sub-register copy.
MachineInstr *CopyMI = BuildMI(*MI.getParent(), MI, MI.getDebugLoc(),
TII->get(TargetOpcode::COPY))
- .addReg(DstReg, RegState::Define, SubIdx)
- .add(UseMO);
+ .addReg(DstReg, RegState::Define, SubIdx)
+ .add(UseMO);
// The first def needs an undef flag because there is no live register
// before it.
@@ -2169,7 +2168,7 @@ void TwoAddressInstructionImpl::eliminateRegSequence(
LLVM_DEBUG(dbgs() << "Eliminated: " << MI);
MI.eraseFromParent();
- // Udpate LiveIntervals.
- if (LIS)
- LIS->repairIntervalsInRange(MBB, MBBI, EndMBBI, OrigRegs);
+ // Udpate LiveIntervals.
+ if (LIS)
+ LIS->repairIntervalsInRange(MBB, MBBI, EndMBBI, OrigRegs);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/206442
More information about the llvm-commits
mailing list