From cf6274ecfce4bb3234ef4384aa05768405bb7019 Mon Sep 17 00:00:00 2001 From: Fabian Bieler Date: Mon, 28 Mar 2011 19:53:07 +0200 Subject: [PATCH 2/2] mesa: Cache registers in current top level loop when searching for live intervals --- src/mesa/program/prog_optimize.c | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c index 9f3edab..0a2efd7 100644 --- a/src/mesa/program/prog_optimize.c +++ b/src/mesa/program/prog_optimize.c @@ -934,7 +934,8 @@ struct loop_info static void update_interval(GLint intBegin[], GLint intEnd[], GLint intLoopStart[], struct loop_info *loopStack, GLuint loopStackDepth, - GLuint index, GLuint ic) + GLuint index, GLuint ic, GLuint regsInLoop[], + GLuint *numRegsInLoop) { int i; @@ -953,6 +954,10 @@ update_interval(GLint intBegin[], GLint intEnd[], GLint intLoopStart[], ASSERT(intEnd[index] == -1); intBegin[index] = intEnd[index] = ic; ASSERT(intLoopStart[index] == -1); + if (loopStackDepth) { + regsInLoop[*numRegsInLoop] = index; + (*numRegsInLoop)++; + } } else { intEnd[index] = ic; @@ -985,6 +990,9 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, * start of the loop that contains said usage and was closed most recently */ GLint intLoopStart[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; + /* Temporary registers inside current top level loop */ + GLuint regsInLoop[REG_ALLOCATE_MAX_PROGRAM_TEMPS]; + GLuint numRegsInLoop = 0; for (i = 0; i < REG_ALLOCATE_MAX_PROGRAM_TEMPS; i++){ intBegin[i] = intEnd[i] = intLoopStart[i] = -1; @@ -1001,15 +1009,16 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, else if (inst->Opcode == OPCODE_ENDLOOP) { GLuint j; loopStackDepth--; - for (j = 0; j < REG_ALLOCATE_MAX_PROGRAM_TEMPS; j++) { - GLuint index = j; - if (intBegin[index] == -1) - continue; + for (j = 0; j < numRegsInLoop; j++) { + GLuint index = regsInLoop[j]; + ASSERT(intBegin[index] != -1); if (intBegin[index] > loopStack[loopStackDepth].Start && intBegin[index] < loopStack[loopStackDepth].End) { intLoopStart[index] = loopStack[loopStackDepth].Start; } } + if (loopStackDepth == 0) + numRegsInLoop = 0; } else if (inst->Opcode == OPCODE_CAL) { return GL_FALSE; @@ -1023,7 +1032,8 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, if (inst->SrcReg[j].RelAddr) return GL_FALSE; update_interval(intBegin, intEnd, intLoopStart, loopStack, - loopStackDepth, index, i); + loopStackDepth, index, i, regsInLoop, + &numRegsInLoop); } } if (inst->DstReg.File == PROGRAM_TEMPORARY) { @@ -1031,7 +1041,8 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, if (inst->DstReg.RelAddr) return GL_FALSE; update_interval(intBegin, intEnd, intLoopStart, loopStack, - loopStackDepth, index, i); + loopStackDepth, index, i, regsInLoop, + &numRegsInLoop); } } } -- 1.7.4.1