glsl: Eliminate assumptions about size of ir_expression::operands
[mesa.git] / src / mesa / program / prog_optimize.c
index ab878755e25dc28c938e87ffc3e36b72ff8ee954..96971f2eda48fe9f6112c11a4b0c6fda2135684c 100644 (file)
@@ -758,7 +758,11 @@ _mesa_remove_extra_moves(struct gl_program *prog)
          nesting--;
          break;
       case OPCODE_MOV:
-         if (i > 0 && can_downward_mov_be_modifed(mov) && nesting == 0) {
+         if (i > 0 &&
+             can_downward_mov_be_modifed(mov) &&
+             mov->SrcReg[0].File == PROGRAM_TEMPORARY &&
+             nesting == 0)
+         {
 
             /* see if this MOV can be removed */
             const GLuint id = mov->SrcReg[0].Index;
@@ -1212,7 +1216,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
 
 #if 0
 static void
-print_it(GLcontext *ctx, struct gl_program *program, const char *txt) {
+print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) {
    fprintf(stderr, "%s (%u inst):\n", txt, program->NumInstructions);
    _mesa_print_program(program);
    _mesa_print_program_parameters(ctx, program);
@@ -1226,7 +1230,7 @@ print_it(GLcontext *ctx, struct gl_program *program, const char *txt) {
  * instructions, temp regs, etc.
  */
 void
-_mesa_optimize_program(GLcontext *ctx, struct gl_program *program)
+_mesa_optimize_program(struct gl_context *ctx, struct gl_program *program)
 {
    GLboolean any_change;