ir3: Set up full/half register conflicts correctly

Setting up transitive conflicts between a full register and its two
half registers (eg r0.x and hr0.x and hr0.y) will make the half
registers conflict.  They don't actually conflict and this prevents us
from using both at the same time.

Add and use a new ra helper that sets up transitive conflicts between
a register and its subregisters, except it carefully avoids the
subregister conflict.

Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c
index 9f0d71f..789c08f 100644
--- a/src/freedreno/ir3/ir3_ra.c
+++ b/src/freedreno/ir3/ir3_ra.c
@@ -297,8 +297,7 @@
 				unsigned hreg0 = set->gpr_to_ra_reg[i + HALF_OFFSET][(j * 2) + 0];
 				unsigned hreg1 = set->gpr_to_ra_reg[i + HALF_OFFSET][(j * 2) + 1];
 
-				ra_add_transitive_reg_conflict(set->regs, freg, hreg0);
-				ra_add_transitive_reg_conflict(set->regs, freg, hreg1);
+				ra_add_transitive_reg_pair_conflict(set->regs, freg, hreg0, hreg1);
 			}
 		}
 
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index b23bb37..3527363 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -305,6 +305,31 @@
 }
 
 /**
+ * Set up conflicts between base_reg and it's two half registers reg0 and
+ * reg1, but take care to not add conflicts between reg0 and reg1.
+ *
+ * This is useful for architectures where full size registers are aliased by
+ * two half size registers (eg 32 bit float and 16 bit float registers).
+ */
+void
+ra_add_transitive_reg_pair_conflict(struct ra_regs *regs,
+                                    unsigned int base_reg, unsigned int reg0, unsigned int reg1)
+{
+   unsigned int i;
+
+   ra_add_reg_conflict(regs, reg0, base_reg);
+   ra_add_reg_conflict(regs, reg1, base_reg);
+
+   for (i = 0; i < regs->regs[base_reg].num_conflicts; i++) {
+      unsigned int conflict = regs->regs[base_reg].conflict_list[i];
+      if (conflict != reg1)
+         ra_add_reg_conflict(regs, reg0, regs->regs[base_reg].conflict_list[i]);
+      if (conflict != reg0)
+         ra_add_reg_conflict(regs, reg1, regs->regs[base_reg].conflict_list[i]);
+   }
+}
+
+/**
  * Makes every conflict on the given register transitive.  In other words,
  * every register that conflicts with r will now conflict with every other
  * register conflicting with r.
diff --git a/src/util/register_allocate.h b/src/util/register_allocate.h
index 2cb57a1..fcd4d93 100644
--- a/src/util/register_allocate.h
+++ b/src/util/register_allocate.h
@@ -55,6 +55,11 @@
                          unsigned int r1, unsigned int r2);
 void ra_add_transitive_reg_conflict(struct ra_regs *regs,
                                     unsigned int base_reg, unsigned int reg);
+
+void
+ra_add_transitive_reg_pair_conflict(struct ra_regs *regs,
+                                    unsigned int base_reg, unsigned int reg0, unsigned int reg1);
+
 void ra_make_reg_conflicts_transitive(struct ra_regs *regs, unsigned int reg);
 void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
 void ra_set_num_conflicts(struct ra_regs *regs, unsigned int class_a,