mesa/program: Don't copy propagate from swizzles.
authorFabian Bieler <fabianbieler@fastmail.fm>
Wed, 24 Apr 2013 23:30:15 +0000 (01:30 +0200)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 8 May 2013 20:59:19 +0000 (13:59 -0700)
Do not propagate a copy if source and destination are identical.

Otherwise code like

MOV TEMP[0].xyzw, TEMP[0].wzyx
MOV TEMP[1].xyzw, TEMP[0].xyzw

is changed to

MOV TEMP[0].xyzw, TEMP[0].wzyx
MOV TEMP[1].xyzw, TEMP[0].wzyx

This fixes Piglit test shaders/glsl-copy-propagation-self-2 for drivers that
use Mesa IR.

NOTE: This is a candidate for the stable branches.
Signed-off-by: Fabian Bieler <fabianbieler@fastmail.fm>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/program/ir_to_mesa.cpp

index 084846201c9878c1305ac24fba4559a9bc89e0f9..363efe7da65b1def1e6edfef0ced6fa1dec3e4f6 100644 (file)
@@ -2768,6 +2768,8 @@ ir_to_mesa_visitor::copy_propagate(void)
       /* If this is a copy, add it to the ACP. */
       if (inst->op == OPCODE_MOV &&
          inst->dst.file == PROGRAM_TEMPORARY &&
+         !(inst->dst.file == inst->src[0].file &&
+           inst->dst.index == inst->src[0].index) &&
          !inst->dst.reladdr &&
          !inst->saturate &&
          !inst->src[0].reladdr &&