From: Christoph Bumiller Date: Wed, 20 Feb 2013 20:03:30 +0000 (+0100) Subject: nv50/ir/opt: make optimization aware of atomics, barriers, surface ops X-Git-Tag: mesa-9.2.1~2343 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0fc2f13eceb525056597c6a9191d2ad81773a4c;p=platform%2Fupstream%2Fmesa.git nv50/ir/opt: make optimization aware of atomics, barriers, surface ops --- diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h index 7ec22b5..43d5fc1 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_inlines.h @@ -46,6 +46,11 @@ static inline bool isTextureOp(operation op) return (op >= OP_TEX && op <= OP_TEXPREP); } +static inline bool isSurfaceOp(operation op) +{ + return (op >= OP_SULDB && op <= OP_SULEA); +} + static inline unsigned int typeSizeof(DataType ty) { switch (ty) { diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp index 19d1c36..6b3e5be 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp @@ -37,6 +37,8 @@ Instruction::isNop() const return true; if (terminator || join) // XXX: should terminator imply flow ? return false; + if (op == OP_ATOM) + return false; if (!fixed && op == OP_NOP) return true; @@ -63,6 +65,8 @@ bool Instruction::isDead() const { if (op == OP_STORE || op == OP_EXPORT || + op == OP_ATOM || + op == OP_SUSTB || op == OP_SUSTP || op == OP_SUREDP || op == OP_SUREDB || op == OP_WRSV) return false; @@ -1727,12 +1731,23 @@ MemoryOpt::runOpt(BasicBlock *bb) isLoad = false; } else { // TODO: maybe have all fixed ops act as barrier ? - if (ldst->op == OP_CALL) { + if (ldst->op == OP_CALL || + ldst->op == OP_BAR || + ldst->op == OP_MEMBAR) { purgeRecords(NULL, FILE_MEMORY_LOCAL); purgeRecords(NULL, FILE_MEMORY_GLOBAL); purgeRecords(NULL, FILE_MEMORY_SHARED); purgeRecords(NULL, FILE_SHADER_OUTPUT); } else + if (ldst->op == OP_ATOM) { + if (ldst->src(0).getFile() == FILE_MEMORY_GLOBAL) { + purgeRecords(NULL, FILE_MEMORY_LOCAL); + purgeRecords(NULL, FILE_MEMORY_GLOBAL); + purgeRecords(NULL, FILE_MEMORY_SHARED); + } else { + purgeRecords(NULL, ldst->src(0).getFile()); + } + } else if (ldst->op == OP_EMIT || ldst->op == OP_RESTART) { purgeRecords(NULL, FILE_SHADER_OUTPUT); } @@ -1941,6 +1956,7 @@ FlatteningPass::visit(BasicBlock *bb) !insn->asFlow() && insn->op != OP_TEXBAR && !isTextureOp(insn->op) && // probably just nve4 + !isSurfaceOp(insn->op) && // not confirmed insn->op != OP_LINTERP && // probably just nve4 insn->op != OP_PINTERP && // probably just nve4 ((insn->op != OP_LOAD && insn->op != OP_STORE) || @@ -2286,6 +2302,12 @@ DeadCodeElim::visit(BasicBlock *bb) } else if (i->defExists(1) && (i->op == OP_VFETCH || i->op == OP_LOAD)) { checkSplitLoad(i); + } else + if (i->defExists(0) && !i->getDef(0)->refCount()) { + if (i->op == OP_ATOM || + i->op == OP_SUREDP || + i->op == OP_SUREDB) + i->setDef(0, NULL); } } return true;