{"optmsgs",    IR3_DBG_OPTMSGS,    "Enable optimizer debug messages"},
        {"forces2en",  IR3_DBG_FORCES2EN,  "Force s2en mode for tex sampler instructions"},
        {"nouboopt",   IR3_DBG_NOUBOOPT,   "Disable lowering UBO to uniform"},
+#ifdef DEBUG
+       {"schedmsgs",  IR3_DBG_SCHEDMSGS,  "Enable scheduler debug messages"},
+#endif
        DEBUG_NAMED_VALUE_END
 };
 
 
        IR3_DBG_OPTMSGS    = 0x080,
        IR3_DBG_FORCES2EN  = 0x100,
        IR3_DBG_NOUBOOPT   = 0x200,
+       IR3_DBG_SCHEDMSGS  = 0x400,
 };
 
 extern enum ir3_shader_debug ir3_shader_debug;
 
        printf("%04u:", instr->name);
        printf("%04u:", instr->ip);
        printf("%03d:", instr->depth);
+       printf("%03u: ", instr->use_count);
 
        if (flags) {
                printf("\t");
 
 #include "util/u_math.h"
 
 #include "ir3.h"
+#include "ir3_compiler.h"
+
+#ifdef DEBUG
+#define SCHED_DEBUG (ir3_shader_debug & IR3_DBG_SCHEDMSGS)
+#else
+#define SCHED_DEBUG 0
+#endif
+#define d(fmt, ...) do { if (SCHED_DEBUG) { \
+       printf("SCHED: "fmt"\n", ##__VA_ARGS__); \
+} } while (0)
+
+#define di(instr, fmt, ...) do { if (SCHED_DEBUG) { \
+       printf("SCHED: "fmt": ", ##__VA_ARGS__); \
+       ir3_print_instr(instr); \
+} } while (0)
 
 /*
  * Instruction Scheduling:
 
        instr->flags |= IR3_INSTR_MARK;
 
+       di(instr, "schedule");
+
        list_addtail(&instr->node, &instr->block->instr_list);
        ctx->scheduled = instr;
 
                if (instr) {
                        unsigned delay = delay_calc(ctx->block, instr, false, false);
 
+                       d("delay=%u", delay);
+
                        /* and if we run out of instructions that can be scheduled,
                         * then it is time for nop's:
                         */