mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
Unroll loops by 8 and enable some additional passes
This commit is contained in:
parent
606b7f5a00
commit
b3be0d22cc
3 changed files with 19 additions and 3 deletions
|
@ -434,6 +434,9 @@ LLVMProgram::LLVMProgram()
|
|||
passManagerBuilder.OptLevel = 3;
|
||||
passManagerBuilder.SizeLevel = 0;
|
||||
passManagerBuilder.Inliner = createFunctionInliningPass();
|
||||
passManagerBuilder.SLPVectorize = true;
|
||||
passManagerBuilder.LoopVectorize = true;
|
||||
passManagerBuilder.LoadCombine = true;
|
||||
passManagerBuilder.populateModulePassManager(*mModulePassManager.get());
|
||||
passManagerBuilder.populateFunctionPassManager(*mFunctionPassManager.get());
|
||||
}
|
||||
|
|
|
@ -13,9 +13,22 @@ SSAForBlock::SSAForBlock()
|
|||
SSAScope::builder().SetInsertPoint(if_basic_block);
|
||||
}
|
||||
|
||||
void SSAForBlock::loop_block(SSABool true_condition)
|
||||
void SSAForBlock::loop_block(SSABool true_condition, int unroll_count)
|
||||
{
|
||||
SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block);
|
||||
auto branch = SSAScope::builder().CreateCondBr(true_condition.v, loop_basic_block, end_basic_block);
|
||||
if (unroll_count > 0)
|
||||
{
|
||||
using namespace llvm;
|
||||
auto md_unroll_enable = MDNode::get(SSAScope::context(), {
|
||||
MDString::get(SSAScope::context(), "llvm.loop.unroll.enable")
|
||||
});
|
||||
auto md_unroll_count = MDNode::get(SSAScope::context(), {
|
||||
MDString::get(SSAScope::context(), "llvm.loop.unroll.count"),
|
||||
ConstantAsMetadata::get(ConstantInt::get(SSAScope::context(), APInt(32, unroll_count)))
|
||||
});
|
||||
auto md_loop = MDNode::getDistinct(SSAScope::context(), { md_unroll_enable, md_unroll_count });
|
||||
branch->setMetadata(LLVMContext::MD_loop, md_loop);
|
||||
}
|
||||
SSAScope::builder().SetInsertPoint(loop_basic_block);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class SSAForBlock
|
|||
{
|
||||
public:
|
||||
SSAForBlock();
|
||||
void loop_block(SSABool true_condition);
|
||||
void loop_block(SSABool true_condition, int unroll_count = 8);
|
||||
void end_block();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue