diff options
author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-07-26 19:08:45 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2016-07-26 19:08:45 +0000 |
commit | 6eba5b8c37c852ddc71540d62dd5eb054d5fe54a (patch) | |
tree | 16389eda160ae1bad7f63bbe13615a5bd629ced3 /llvm/lib | |
parent | 96034ca10eae091749974687afb4f1888aab669d (diff) | |
download | bcm5719-llvm-6eba5b8c37c852ddc71540d62dd5eb054d5fe54a.tar.gz bcm5719-llvm-6eba5b8c37c852ddc71540d62dd5eb054d5fe54a.zip |
[Hexagon] Rerun bit tracker on new instructions in RIE
Consider this case:
vreg1 = A2_zxth vreg0 (1)
...
vreg2 = A2_zxth vreg1 (2)
Redundant instruction elimination could delete the instruction (1)
because the user (2) only cares about the low 16 bits. Then it could
delete (2) because the input is already zero-extended. The problem
is that the properties allowing each individual instruction to be
deleted depend on the existence of the other instruction, so either
one can be deleted, but not both.
The existing check for this situation in RIE was insufficient. The
fix is to update all dependent cells when an instruction is removed
(replaced via COPY) in RIE.
llvm-svn: 276792
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Hexagon/BitTracker.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/BitTracker.h | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp | 12 |
3 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/Target/Hexagon/BitTracker.cpp b/llvm/lib/Target/Hexagon/BitTracker.cpp index d052a835fbd..9a2a59750a0 100644 --- a/llvm/lib/Target/Hexagon/BitTracker.cpp +++ b/llvm/lib/Target/Hexagon/BitTracker.cpp @@ -1042,6 +1042,15 @@ bool BT::reached(const MachineBasicBlock *B) const { } +// Visit an individual instruction. This could be a newly added instruction, +// or one that has been modified by an optimization. +void BT::visit(const llvm::MachineInstr &MI) { + assert(!MI.isBranch() && "Only non-branches are allowed"); + InstrExec.insert(&MI); + visitNonBranch(MI); +} + + void BT::reset() { EdgeExec.clear(); InstrExec.clear(); diff --git a/llvm/lib/Target/Hexagon/BitTracker.h b/llvm/lib/Target/Hexagon/BitTracker.h index 5b925fe696f..3c16a73ddb4 100644 --- a/llvm/lib/Target/Hexagon/BitTracker.h +++ b/llvm/lib/Target/Hexagon/BitTracker.h @@ -49,6 +49,7 @@ struct BitTracker { void put(RegisterRef RR, const RegisterCell &RC); void subst(RegisterRef OldRR, RegisterRef NewRR); bool reached(const MachineBasicBlock *B) const; + void visit(const MachineInstr &MI); private: void visitPHI(const MachineInstr &PI); diff --git a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp index 9a8bc0e5b45..e6a03aa5ad5 100644 --- a/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp +++ b/llvm/lib/Target/Hexagon/HexagonBitSimplify.cpp @@ -1294,18 +1294,20 @@ bool RedundantInstrElimination::processBlock(MachineBasicBlock &B, const DebugLoc &DL = MI->getDebugLoc(); const TargetRegisterClass *FRC = HBS::getFinalVRegClass(RD, MRI); unsigned NewR = MRI.createVirtualRegister(FRC); - BuildMI(B, At, DL, HII.get(TargetOpcode::COPY), NewR) - .addReg(RS.Reg, 0, RS.Sub); + MachineInstr *CopyI = + BuildMI(B, At, DL, HII.get(TargetOpcode::COPY), NewR) + .addReg(RS.Reg, 0, RS.Sub); HBS::replaceSubWithSub(RD.Reg, RD.Sub, NewR, 0, MRI); - // Do not update the bit tracker. This pass can create copies between - // registers that don't have the exact same values. Updating the - // tracker here may be tricky. E.g. + // This pass can create copies between registers that don't have the + // exact same values. Updating the tracker has to involve updating + // all dependent cells. Example: // vreg1 = inst vreg2 ; vreg1 != vreg2, but used bits are equal // // vreg3 = copy vreg2 ; <- inserted // ... = vreg3 ; <- replaced from vreg2 // Indirectly, we can create a "copy" between vreg1 and vreg2 even // though their exact values do not match. + BT.visit(*CopyI); Changed = true; break; } |