brw_set_default_access_mode(p, BRW_ALIGN_1);
brw_set_default_predicate_control(p, inst->predicate);
brw_set_default_predicate_inverse(p, inst->predicate_inverse);
- brw_set_default_flag_reg(p, inst->flag_subreg / 2, inst->flag_subreg % 2);
+ /* On gen7 and above, hardware automatically adds the group onto the
+ * flag subregister number. On Sandy Bridge and older, we have to do it
+ * ourselves.
+ */
+ const unsigned flag_subreg = inst->flag_subreg +
+ (devinfo->gen >= 7 ? 0 : inst->group / 16);
+ brw_set_default_flag_reg(p, flag_subreg / 2, flag_subreg % 2);
brw_set_default_saturate(p, inst->saturate);
brw_set_default_mask_control(p, inst->force_writemask_all);
brw_set_default_acc_write_control(p, inst->writes_accumulator);