Revert "[ARM][MVE] findVCMPToFoldIntoVPS. NFC."

This reverts commit 9468e3334b.

There's a test that doesn't like this change. The RDA analysis
gets invalided by changes in the block, which is not taken into
account. Revert while I work on a fix for this.
This commit is contained in:
Sjoerd Meijer 2019-12-13 11:46:33 +00:00
parent 228c74076d
commit e91420e17d
2 changed files with 30 additions and 29 deletions

View File

@ -22,9 +22,9 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/ReachingDefAnalysis.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include <cassert>
#include <new>
@ -37,21 +37,16 @@ namespace {
class MVEVPTBlock : public MachineFunctionPass {
public:
static char ID;
const Thumb2InstrInfo *TII;
const TargetRegisterInfo *TRI;
MVEVPTBlock() : MachineFunctionPass(ID) {}
bool runOnMachineFunction(MachineFunction &Fn) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
AU.addRequired<ReachingDefAnalysis>();
MachineFunctionPass::getAnalysisUsage(AU);
}
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs).set(
MachineFunctionProperties::Property::TracksLiveness);
MachineFunctionProperties::Property::NoVRegs);
}
StringRef getPassName() const override {
@ -60,9 +55,6 @@ namespace {
private:
bool InsertVPTBlocks(MachineBasicBlock &MBB);
const Thumb2InstrInfo *TII = nullptr;
ReachingDefAnalysis *RDA = nullptr;
};
char MVEVPTBlock::ID = 0;
@ -142,25 +134,35 @@ static unsigned VCMPOpcodeToVPT(unsigned Opcode) {
}
}
static MachineInstr *findVCMPToFoldIntoVPST(MachineInstr *MI,
ReachingDefAnalysis *RDA,
static MachineInstr *findVCMPToFoldIntoVPST(MachineBasicBlock::iterator MI,
const TargetRegisterInfo *TRI,
unsigned &NewOpcode) {
// First, search backwards to the instruction that defines VPR
auto *Def = RDA->getReachingMIDef(MI, ARM::VPR);
if (!Def)
// Search backwards to the instruction that defines VPR. This may or not
// be a VCMP, we check that after this loop. If we find another instruction
// that reads cpsr, we return nullptr.
MachineBasicBlock::iterator CmpMI = MI;
while (CmpMI != MI->getParent()->begin()) {
--CmpMI;
if (CmpMI->modifiesRegister(ARM::VPR, TRI))
break;
if (CmpMI->readsRegister(ARM::VPR, TRI))
break;
}
if (CmpMI == MI)
return nullptr;
NewOpcode = VCMPOpcodeToVPT(CmpMI->getOpcode());
if (NewOpcode == 0)
return nullptr;
// Now check that Def is a VCMP
if (!(NewOpcode = VCMPOpcodeToVPT(Def->getOpcode())))
// Search forward from CmpMI to MI, checking if either register was def'd
if (registerDefinedBetween(CmpMI->getOperand(1).getReg(), std::next(CmpMI),
MI, TRI))
return nullptr;
// Check that Def's operands are not defined between the VCMP and MI, i.e.
// check that they have the same reaching def.
if (!RDA->hasSameReachingDef(Def, MI, Def->getOperand(1).getReg()) ||
!RDA->hasSameReachingDef(Def, MI, Def->getOperand(2).getReg()))
if (registerDefinedBetween(CmpMI->getOperand(2).getReg(), std::next(CmpMI),
MI, TRI))
return nullptr;
return Def;
return &*CmpMI;
}
bool MVEVPTBlock::InsertVPTBlocks(MachineBasicBlock &Block) {
@ -228,7 +230,7 @@ bool MVEVPTBlock::InsertVPTBlocks(MachineBasicBlock &Block) {
// a VPST directly
MachineInstrBuilder MIBuilder;
unsigned NewOpcode;
MachineInstr *VCMP = findVCMPToFoldIntoVPST(MI, RDA, NewOpcode);
MachineInstr *VCMP = findVCMPToFoldIntoVPST(MI, TRI, NewOpcode);
if (VCMP) {
LLVM_DEBUG(dbgs() << " folding VCMP into VPST: "; VCMP->dump());
MIBuilder = BuildMI(Block, MI, dl, TII->get(NewOpcode));
@ -258,7 +260,7 @@ bool MVEVPTBlock::runOnMachineFunction(MachineFunction &Fn) {
return false;
TII = static_cast<const Thumb2InstrInfo *>(STI.getInstrInfo());
RDA = &getAnalysis<ReachingDefAnalysis>();
TRI = STI.getRegisterInfo();
LLVM_DEBUG(dbgs() << "********** ARM MVE VPT BLOCKS **********\n"
<< "********** Function: " << Fn.getName() << '\n');

View File

@ -144,7 +144,6 @@
; CHECK-NEXT: Machine Natural Loop Construction
; CHECK-NEXT: Machine Block Frequency Analysis
; CHECK-NEXT: If Converter
; CHECK-NEXT: ReachingDefAnalysis
; CHECK-NEXT: MVE VPT block insertion pass
; CHECK-NEXT: Thumb IT blocks insertion pass
; CHECK-NEXT: MachineDominator Tree Construction