r600/sb: add lds related peepholes.
authorDave Airlie <airlied@redhat.com>
Wed, 10 Jan 2018 06:08:48 +0000 (06:08 +0000)
committerDave Airlie <airlied@redhat.com>
Thu, 18 Jan 2018 03:38:17 +0000 (03:38 +0000)
if no destination:
a) convert _RET instructions to non _RET variants if no dst
b) set src0 to undefined if it's a READ, this should get DCE then.

Acked-By: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/sb/sb_peephole.cpp

index 49a6965b1f385380fd864527482b909d9a1bfee1..4390a8f525c87749e2d4aae10ca91b2890a47181 100644 (file)
@@ -68,7 +68,14 @@ void peephole::run_on(container_node* c) {
                        if (n->is_alu_inst()) {
                                alu_node *a = static_cast<alu_node*>(n);
 
-                               if (a->bc.op_ptr->flags &
+                               if (a->bc.op_ptr->flags & AF_LDS) {
+                                       if (!a->dst[0]) {
+                                               if (a->bc.op >= LDS_OP2_LDS_ADD_RET && a->bc.op <= LDS_OP3_LDS_MSKOR_RET)
+                                                       a->bc.set_op(a->bc.op - LDS_OP2_LDS_ADD_RET + LDS_OP2_LDS_ADD);
+                                               if (a->bc.op == LDS_OP1_LDS_READ_RET)
+                                                       a->src[0] = sh.get_undef_value();
+                                       }
+                               } else if (a->bc.op_ptr->flags &
                                                (AF_PRED | AF_SET | AF_CMOV | AF_KILL)) {
                                        optimize_cc_op(a);
                                } else if (a->bc.op == ALU_OP1_FLT_TO_INT) {