r600/sb: Don't create three source ops with all kcache values
authorGert Wollny <gert.wollny@collabora.com>
Tue, 10 May 2022 18:04:09 +0000 (20:04 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 17 May 2022 18:43:30 +0000 (18:43 +0000)
There is a good chance that the created instruction can't be
scheduled, so avoid this case.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16499>

src/gallium/drivers/r600/sb/sb_gvn.cpp
src/gallium/drivers/r600/sb/sb_peephole.cpp

index caea4ec..c994ff6 100644 (file)
@@ -174,10 +174,11 @@ void gvn::process_alu_src_constants(node &n, value* &v) {
                }
        }
 
+       unsigned kcache_count = 0;
        for (vvec::iterator I = n.src.begin(), E = n.src.end(); I != E; ++I) {
                value *c = (*I);
 
-               if (c->is_kcache() && !kc.try_reserve(c->select)) {
+               if (c->is_kcache() && (!kc.try_reserve(c->select) || ++kcache_count == 2)) {
                        process_src(v, false);
                        return;
                }
index 979f4bc..5e33631 100644 (file)
@@ -268,6 +268,12 @@ void peephole::optimize_CNDcc_op(alu_node* a) {
        if (d->bc.src[nds].abs)
                return;
 
+       // Don't create an instruction that uses three kcache values
+       // chances are high that it can't be scheduled
+       if (d->src[0]->is_kcache() && a->src[1]->is_kcache() &&
+                a->src[2]->is_kcache())
+               return;
+
        // TODO we can handle some cases for uint comparison
        if (dcmp_type == AF_UINT_CMP)
                return;