pan/bi: Assume SSA in CSE
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 25 Jul 2022 19:03:36 +0000 (15:03 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/bi_opt_cse.c

index 218d64e..8d1d46f 100644 (file)
@@ -47,7 +47,6 @@ hash_index(uint32_t hash, bi_index index)
         hash = HASH(hash, index.neg);
         hash = HASH(hash, index.swizzle);
         hash = HASH(hash, index.offset);
-        hash = HASH(hash, index.reg);
         hash = HASH(hash, index.type);
         return hash;
 }
@@ -140,22 +139,6 @@ instr_can_cse(const bi_instr *I)
         if (I->branch_target)
                 return false;
 
-        /* Refuse to CSE non-SSA destinations since the data flow analysis
-         * required is nontrivial */
-        bi_foreach_dest(I, d) {
-                if (!bi_is_null(I->dest[d]) && !bi_is_ssa(I->dest[d]))
-                        return false;
-        }
-
-        /* Similar refuse to CSE non-SSA sources. We allow machine registers,
-         * since CSE runs before register allocation which means any registers
-         * encountered are preloaded and hence assumed constant.
-         */
-        bi_foreach_src(I, s) {
-                if (I->src[s].reg)
-                        return false;
-        }
-
         return true;
 }
 
@@ -193,8 +176,7 @@ bi_opt_cse(bi_context *ctx)
                                 const bi_instr *match = entry->key;
 
                                 bi_foreach_dest(instr, d) {
-                                        if (!bi_is_null(instr->dest[d]))
-                                                replacement[instr->dest[d].value] = match->dest[d];
+                                        replacement[instr->dest[d].value] = match->dest[d];
                                 }
                         }
                 }