[gcc r17-160] [IRA]: Fix implicit preference calculation.
Vladimir Makarov
vmakarov@gcc.gnu.org
Tue Apr 28 18:10:11 GMT 2026
https://gcc.gnu.org/g:9eb8a18033a473b30559862b3ff6a1cac162759b
commit r17-160-g9eb8a18033a473b30559862b3ff6a1cac162759b
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date: Tue Apr 28 08:36:13 2026 -0400
[IRA]: Fix implicit preference calculation.
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.
Diff:
---
gcc/ira-lives.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/gcc/ira-lives.cc b/gcc/ira-lives.cc
index 04e586343c82..a6b3eff1ab86 100644
--- a/gcc/ira-lives.cc
+++ b/gcc/ira-lives.cc
@@ -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)
More information about the Gcc-cvs
mailing list