Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a temporary solution in order to transition to system provide…
…d LLVM releases. Since we will not anymore patch LLVM sources, we need to customize some LLVM passes for the desired behavior. InstCombiner, by default, performs instruction sinking while doing combining. This causes multiple negative effects (breaking I/O coalesicng, increasing register pressure). the solution so far was to apply a patch to LLVM code base to disable this. Since we do not use patches on LLVM anymore, we copy over the pass into IGC codebase and customize it. A discussion is undergoing to include some of those customizations into LLVM trunk, nevertheless that would happen after LLVM 7.0 transition. At that point, this checkin should be removed to keep the design clean. Change-Id: I14cc6870ec046a85ccd721f92435ded1d98df1f8
- Loading branch information
1 parent
432c310
commit 25753bb
Showing
21 changed files
with
28,956 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,69 @@ | ||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
add_subdirectory(OpenCLPasses) | ||
add_subdirectory(OpenGLPasses) | ||
|
||
set(IGC_BUILD__SRC__Optimizer | ||
"${CMAKE_CURRENT_SOURCE_DIR}/BuiltInFuncImport.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InfiniteLoopRemoval.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/LinkMultiRateShaders.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MCSOptimization.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/GatingSimilarSamples.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIConverter.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIUtils.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncImport.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncLibrary.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/Scalarizer.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/SetMathPrecisionForPositionOutput.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/FixFastMathFlags.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/CodeAssumption.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MarkReadOnlyLoad.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/RectListOptimizationPass.cpp" | ||
) | ||
|
||
set(IGC_BUILD__SRC__Compiler_Optimizer | ||
${IGC_BUILD__SRC__Optimizer} | ||
${IGC_BUILD__SRC__Optimizer_OpenCLPasses} | ||
${IGC_BUILD__SRC__Optimizer_OpenGLPasses} | ||
PARENT_SCOPE | ||
) | ||
|
||
set(IGC_BUILD__HDR__Optimizer | ||
"${CMAKE_CURRENT_SOURCE_DIR}/BuiltInFuncImport.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InfiniteLoopRemoval.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/LinkMultiRateShaders.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIConverter.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIUtils.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MCSOptimization.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/GatingSimilarSamples.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncImport.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/Scalarizer.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/SetMathPrecisionForPositionOutput.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/FixFastMathFlags.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/CodeAssumption.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/RectListOptimizationPass.hpp" | ||
) | ||
|
||
|
||
set(IGC_BUILD__HDR__Compiler_Optimizer | ||
${IGC_BUILD__HDR__Optimizer} | ||
${IGC_BUILD__HDR__Optimizer_OpenCLPasses} | ||
${IGC_BUILD__HDR__Optimizer_OpenGLPasses} | ||
PARENT_SCOPE | ||
) | ||
|
||
|
||
igc_sg_register( | ||
Compiler__Optimizer | ||
"Optimizer" | ||
GROUPS | ||
Compiler__Optimizer_OpenCLPasses | ||
Compiler__Optimizer_OpenGLPasses | ||
FILES | ||
${IGC_BUILD__SRC__Optimizer} | ||
${IGC_BUILD__HDR__Optimizer} | ||
) | ||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
add_subdirectory(OpenCLPasses) | ||
add_subdirectory(OpenGLPasses) | ||
add_subdirectory(IGCInstCombiner) | ||
|
||
set(IGC_BUILD__SRC__Optimizer | ||
"${CMAKE_CURRENT_SOURCE_DIR}/BuiltInFuncImport.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InfiniteLoopRemoval.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/LinkMultiRateShaders.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MCSOptimization.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/GatingSimilarSamples.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIConverter.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIUtils.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncImport.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncLibrary.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/Scalarizer.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/SetMathPrecisionForPositionOutput.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/FixFastMathFlags.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/CodeAssumption.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MarkReadOnlyLoad.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/RectListOptimizationPass.cpp" | ||
) | ||
|
||
set(IGC_BUILD__SRC__Compiler_Optimizer | ||
${IGC_BUILD__SRC__Optimizer} | ||
${IGC_BUILD__SRC__Optimizer_OpenCLPasses} | ||
${IGC_BUILD__SRC__Optimizer_OpenGLPasses} | ||
${IGC_BUILD__SRC__Optimizer_IGCInstCombiner} | ||
PARENT_SCOPE | ||
) | ||
|
||
set(IGC_BUILD__HDR__Optimizer | ||
"${CMAKE_CURRENT_SOURCE_DIR}/BuiltInFuncImport.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InfiniteLoopRemoval.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/LinkMultiRateShaders.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIConverter.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/OCLBIUtils.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/MCSOptimization.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/GatingSimilarSamples.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/PreCompiledFuncImport.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/Scalarizer.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/SetMathPrecisionForPositionOutput.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/FixFastMathFlags.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/CodeAssumption.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/RectListOptimizationPass.hpp" | ||
) | ||
|
||
|
||
set(IGC_BUILD__HDR__Compiler_Optimizer | ||
${IGC_BUILD__HDR__Optimizer} | ||
${IGC_BUILD__HDR__Optimizer_OpenCLPasses} | ||
${IGC_BUILD__HDR__Optimizer_OpenGLPasses} | ||
${IGC_BUILD__HDR__Optimizer_IGCInstCombiner} | ||
PARENT_SCOPE | ||
) | ||
|
||
|
||
igc_sg_register( | ||
Compiler__Optimizer | ||
"Optimizer" | ||
GROUPS | ||
Compiler__Optimizer_OpenCLPasses | ||
Compiler__Optimizer_OpenGLPasses | ||
Compiler__Optimizer_IGCInstCombiner | ||
FILES | ||
${IGC_BUILD__SRC__Optimizer} | ||
${IGC_BUILD__HDR__Optimizer} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
|
||
set(IGC_BUILD__SRC__4_0 | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineAddSub.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineAndOrXor.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineCalls.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineCasts.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineCompares.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineLoadStoreAlloca.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineMulDivRem.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombinePHI.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineSelect.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineShifts.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineSimplifyDemanded.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineVectorOps.cpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstructionCombining.cpp" | ||
) | ||
set(IGC_BUILD__SRC__IGCInstCombiner_4_0 ${IGC_BUILD__SRC__4_0} PARENT_SCOPE) | ||
|
||
set(IGC_BUILD__HDR__4_0 | ||
"${CMAKE_CURRENT_SOURCE_DIR}/InstCombineInternal.h" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/IGCInstructionCombining.hpp" | ||
) | ||
set(IGC_BUILD__HDR__IGCInstCombiner_4_0 ${IGC_BUILD__HDR__4_0} PARENT_SCOPE) | ||
|
||
|
||
igc_sg_register( | ||
Optimizer__IGCInstCombiner_4_0 | ||
"4.0" | ||
FILES | ||
${IGC_BUILD__SRC__4_0} | ||
${IGC_BUILD__HDR__4_0} | ||
) |
62 changes: 62 additions & 0 deletions
62
IGC/Compiler/Optimizer/IGCInstCombiner/4.0/IGCInstructionCombining.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*===================== begin_copyright_notice ================================== | ||
Copyright (c) 2017 Intel Corporation | ||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
======================= end_copyright_notice ==================================*/ | ||
#ifndef IGC_INSTCOMBINE_INSTCOMBINE_H | ||
#define IGC_INSTCOMBINE_INSTCOMBINE_H | ||
|
||
#include <llvm/PassRegistry.h> | ||
#include "llvm/Transforms/InstCombine/InstCombineWorklist.h" | ||
#include "llvm/IR/PassManager.h" | ||
|
||
#include "Compiler/InitializePasses.h" | ||
|
||
namespace llvm { | ||
class FunctionPass; | ||
} | ||
|
||
namespace IGC | ||
{ | ||
class IGCInstructionCombiningPass : public llvm::FunctionPass { | ||
llvm::InstCombineWorklist Worklist; | ||
const bool ExpensiveCombines; | ||
|
||
public: | ||
static char ID; // Pass identification, replacement for typeid | ||
|
||
IGCInstructionCombiningPass(bool ExpensiveCombines = true) | ||
: FunctionPass(ID), ExpensiveCombines(ExpensiveCombines) { | ||
initializeIGCInstructionCombiningPassPass(*llvm::PassRegistry::getPassRegistry()); | ||
} | ||
|
||
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override; | ||
bool runOnFunction(llvm::Function &F) override; | ||
}; | ||
|
||
|
||
llvm::FunctionPass* createIGCInstructionCombiningPass(); | ||
} // namespace IGC | ||
|
||
#endif //IGC_INSTCOMBINE_INSTCOMBINE_H | ||
|
Oops, something went wrong.