intel/mi: Optimize away LOAD_REGISTER_REG from a register to itself
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 1 Apr 2019 23:00:25 +0000 (16:00 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 25 Jul 2019 18:42:55 +0000 (18:42 +0000)
We might want to resolve something to be in a particular register,
so we can access it outside of the gen_mi framework...but it may already
be in that register, at which point there's no work to do.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/intel/common/gen_mi_builder.h

index bb817ce..5008935 100644 (file)
@@ -414,9 +414,11 @@ _gen_mi_copy_no_unref(struct gen_mi_builder *b,
       case GEN_MI_VALUE_TYPE_REG32:
       case GEN_MI_VALUE_TYPE_REG64:
 #if GEN_GEN >= 8 || GEN_IS_HASWELL
-         gen_mi_builder_emit(b, GENX(MI_LOAD_REGISTER_REG), lrr) {
-            lrr.SourceRegisterAddress = src.reg;
-            lrr.DestinationRegisterAddress = dst.reg;
+         if (src.reg != dst.reg) {
+            gen_mi_builder_emit(b, GENX(MI_LOAD_REGISTER_REG), lrr) {
+               lrr.SourceRegisterAddress = src.reg;
+               lrr.DestinationRegisterAddress = dst.reg;
+            }
          }
 #else
          unreachable("Cannot do reg <-> reg copy on IVB and earlier");