Skip to content

Commit 1de4b40

Browse files
committed
address comment
1 parent f0cdc75 commit 1de4b40

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5256,22 +5256,6 @@ void PPCInstrInfo::promoteInstr32To64ForElimEXTSW(const Register &Reg,
52565256
return;
52575257

52585258
unsigned Opcode = MI->getOpcode();
5259-
bool HasNonSignedExtInstrPromoted = false;
5260-
int NewOpcode = -1;
5261-
5262-
std::unordered_map<unsigned, unsigned> OpcodeMap = {
5263-
{PPC::OR, PPC::OR8}, {PPC::ISEL, PPC::ISEL8},
5264-
{PPC::ORI, PPC::ORI8}, {PPC::XORI, PPC::XORI8},
5265-
{PPC::ORIS, PPC::ORIS8}, {PPC::XORIS, PPC::XORIS8},
5266-
{PPC::AND, PPC::AND8}};
5267-
5268-
// Check if the Opcode is in the map.
5269-
auto It = OpcodeMap.find(Opcode);
5270-
if (It != OpcodeMap.end()) {
5271-
// Set the new opcode to the mapped 64-bit version.
5272-
NewOpcode = It->second;
5273-
HasNonSignedExtInstrPromoted = true;
5274-
}
52755259

52765260
switch (Opcode) {
52775261
case PPC::OR:
@@ -5341,13 +5325,31 @@ void PPCInstrInfo::promoteInstr32To64ForElimEXTSW(const Register &Reg,
53415325
break;
53425326
}
53435327

5328+
bool HasNonSignedExtInstrPromoted = false;
5329+
int NewOpcode = -1;
5330+
5331+
// Map the opcode of instructions (which are not sign- or zero-extended
5332+
// themselves,but have operands that are destination registers of sign- or
5333+
// zero-extended instructions) to their 64-bit equivalents.
5334+
std::unordered_map<unsigned, unsigned> OpcodeMap = {
5335+
{PPC::OR, PPC::OR8}, {PPC::ISEL, PPC::ISEL8},
5336+
{PPC::ORI, PPC::ORI8}, {PPC::XORI, PPC::XORI8},
5337+
{PPC::ORIS, PPC::ORIS8}, {PPC::XORIS, PPC::XORIS8},
5338+
{PPC::AND, PPC::AND8}};
5339+
5340+
auto It = OpcodeMap.find(Opcode);
5341+
if (It != OpcodeMap.end()) {
5342+
// Set the new opcode to the mapped 64-bit version.
5343+
NewOpcode = It->second;
5344+
HasNonSignedExtInstrPromoted = true;
5345+
}
5346+
53445347
const PPCInstrInfo *TII =
53455348
MI->getMF()->getSubtarget<PPCSubtarget>().getInstrInfo();
53465349
if (!TII->isSExt32To64(Opcode) && !HasNonSignedExtInstrPromoted)
53475350
return;
53485351

53495352
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
5350-
53515353
if (RC == &PPC::G8RCRegClass || RC == &PPC::G8RC_and_G8RC_NOX0RegClass)
53525354
return;
53535355

0 commit comments

Comments
 (0)