https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86107

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
For some reason, this part of x86_mitigate_rop:

      int n_uses;
      reg_class superclass = regrename_find_superclass (head, &n_uses,
                                                        &unavailable);
      old_reg = head->regno;
      best_reg = find_rename_reg (head, superclass, &unavailable,
                                  old_reg, false);
      bool ok = regrename_do_replace (head, best_reg);
      gcc_assert (ok);
      if (dump_file)
        fprintf (dump_file, "Chain %d renamed as %s in %s\n", head->id,
                 reg_names[best_reg], reg_class_names[superclass]);

does not validate in regrename_do_replace.

The compiler wants to rename:

(insn 1264 1263 1265 5 (set (reg:DI 22 xmm1 [594])
        (reg:DI 3 bx [594])) "pr86107.c":15 85 {*movdi_internal}
     (expr_list:REG_DEAD (reg:DI 3 bx [594])
        (nil)))

to:

(set (reg:DI 22 xmm1 [594])
    (reg:DI 1 dx [594]))

and fails validation of new instruction.

The alternative 20 in *movdi_internal (*v->?r) is marked with
preferred_for_speed attribute:

   (set (attr "preferred_for_speed")
     (cond [(eq_attr "alternative" "10,17,19")
              (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
            (eq_attr "alternative" "11,18,20")
              (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
           ]
           (symbol_ref "true")))

but should not fail verification even for !TARGET_INTER_UNIT_MOVES_TO_VEC
targets. As a matter of fact, the compilation works with -mtune=intel.

It looks to me that preferred_for_speed attribute handling is at fault here.

Reply via email to