nir: Pull nir_instr_can_cse()'s SSA checks out of the switch.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 21 Jan 2015 20:20:59 +0000 (12:20 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 23 Jan 2015 22:53:26 +0000 (14:53 -0800)
This should not be a change in behavior, as all current cases that
potentially answer "yes" require SSA.

The next patch will introduce another case that requires SSA.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_opt_cse.c

index a33ebdd9981c2ea6f53b75acf4db7becbd85403c..fef167816ab6608cbc8848b54d80ce73f042dd6c 100644 (file)
@@ -139,12 +139,16 @@ dest_is_ssa(nir_dest *dest, void *data)
 static bool
 nir_instr_can_cse(nir_instr *instr)
 {
+   /* We only handle SSA. */
+   if (!nir_foreach_dest(instr, dest_is_ssa, NULL) ||
+       !nir_foreach_src(instr, src_is_ssa, NULL))
+      return false;
+
    switch (instr->type) {
    case nir_instr_type_alu:
    case nir_instr_type_load_const:
    case nir_instr_type_phi:
-      return nir_foreach_dest(instr, dest_is_ssa, NULL) &&
-             nir_foreach_src(instr, src_is_ssa, NULL);
+      return true;
    case nir_instr_type_tex:
       return false; /* TODO */
    case nir_instr_type_intrinsic: