aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2025-02-05 15:35:13 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2025-02-05 15:35:13 +0000
commit50a31b6765fe17aee22a1fc1457c762a53140c8e (patch)
tree83800d9cff894a92bdff367b5a06139f74068b4e
parent6f95af4f22b641fbb3509f1436bce811d4e4acad (diff)
downloadgcc-50a31b6765fe17aee22a1fc1457c762a53140c8e.zip
gcc-50a31b6765fe17aee22a1fc1457c762a53140c8e.tar.gz
gcc-50a31b6765fe17aee22a1fc1457c762a53140c8e.tar.bz2
aarch64: Fix sve/acle/general/ldff1_8.c failures
gcc.target/aarch64/sve/acle/general/ldff1_8.c and gcc.target/aarch64/sve/ptest_1.c were failing because the aarch64 port was giving a zero (unknown) cost to instructions that compute two results in parallel. This was latent until r15-1575-gea8061f46a30, which fixed rtl-ssa to treat zero costs as unknown. A long-standing todo here is to make insn_cost derive costs from md information, rather than having to write a lot of matching code in aarch64_rtx_costs. But that's not something we can do for GCC 15. This patch instead treats the cost of a PARALLEL as being the maximum cost of its constituent sets. I don't like this very much, since it isn't really target-specific behaviour. If it were stage 1, I'd be trying to change pattern_cost instead. gcc/ * config/aarch64/aarch64.cc (aarch64_insn_cost): Give PARALLELs the same cost as the costliest SET.
-rw-r--r--gcc/config/aarch64/aarch64.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 16754fa..c1e4020 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -15889,7 +15889,24 @@ aarch64_insn_cost (rtx_insn *insn, bool speed)
{
if (rtx set = single_set (insn))
return set_rtx_cost (set, speed);
- return pattern_cost (PATTERN (insn), speed);
+
+ /* If the instruction does multiple sets in parallel, use the cost
+ of the most expensive set. This copes with instructions that set
+ the flags to a useful value as a side effect. */
+ rtx pat = PATTERN (insn);
+ if (GET_CODE (pat) == PARALLEL)
+ {
+ int max_cost = 0;
+ for (int i = 0; i < XVECLEN (pat, 0); ++i)
+ {
+ rtx x = XVECEXP (pat, 0, i);
+ if (GET_CODE (x) == SET)
+ max_cost = std::max (max_cost, set_rtx_cost (x, speed));
+ }
+ return max_cost;
+ }
+
+ return pattern_cost (pat, speed);
}
/* Implement TARGET_INIT_BUILTINS. */