r300/compiler: fix peephole optimizer
authorTom Stellard <tstellar@gmail.com>
Fri, 14 May 2010 00:15:49 +0000 (02:15 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 16 May 2010 18:20:55 +0000 (20:20 +0200)
Tested-by: Marek Olšák <maraeo@gmail.com>
src/mesa/drivers/dri/r300/compiler/radeon_optimize.c

index 80e3eeacfc10fd7ac3f1413c1bfd57a2d1cffd6a..fd608ccb72a6cc546a7278540cd21cd733aabf27 100644 (file)
@@ -82,6 +82,18 @@ static void peephole_scan_read(void * data, struct rc_instruction * inst,
        if (file != RC_FILE_TEMPORARY || index != s->Mov->U.I.DstReg.Index)
                return;
 
+       /* These instructions cannot read from the constants file.
+        * see radeonTransformTEX()
+        */
+       if(s->Mov->U.I.SrcReg[0].File != RC_FILE_TEMPORARY &&
+                       s->Mov->U.I.SrcReg[0].File != RC_FILE_INPUT &&
+                               (inst->U.I.Opcode == RC_OPCODE_TEX ||
+                               inst->U.I.Opcode == RC_OPCODE_TXB ||
+                               inst->U.I.Opcode == RC_OPCODE_TXP ||
+                               inst->U.I.Opcode == RC_OPCODE_KIL)){
+               s->Conflict = 1;
+               return;
+       }
        if ((mask & s->MovMask) == mask) {
                if (s->SourceClobbered) {
                        s->Conflict = 1;
@@ -109,7 +121,8 @@ static void peephole_scan_write(void * data, struct rc_instruction * inst,
                        s->DefinedMask |= mask;
                else
                        s->DefinedMask &= ~mask;
-       } else if (file == s->Mov->U.I.SrcReg[0].File && index == s->Mov->U.I.SrcReg[0].Index) {
+       }
+       if (file == s->Mov->U.I.SrcReg[0].File && index == s->Mov->U.I.SrcReg[0].Index) {
                if (mask & s->SourcedMask)
                        s->SourceClobbered = 1;
        } else if (s->Mov->U.I.SrcReg[0].RelAddr && file == RC_FILE_ADDRESS) {