]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[IRA]: Fix implicit preference calculation.
authorVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Apr 2026 12:36:13 +0000 (08:36 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Apr 2026 18:09:59 +0000 (14:09 -0400)
When searching prefered hard regs from too strict constraints we can ignore
some alternatives for subsequent operands.  This can result in worse code
generation.  The patch fixes this.

gcc/ChangeLog:

* ira-lives.cc (ira_implicitly_set_insn_hard_regs): Use the same
start prefered for all operand.

gcc/ira-lives.cc

index 04e586343c82220685d8b5b80a29f926ac9d659f..a6b3eff1ab86681abc0f158eb8a14a2d6b710b50 100644 (file)
@@ -956,12 +956,14 @@ ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set,
          mode = (GET_CODE (op) == SCRATCH
                  ? GET_MODE (op) : PSEUDO_REGNO_MODE (regno));
          cl = NO_REGS;
-         for (; (c = *p); p += CONSTRAINT_LEN (c, p))
+         for (alternative_mask curr_preferred = preferred;
+              (c = *p);
+              p += CONSTRAINT_LEN (c, p))
            if (c == '#')
-             preferred &= ~ALTERNATIVE_BIT (0);
+             curr_preferred &= ~ALTERNATIVE_BIT (0);
            else if (c == ',')
-             preferred >>= 1;
-           else if (preferred & 1)
+             curr_preferred >>= 1;
+           else if (curr_preferred & 1)
              {
                cl = reg_class_for_constraint (lookup_constraint (p));
                if (cl != NO_REGS)