Skip to content

Commit dec5765

Browse files
authored
[X86] X86FixupInstTuning - add dbg message for each instruction replacement (llvm#144083)
Help debug the changes the pass makes
1 parent d688df5 commit dec5765

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

llvm/lib/Target/X86/X86FixupInstTuning.cpp

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ bool X86FixupInstTuningPass::processInstruction(
132132
auto ProcessVPERMILPDri = [&](unsigned NewOpc) -> bool {
133133
if (!NewOpcPreferable(NewOpc))
134134
return false;
135-
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
136-
MI.removeOperand(NumOperands - 1);
137-
MI.addOperand(MI.getOperand(NumOperands - 2));
138-
MI.setDesc(TII->get(NewOpc));
139-
MI.addOperand(MachineOperand::CreateImm(MaskImm));
135+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
136+
{
137+
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
138+
MI.removeOperand(NumOperands - 1);
139+
MI.addOperand(MI.getOperand(NumOperands - 2));
140+
MI.setDesc(TII->get(NewOpc));
141+
MI.addOperand(MachineOperand::CreateImm(MaskImm));
142+
}
143+
LLVM_DEBUG(dbgs() << " With: " << MI);
140144
return true;
141145
};
142146

@@ -147,11 +151,15 @@ bool X86FixupInstTuningPass::processInstruction(
147151
auto ProcessVPERMILPSri = [&](unsigned NewOpc) -> bool {
148152
if (!NewOpcPreferable(NewOpc))
149153
return false;
150-
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
151-
MI.removeOperand(NumOperands - 1);
152-
MI.addOperand(MI.getOperand(NumOperands - 2));
153-
MI.setDesc(TII->get(NewOpc));
154-
MI.addOperand(MachineOperand::CreateImm(MaskImm));
154+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
155+
{
156+
unsigned MaskImm = MI.getOperand(NumOperands - 1).getImm();
157+
MI.removeOperand(NumOperands - 1);
158+
MI.addOperand(MI.getOperand(NumOperands - 2));
159+
MI.setDesc(TII->get(NewOpc));
160+
MI.addOperand(MachineOperand::CreateImm(MaskImm));
161+
}
162+
LLVM_DEBUG(dbgs() << " With: " << MI);
155163
return true;
156164
};
157165

@@ -164,7 +172,11 @@ bool X86FixupInstTuningPass::processInstruction(
164172
if (!ST->hasNoDomainDelayShuffle() ||
165173
!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
166174
return false;
167-
MI.setDesc(TII->get(NewOpc));
175+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
176+
{
177+
MI.setDesc(TII->get(NewOpc));
178+
}
179+
LLVM_DEBUG(dbgs() << " With: " << MI);
168180
return true;
169181
};
170182

@@ -185,9 +197,12 @@ bool X86FixupInstTuningPass::processInstruction(
185197
auto ProcessUNPCK = [&](unsigned NewOpc, unsigned MaskImm) -> bool {
186198
if (!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
187199
return false;
188-
189-
MI.setDesc(TII->get(NewOpc));
190-
MI.addOperand(MachineOperand::CreateImm(MaskImm));
200+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
201+
{
202+
MI.setDesc(TII->get(NewOpc));
203+
MI.addOperand(MachineOperand::CreateImm(MaskImm));
204+
}
205+
LLVM_DEBUG(dbgs() << " With: " << MI);
191206
return true;
192207
};
193208

@@ -198,7 +213,11 @@ bool X86FixupInstTuningPass::processInstruction(
198213
if (!ST->hasNoDomainDelayShuffle() ||
199214
!NewOpcPreferable(NewOpc, /*ReplaceInTie*/ false))
200215
return false;
201-
MI.setDesc(TII->get(NewOpc));
216+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
217+
{
218+
MI.setDesc(TII->get(NewOpc));
219+
}
220+
LLVM_DEBUG(dbgs() << " With: " << MI);
202221
return true;
203222
};
204223

@@ -229,8 +248,12 @@ bool X86FixupInstTuningPass::processInstruction(
229248
return false;
230249
if (!OptSize && !NewOpcPreferable(MovOpc))
231250
return false;
232-
MI.setDesc(TII->get(MovOpc));
233-
MI.removeOperand(NumOperands - 1);
251+
LLVM_DEBUG(dbgs() << "Replacing: " << MI);
252+
{
253+
MI.setDesc(TII->get(MovOpc));
254+
MI.removeOperand(NumOperands - 1);
255+
}
256+
LLVM_DEBUG(dbgs() << " With: " << MI);
234257
return true;
235258
};
236259

0 commit comments

Comments
 (0)