Skip to content

Commit

Permalink
[PowerPC] Fixed missing change flag of emitRLDICWhenLoweringJumpTables
Browse files Browse the repository at this point in the history
PPCMIPeephole::emitRLDICWhenLoweringJumpTables should return a bool
value to indicate optimization is conducted or not.

Differential Revision: https://reviews.llvm.org/D63801

llvm-svn: 364383
  • Loading branch information
bzEq committed Jun 26, 2019
1 parent e0e7d4c commit d6a8bc7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
Expand Up @@ -94,7 +94,7 @@ struct PPCMIPeephole : public MachineFunctionPass {
// Perform peepholes.
bool eliminateRedundantCompare(void);
bool eliminateRedundantTOCSaves(std::map<MachineInstr *, bool> &TOCSaves);
void emitRLDICWhenLoweringJumpTables(MachineInstr &MI);
bool emitRLDICWhenLoweringJumpTables(MachineInstr &MI);
void UpdateTOCSaves(std::map<MachineInstr *, bool> &TOCSaves,
MachineInstr *MI);

Expand Down Expand Up @@ -761,7 +761,7 @@ bool PPCMIPeephole::simplifyCode(void) {
break;
}
case PPC::RLDICR: {
emitRLDICWhenLoweringJumpTables(MI);
Simplified = emitRLDICWhenLoweringJumpTables(MI);
break;
}
}
Expand Down Expand Up @@ -1284,25 +1284,25 @@ bool PPCMIPeephole::eliminateRedundantCompare(void) {
// We miss the opportunity to emit an RLDIC when lowering jump tables
// since ISEL sees only a single basic block. When selecting, the clear
// and shift left will be in different blocks.
void PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &MI) {
bool PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &MI) {
if (MI.getOpcode() != PPC::RLDICR)
return;
return false;

unsigned SrcReg = MI.getOperand(1).getReg();
if (!TargetRegisterInfo::isVirtualRegister(SrcReg))
return;
return false;

MachineInstr *SrcMI = MRI->getVRegDef(SrcReg);
if (SrcMI->getOpcode() != PPC::RLDICL)
return;
return false;

MachineOperand MOpSHSrc = SrcMI->getOperand(2);
MachineOperand MOpMBSrc = SrcMI->getOperand(3);
MachineOperand MOpSHMI = MI.getOperand(2);
MachineOperand MOpMEMI = MI.getOperand(3);
if (!(MOpSHSrc.isImm() && MOpMBSrc.isImm() && MOpSHMI.isImm() &&
MOpMEMI.isImm()))
return;
return false;

uint64_t SHSrc = MOpSHSrc.getImm();
uint64_t MBSrc = MOpMBSrc.getImm();
Expand All @@ -1311,7 +1311,7 @@ void PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &MI) {
uint64_t NewSH = SHSrc + SHMI;
uint64_t NewMB = MBSrc - SHMI;
if (NewMB > 63 || NewSH > 63)
return;
return false;

// The bits cleared with RLDICL are [0, MBSrc).
// The bits cleared with RLDICR are (MEMI, 63].
Expand All @@ -1320,7 +1320,7 @@ void PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &MI) {
//
// The bits cleared with RLDIC are [0, NewMB) and (63-NewSH, 63].
if ((63 - NewSH) != MEMI)
return;
return false;

LLVM_DEBUG(dbgs() << "Converting pair: ");
LLVM_DEBUG(SrcMI->dump());
Expand All @@ -1334,6 +1334,7 @@ void PPCMIPeephole::emitRLDICWhenLoweringJumpTables(MachineInstr &MI) {
LLVM_DEBUG(dbgs() << "To: ");
LLVM_DEBUG(MI.dump());
NumRotatesCollapsed++;
return true;
}

} // end default namespace
Expand Down

0 comments on commit d6a8bc7

Please sign in to comment.