Small fixes to optimization disabling code.
This commit is contained in:
2
func.cpp
2
func.cpp
@@ -287,7 +287,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
|||||||
// is all on and thence having a specialized code path for that
|
// is all on and thence having a specialized code path for that
|
||||||
// case. If this is a simple function, then this isn't worth the
|
// case. If this is a simple function, then this isn't worth the
|
||||||
// code bloat / overhead.
|
// code bloat / overhead.
|
||||||
if (checkMask) {
|
if (checkMask && (g->opt.disableCoherentControlFlow == false)) {
|
||||||
bool allTrue[ISPC_MAX_NVEC];
|
bool allTrue[ISPC_MAX_NVEC];
|
||||||
for (int i = 0; i < g->target.vectorWidth; ++i)
|
for (int i = 0; i < g->target.vectorWidth; ++i)
|
||||||
allTrue[i] = true;
|
allTrue[i] = true;
|
||||||
|
|||||||
11
stmt.cpp
11
stmt.cpp
@@ -491,7 +491,6 @@ IfStmt::IfStmt(Expr *t, Stmt *ts, Stmt *fs, bool checkCoherence, SourcePos p)
|
|||||||
: Stmt(p), test(t), trueStmts(ts), falseStmts(fs),
|
: Stmt(p), test(t), trueStmts(ts), falseStmts(fs),
|
||||||
doAllCheck(checkCoherence &&
|
doAllCheck(checkCoherence &&
|
||||||
!g->opt.disableCoherentControlFlow) {
|
!g->opt.disableCoherentControlFlow) {
|
||||||
// have to wait until after type checking to initialize doAnyCheck.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -869,7 +868,7 @@ lSafeToRunWithAllLanesOff(Stmt *stmt) {
|
|||||||
void
|
void
|
||||||
IfStmt::emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *ltest) const {
|
IfStmt::emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *ltest) const {
|
||||||
llvm::Value *oldMask = ctx->GetInternalMask();
|
llvm::Value *oldMask = ctx->GetInternalMask();
|
||||||
if (ctx->GetFullMask() == LLVMMaskAllOn) {
|
if (ctx->GetFullMask() == LLVMMaskAllOn && !g->opt.disableCoherentControlFlow) {
|
||||||
// We can tell that the mask is on statically at compile time; just
|
// We can tell that the mask is on statically at compile time; just
|
||||||
// emit code for the 'if test with the mask all on' path
|
// emit code for the 'if test with the mask all on' path
|
||||||
llvm::BasicBlock *bDone = ctx->CreateBasicBlock("cif_done");
|
llvm::BasicBlock *bDone = ctx->CreateBasicBlock("cif_done");
|
||||||
@@ -921,11 +920,12 @@ IfStmt::emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *ltest) const {
|
|||||||
//
|
//
|
||||||
// where our use of blend for conditional assignments doesn't check
|
// where our use of blend for conditional assignments doesn't check
|
||||||
// for the 'all lanes' off case.
|
// for the 'all lanes' off case.
|
||||||
|
bool costIsAcceptable = ((trueStmts ? trueStmts->EstimateCost() : 0) +
|
||||||
|
(falseStmts ? falseStmts->EstimateCost() : 0)) <
|
||||||
|
PREDICATE_SAFE_IF_STATEMENT_COST;
|
||||||
if (lSafeToRunWithAllLanesOff(trueStmts) &&
|
if (lSafeToRunWithAllLanesOff(trueStmts) &&
|
||||||
lSafeToRunWithAllLanesOff(falseStmts) &&
|
lSafeToRunWithAllLanesOff(falseStmts) &&
|
||||||
(((trueStmts ? trueStmts->EstimateCost() : 0) +
|
(costIsAcceptable || g->opt.disableCoherentControlFlow)) {
|
||||||
(falseStmts ? falseStmts->EstimateCost() : 0)) <
|
|
||||||
PREDICATE_SAFE_IF_STATEMENT_COST)) {
|
|
||||||
ctx->StartVaryingIf(oldMask);
|
ctx->StartVaryingIf(oldMask);
|
||||||
emitMaskedTrueAndFalse(ctx, oldMask, ltest);
|
emitMaskedTrueAndFalse(ctx, oldMask, ltest);
|
||||||
assert(ctx->GetCurrentBasicBlock());
|
assert(ctx->GetCurrentBasicBlock());
|
||||||
@@ -951,6 +951,7 @@ IfStmt::emitMaskAllOn(FunctionEmitContext *ctx, llvm::Value *ltest,
|
|||||||
// compiler see what's going on so that subsequent optimizations for
|
// compiler see what's going on so that subsequent optimizations for
|
||||||
// code emitted here can operate with the knowledge that the mask is
|
// code emitted here can operate with the knowledge that the mask is
|
||||||
// definitely all on (until it modifies the mask itself).
|
// definitely all on (until it modifies the mask itself).
|
||||||
|
assert(!g->opt.disableCoherentControlFlow);
|
||||||
ctx->SetInternalMask(LLVMMaskAllOn);
|
ctx->SetInternalMask(LLVMMaskAllOn);
|
||||||
llvm::Value *oldFunctionMask = ctx->GetFunctionMask();
|
llvm::Value *oldFunctionMask = ctx->GetFunctionMask();
|
||||||
ctx->SetFunctionMask(LLVMMaskAllOn);
|
ctx->SetFunctionMask(LLVMMaskAllOn);
|
||||||
|
|||||||
Reference in New Issue
Block a user