[X86][NewPM] Port x86-fixup-setcc (#175609)
Similar to other portings, except this time we do not refactor to an impl since there is a single runOnMachineFunction definition that can easily be made static. Test coverage added.
This commit is contained in:
parent
acf82c1083
commit
9f0d0bbaf4
@ -100,7 +100,13 @@ public:
|
||||
FunctionPass *createX86OptimizeLEAsLegacyPass();
|
||||
|
||||
/// Return a pass that transforms setcc + movzx pairs into xor + setcc.
|
||||
FunctionPass *createX86FixupSetCC();
|
||||
class X86FixupSetCCPass : public PassInfoMixin<X86FixupSetCCPass> {
|
||||
public:
|
||||
PreservedAnalyses run(MachineFunction &MF,
|
||||
MachineFunctionAnalysisManager &MFAM);
|
||||
};
|
||||
|
||||
FunctionPass *createX86FixupSetCCLegacyPass();
|
||||
|
||||
/// Return a pass that avoids creating store forward block issues in the
|
||||
/// hardware.
|
||||
@ -333,7 +339,7 @@ void initializeX86ExpandPseudoLegacyPass(PassRegistry &);
|
||||
void initializeX86FPStackifierLegacyPass(PassRegistry &);
|
||||
void initializeX86FastPreTileConfigLegacyPass(PassRegistry &);
|
||||
void initializeX86FastTileConfigLegacyPass(PassRegistry &);
|
||||
void initializeX86FixupSetCCPassPass(PassRegistry &);
|
||||
void initializeX86FixupSetCCLegacyPass(PassRegistry &);
|
||||
void initializeX86FlagsCopyLoweringLegacyPass(PassRegistry &);
|
||||
void initializeX86LoadValueInjectionLoadHardeningPassPass(PassRegistry &);
|
||||
void initializeX86LoadValueInjectionRetHardeningPassPass(PassRegistry &);
|
||||
|
||||
@ -39,36 +39,31 @@ using namespace llvm;
|
||||
STATISTIC(NumSubstZexts, "Number of setcc + zext pairs substituted");
|
||||
|
||||
namespace {
|
||||
class X86FixupSetCCPass : public MachineFunctionPass {
|
||||
class X86FixupSetCCLegacy : public MachineFunctionPass {
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
X86FixupSetCCPass() : MachineFunctionPass(ID) {}
|
||||
X86FixupSetCCLegacy() : MachineFunctionPass(ID) {}
|
||||
|
||||
StringRef getPassName() const override { return "X86 Fixup SetCC"; }
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
|
||||
private:
|
||||
MachineRegisterInfo *MRI = nullptr;
|
||||
const X86Subtarget *ST = nullptr;
|
||||
const X86InstrInfo *TII = nullptr;
|
||||
|
||||
enum { SearchBound = 16 };
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
char X86FixupSetCCPass::ID = 0;
|
||||
char X86FixupSetCCLegacy::ID = 0;
|
||||
|
||||
INITIALIZE_PASS(X86FixupSetCCPass, DEBUG_TYPE, DEBUG_TYPE, false, false)
|
||||
INITIALIZE_PASS(X86FixupSetCCLegacy, DEBUG_TYPE, DEBUG_TYPE, false, false)
|
||||
|
||||
FunctionPass *llvm::createX86FixupSetCC() { return new X86FixupSetCCPass(); }
|
||||
FunctionPass *llvm::createX86FixupSetCCLegacyPass() {
|
||||
return new X86FixupSetCCLegacy();
|
||||
}
|
||||
|
||||
bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
static bool fixupSetCC(MachineFunction &MF) {
|
||||
bool Changed = false;
|
||||
MRI = &MF.getRegInfo();
|
||||
ST = &MF.getSubtarget<X86Subtarget>();
|
||||
TII = ST->getInstrInfo();
|
||||
MachineRegisterInfo *MRI = &MF.getRegInfo();
|
||||
const X86Subtarget *ST = &MF.getSubtarget<X86Subtarget>();
|
||||
const X86InstrInfo *TII = ST->getInstrInfo();
|
||||
|
||||
SmallVector<MachineInstr*, 4> ToErase;
|
||||
|
||||
@ -155,3 +150,14 @@ bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
bool X86FixupSetCCLegacy::runOnMachineFunction(MachineFunction &MF) {
|
||||
return fixupSetCC(MF);
|
||||
}
|
||||
|
||||
PreservedAnalyses X86FixupSetCCPass::run(MachineFunction &MF,
|
||||
MachineFunctionAnalysisManager &MFAM) {
|
||||
return fixupSetCC(MF) ? getMachineFunctionPassPreservedAnalyses()
|
||||
.preserveSet<CFGAnalyses>()
|
||||
: PreservedAnalyses::all();
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ MACHINE_FUNCTION_PASS("x86-fast-tile-config", X86FastTileConfigPass())
|
||||
MACHINE_FUNCTION_PASS("x86-fixup-bw-insts", X86FixupBWInstsPass())
|
||||
MACHINE_FUNCTION_PASS("x86-fixup-inst-tuning", X86FixupInstTuningPass())
|
||||
MACHINE_FUNCTION_PASS("x86-fixup-leas", X86FixupLEAsPass())
|
||||
MACHINE_FUNCTION_PASS("x86-fixup-setcc", X86FixupSetCCPass())
|
||||
MACHINE_FUNCTION_PASS("x86-flags-copy-lowering", X86FlagsCopyLoweringPass())
|
||||
MACHINE_FUNCTION_PASS("x86-fp-stackifier", X86FPStackifierPass())
|
||||
MACHINE_FUNCTION_PASS("x86-isel", X86ISelDAGToDAGPass(*this))
|
||||
@ -52,7 +53,6 @@ MACHINE_FUNCTION_PASS("x86-optimize-leas", X86OptimizeLEAsPass())
|
||||
#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME)
|
||||
#endif
|
||||
DUMMY_MACHINE_FUNCTION_PASS("x86-execution-domain-fix", X86ExecutionDomainFix())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("x86-fixup-setcc", X86FixupSetCCPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("x86-fixup-vector-constants", X86FixupVectorConstantsPass())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("x86-lower-tile-copy", X86LowerTileCopy())
|
||||
DUMMY_MACHINE_FUNCTION_PASS("x86-lvi-load", X86LoadValueInjectionLoadHardeningPass())
|
||||
|
||||
@ -77,7 +77,7 @@ extern "C" LLVM_C_ABI void LLVMInitializeX86Target() {
|
||||
initializeCompressEVEXLegacyPass(PR);
|
||||
initializeFixupLEAsLegacyPass(PR);
|
||||
initializeX86FPStackifierLegacyPass(PR);
|
||||
initializeX86FixupSetCCPassPass(PR);
|
||||
initializeX86FixupSetCCLegacyPass(PR);
|
||||
initializeX86CallFrameOptimizationLegacyPass(PR);
|
||||
initializeX86CmovConversionLegacyPass(PR);
|
||||
initializeX86TileConfigPass(PR);
|
||||
@ -514,7 +514,7 @@ bool X86PassConfig::addPreISel() {
|
||||
void X86PassConfig::addPreRegAlloc() {
|
||||
if (getOptLevel() != CodeGenOptLevel::None) {
|
||||
addPass(&LiveRangeShrinkID);
|
||||
addPass(createX86FixupSetCC());
|
||||
addPass(createX86FixupSetCCLegacyPass());
|
||||
addPass(createX86OptimizeLEAsLegacyPass());
|
||||
addPass(createX86CallFrameOptimizationLegacyPass());
|
||||
addPass(createX86AvoidStoreForwardingBlocksLegacyPass());
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# RUN: llc %s --run-pass=x86-fixup-setcc -o - | FileCheck %s
|
||||
# RUN: llc %s -passes=x86-fixup-setcc -o - | FileCheck %s
|
||||
|
||||
## Check the debug-isntr-number transfers from MOVZX32rr8 to the SETCC
|
||||
## after the mov is replaced with an INSERT_SUBREG, updating the substitutions
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user