Skip to content

[X86] X86FixupInstTuning - add dbg message for each instruction replacement #144083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
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
57 changes: 40 additions & 17 deletions llvm/lib/Target/X86/X86FixupInstTuning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ bool X86FixupInstTuningPass::processInstruction(
auto ProcessVPERMILPDri = [&](unsigned NewOpc) -> bool {
if (!NewOpcPreferable(NewOpc))
return false;
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
MI.removeOperand(NumOperands - 1);
MI.addOperand(MI.getOperand(NumOperands - 2));
MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
MI.removeOperand(NumOperands - 1);
MI.addOperand(MI.getOperand(NumOperands - 2));
MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand All @@ -147,11 +151,15 @@ bool X86FixupInstTuningPass::processInstruction(
auto ProcessVPERMILPSri = [&](unsigned NewOpc) -> bool {
if (!NewOpcPreferable(NewOpc))
return false;
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
MI.removeOperand(NumOperands - 1);
MI.addOperand(MI.getOperand(NumOperands - 2));
MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
MI.removeOperand(NumOperands - 1);
MI.addOperand(MI.getOperand(NumOperands - 2));
MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand All @@ -164,7 +172,11 @@ bool X86FixupInstTuningPass::processInstruction(
if (!ST->hasNoDomainDelayShuffle() ||
!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
return false;
MI.setDesc(TII->get(NewOpc));
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
MI.setDesc(TII->get(NewOpc));
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand All @@ -185,9 +197,12 @@ bool X86FixupInstTuningPass::processInstruction(
auto ProcessUNPCK = [&](unsigned NewOpc, unsigned MaskImm) -> bool {
if (!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
return false;

MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
MI.setDesc(TII->get(NewOpc));
MI.addOperand(MachineOperand::CreateImm(MaskImm));
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand All @@ -198,7 +213,11 @@ bool X86FixupInstTuningPass::processInstruction(
if (!ST->hasNoDomainDelayShuffle() ||
!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
return false;
MI.setDesc(TII->get(NewOpc));
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
MI.setDesc(TII->get(NewOpc));
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand Down Expand Up @@ -229,8 +248,12 @@ bool X86FixupInstTuningPass::processInstruction(
return false;
if (!OptSize && !NewOpcPreferable(MovOpc))
return false;
MI.setDesc(TII->get(MovOpc));
MI.removeOperand(NumOperands - 1);
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
{
MI.setDesc(TII->get(MovOpc));
MI.removeOperand(NumOperands - 1);
}
LLVM_DEBUG(dbgs() << " With: " << MI);
return true;
};

Expand Down
Loading