diff --git a/lib/Target/R600/AMDGPU.td b/lib/Target/R600/AMDGPU.td index 0048e25e2f3..a722f555b85 100644 --- a/lib/Target/R600/AMDGPU.td +++ b/lib/Target/R600/AMDGPU.td @@ -21,6 +21,11 @@ def FeatureDumpCode : SubtargetFeature <"DumpCode", "true", "Dump MachineInstrs in the CodeEmitter">; +def FeatureIRStructurizer : SubtargetFeature <"EnableIRStructurizer", + "EnableIRStructurizer", + "true", + "Enable IR Structurizer">; + // Target features def FeatureFP64 : SubtargetFeature<"fp64", diff --git a/lib/Target/R600/AMDGPUSubtarget.cpp b/lib/Target/R600/AMDGPUSubtarget.cpp index 53cfe84e352..1e21c8e8b5c 100644 --- a/lib/Target/R600/AMDGPUSubtarget.cpp +++ b/lib/Target/R600/AMDGPUSubtarget.cpp @@ -36,6 +36,7 @@ AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) : Gen = AMDGPUSubtarget::R600; FP64 = false; CaymanISA = false; + EnableIRStructurizer = false; ParseSubtargetFeatures(GPU, FS); DevName = GPU; } @@ -65,6 +66,10 @@ AMDGPUSubtarget::hasCaymanISA() const { return CaymanISA; } bool +AMDGPUSubtarget::IsIRStructurizerEnabled() const { + return EnableIRStructurizer; +} +bool AMDGPUSubtarget::isTargetELF() const { return false; } diff --git a/lib/Target/R600/AMDGPUSubtarget.h b/lib/Target/R600/AMDGPUSubtarget.h index 0e8b58aa3c5..c5345cc764c 100644 --- a/lib/Target/R600/AMDGPUSubtarget.h +++ b/lib/Target/R600/AMDGPUSubtarget.h @@ -48,6 +48,7 @@ private: enum Generation Gen; bool FP64; bool CaymanISA; + bool EnableIRStructurizer; InstrItineraryData InstrItins; @@ -63,6 +64,7 @@ public: enum Generation getGeneration() const; bool hasHWFP64() const; bool hasCaymanISA() const; + bool IsIRStructurizerEnabled() const; virtual bool enableMachineScheduler() const { return getGeneration() <= NORTHERN_ISLANDS; diff --git a/lib/Target/R600/AMDGPUTargetMachine.cpp b/lib/Target/R600/AMDGPUTargetMachine.cpp index 66585e432e3..1fef0b16078 100644 --- a/lib/Target/R600/AMDGPUTargetMachine.cpp +++ b/lib/Target/R600/AMDGPUTargetMachine.cpp @@ -33,6 +33,7 @@ #include "llvm/Transforms/Scalar.h" #include + using namespace llvm; extern "C" void LLVMInitializeR600Target() { @@ -123,9 +124,11 @@ bool AMDGPUPassConfig::addPreISel() { const AMDGPUSubtarget &ST = TM->getSubtarget(); addPass(createFlattenCFGPass()); + if (ST.IsIRStructurizerEnabled() || + ST.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) + addPass(createStructurizeCFGPass()); if (ST.getGeneration() > AMDGPUSubtarget::NORTHERN_ISLANDS) { addPass(createSITypeRewriter()); - addPass(createStructurizeCFGPass()); addPass(createSIAnnotateControlFlowPass()); } else { addPass(createR600TextureIntrinsicsReplacer()); diff --git a/lib/Target/R600/R600EmitClauseMarkers.cpp b/lib/Target/R600/R600EmitClauseMarkers.cpp index beacc0ea62c..928c0e3ba6d 100644 --- a/lib/Target/R600/R600EmitClauseMarkers.cpp +++ b/lib/Target/R600/R600EmitClauseMarkers.cpp @@ -84,6 +84,7 @@ private: switch (MI->getOpcode()) { case AMDGPU::KILL: case AMDGPU::RETURN: + case AMDGPU::IMPLICIT_DEF: return true; default: return false; diff --git a/lib/Target/R600/R600Packetizer.cpp b/lib/Target/R600/R600Packetizer.cpp index bed91157519..03d8d8767ed 100644 --- a/lib/Target/R600/R600Packetizer.cpp +++ b/lib/Target/R600/R600Packetizer.cpp @@ -340,7 +340,7 @@ bool R600Packetizer::runOnMachineFunction(MachineFunction &Fn) { MachineBasicBlock::iterator End = MBB->end(); MachineBasicBlock::iterator MI = MBB->begin(); while (MI != End) { - if (MI->isKill() || + if (MI->isKill() || MI->getOpcode() == AMDGPU::IMPLICIT_DEF || (MI->getOpcode() == AMDGPU::CF_ALU && !MI->getOperand(8).getImm())) { MachineBasicBlock::iterator DeleteMI = MI; ++MI;