if (mode == midgard_reg_mode_32) {
bool lo = ins->swizzle[i][0] >= COMPONENT_Z;
bool hi = ins->swizzle[i][1] >= COMPONENT_Z;
+ unsigned mask = mir_bytemask(ins);
- /* TODO: can we mix halves? */
- assert(lo == hi);
+ if (mask & 0xFF) {
+ /* We can't mix halves... */
+ if (mask & 0xFF00)
+ assert(lo == hi);
- src[i].rep_low |= lo;
+ src[i].rep_low |= lo;
+ } else {
+ src[i].rep_low |= hi;
+ }
} else if (mode < midgard_reg_mode_32) {
unreachable("Cannot encode 8/16 swizzle in 64-bit");
}
unsigned *min_alignment = calloc(sizeof(unsigned), ctx->temp_count);
mir_foreach_instr_global(ctx, ins) {
+ /* Swizzles of 32-bit sources on 64-bit instructions need to be
+ * aligned to either bottom (xy) or top (zw). More general
+ * swizzle lowering should happen prior to scheduling (TODO),
+ * but once we get RA we shouldn't disrupt this further. Align
+ * sources of 64-bit instructions. */
+
+ if (ins->type == TAG_ALU_4 && ins->alu.reg_mode == midgard_reg_mode_64) {
+ mir_foreach_src(ins, v) {
+ unsigned s = ins->src[v];
+
+ if (s < ctx->temp_count)
+ min_alignment[s] = 3;
+ }
+ }
+
if (ins->dest >= SSA_FIXED_MINIMUM) continue;
/* 0 for x, 1 for xy, 2 for xyz, 3 for xyzw */