intel/fs: Don't emit a des copy for image ops with has_dest == false
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 27 Mar 2018 23:27:20 +0000 (16:27 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 28 Mar 2018 01:18:21 +0000 (18:18 -0700)
This was causing us to walk dest_components times over a thing with no
destination.  This happened to work because all of the image intrinsics
without a destination also happened to have dest_components == 0.  We
shouldn't be reading dest_components if has_dest == false.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/intel/compiler/brw_fs_nir.cpp

index f5d539925984ade9b2124bf2febfad55f85d16ca..197d41062e38256418bf5b82af2f49a594291536 100644 (file)
@@ -3848,9 +3848,12 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
                                  get_image_atomic_op(instr->intrinsic, type));
 
       /* Assign the result. */
-      for (unsigned c = 0; c < info->dest_components; ++c)
-         bld.MOV(offset(retype(dest, base_type), bld, c),
-                 offset(tmp, bld, c));
+      if (nir_intrinsic_infos[instr->intrinsic].has_dest) {
+         for (unsigned c = 0; c < info->dest_components; ++c) {
+            bld.MOV(offset(retype(dest, base_type), bld, c),
+                    offset(tmp, bld, c));
+         }
+      }
       break;
    }