mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[Hexagon] Update kills in hexagon-nvj even more properly than before
Account for the fact that both, the feeder and the compare can be moved over instructions that kill registers. llvm-svn: 306443
This commit is contained in:
parent
b4e591cd6e
commit
840728b581
@ -69,9 +69,7 @@ namespace {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
HexagonNewValueJump() : MachineFunctionPass(ID) {
|
||||
initializeHexagonNewValueJumpPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
HexagonNewValueJump() : MachineFunctionPass(ID) {}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<MachineBranchProbabilityInfo>();
|
||||
@ -445,8 +443,6 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) {
|
||||
unsigned predReg = 0; // predicate reg of the jump.
|
||||
unsigned cmpReg1 = 0;
|
||||
int cmpOp2 = 0;
|
||||
bool MO1IsKill = false;
|
||||
bool MO2IsKill = false;
|
||||
MachineBasicBlock::iterator jmpPos;
|
||||
MachineBasicBlock::iterator cmpPos;
|
||||
MachineInstr *cmpInstr = nullptr, *jmpInstr = nullptr;
|
||||
@ -548,14 +544,10 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) {
|
||||
// We need cmpReg1 and cmpOp2(imm or reg) while building
|
||||
// new value jump instruction.
|
||||
cmpReg1 = MI.getOperand(1).getReg();
|
||||
if (MI.getOperand(1).isKill())
|
||||
MO1IsKill = true;
|
||||
|
||||
if (isSecondOpReg) {
|
||||
if (isSecondOpReg)
|
||||
cmpOp2 = MI.getOperand(2).getReg();
|
||||
if (MI.getOperand(2).isKill())
|
||||
MO2IsKill = true;
|
||||
} else
|
||||
else
|
||||
cmpOp2 = MI.getOperand(2).getImm();
|
||||
continue;
|
||||
}
|
||||
@ -605,11 +597,8 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) {
|
||||
if ((COp == Hexagon::C2_cmpeq || COp == Hexagon::C4_cmpneq) &&
|
||||
(feederReg == (unsigned) cmpOp2)) {
|
||||
unsigned tmp = cmpReg1;
|
||||
bool tmpIsKill = MO1IsKill;
|
||||
cmpReg1 = cmpOp2;
|
||||
MO1IsKill = MO2IsKill;
|
||||
cmpOp2 = tmp;
|
||||
MO2IsKill = tmpIsKill;
|
||||
}
|
||||
|
||||
// Now we have swapped the operands, all we need to check is,
|
||||
@ -623,31 +612,33 @@ bool HexagonNewValueJump::runOnMachineFunction(MachineFunction &MF) {
|
||||
// make sure we are respecting the kill values of
|
||||
// the operands of the feeder.
|
||||
|
||||
bool updatedIsKill = false;
|
||||
for (unsigned i = 0; i < MI.getNumOperands(); i++) {
|
||||
MachineOperand &MO = MI.getOperand(i);
|
||||
if (MO.isReg() && MO.isUse()) {
|
||||
unsigned feederReg = MO.getReg();
|
||||
for (MachineBasicBlock::iterator localII = feederPos,
|
||||
end = cmpInstr->getIterator(); localII != end; localII++) {
|
||||
MachineInstr &localMI = *localII;
|
||||
for (unsigned j = 0; j < localMI.getNumOperands(); j++) {
|
||||
MachineOperand &localMO = localMI.getOperand(j);
|
||||
if (localMO.isReg() && localMO.isUse() &&
|
||||
localMO.isKill() && feederReg == localMO.getReg()) {
|
||||
// We found that there is kill of a use register
|
||||
// Set up a kill flag on the register
|
||||
localMO.setIsKill(false);
|
||||
MO.setIsKill();
|
||||
updatedIsKill = true;
|
||||
break;
|
||||
}
|
||||
auto TransferKills = [jmpPos,cmpPos] (MachineInstr &MI) {
|
||||
for (MachineOperand &MO : MI.operands()) {
|
||||
if (!MO.isReg() || !MO.isUse())
|
||||
continue;
|
||||
unsigned UseR = MO.getReg();
|
||||
for (auto I = std::next(MI.getIterator()); I != jmpPos; ++I) {
|
||||
if (I == cmpPos)
|
||||
continue;
|
||||
for (MachineOperand &Op : I->operands()) {
|
||||
if (!Op.isReg() || !Op.isUse() || !Op.isKill())
|
||||
continue;
|
||||
if (Op.getReg() != UseR)
|
||||
continue;
|
||||
// We found that there is kill of a use register
|
||||
// Set up a kill flag on the register
|
||||
Op.setIsKill(false);
|
||||
MO.setIsKill(true);
|
||||
return;
|
||||
}
|
||||
if (updatedIsKill) break;
|
||||
}
|
||||
}
|
||||
if (updatedIsKill) break;
|
||||
}
|
||||
};
|
||||
|
||||
TransferKills(*feederPos);
|
||||
TransferKills(*cmpPos);
|
||||
bool MO1IsKill = cmpPos->killsRegister(cmpReg1, QRI);
|
||||
bool MO2IsKill = isSecondOpReg && cmpPos->killsRegister(cmpOp2, QRI);
|
||||
|
||||
MBB->splice(jmpPos, MI.getParent(), MI);
|
||||
MBB->splice(jmpPos, MI.getParent(), cmpInstr);
|
||||
|
@ -113,6 +113,7 @@ namespace llvm {
|
||||
void initializeHexagonLoopIdiomRecognizePass(PassRegistry&);
|
||||
void initializeHexagonGenMuxPass(PassRegistry&);
|
||||
void initializeHexagonOptAddrModePass(PassRegistry&);
|
||||
void initializeHexagonNewValueJumpPass(PassRegistry&);
|
||||
Pass *createHexagonLoopIdiomPass();
|
||||
|
||||
FunctionPass *createHexagonBitSimplify();
|
||||
@ -158,6 +159,7 @@ extern "C" void LLVMInitializeHexagonTarget() {
|
||||
initializeHexagonLoopIdiomRecognizePass(PR);
|
||||
initializeHexagonGenMuxPass(PR);
|
||||
initializeHexagonOptAddrModePass(PR);
|
||||
initializeHexagonNewValueJumpPass(PR);
|
||||
}
|
||||
|
||||
HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT,
|
||||
|
18
test/CodeGen/Hexagon/newvaluejump-kill2.mir
Normal file
18
test/CodeGen/Hexagon/newvaluejump-kill2.mir
Normal file
@ -0,0 +1,18 @@
|
||||
# RUN: llc -march=hexagon -run-pass hexagon-nvj -verify-machineinstrs %s -o - | FileCheck %s
|
||||
# CHECK: J4_cmpgtu_t_jumpnv_t killed %r3, killed %r1, %bb.1, implicit-def %pc
|
||||
|
||||
---
|
||||
name: fred
|
||||
tracksRegLiveness: true
|
||||
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: %r0
|
||||
%r1 = A2_addi %r0, -1
|
||||
%r2 = A2_tfrsi -1431655765
|
||||
%r3 = A2_tfrsi 2
|
||||
%p0 = C2_cmpgtu killed %r3, %r1
|
||||
%r2 = S4_subaddi killed %r1, 1, killed %r2
|
||||
J2_jumpt killed %p0, %bb.1, implicit-def %pc
|
||||
bb.1:
|
||||
...
|
Loading…
Reference in New Issue
Block a user