[PATCH v2 02/13] aarch64: Make reads/writes to FFR expensive

Alfie Richards <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
With later changes to RDFFR to use subregisters we see forward prop
begin to duplicate FFR reads. This change prevents that.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_insn_cost): Add extra costs
	for FFR reads/writes.
---
 gcc/config/aarch64/aarch64.cc | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 3041a6ee62a..e7522e49efd 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -16989,8 +16989,16 @@ aarch64_frame_allocation_cost (frame_cost_type,
 static int
 aarch64_insn_cost (rtx_insn *insn, bool speed)
 {
+  int extra_cost = 0;
+
+  /* Reads and sets to FFR are expensive. Mark them as such to prevent
+     duplication.  */
+  if (recog_memoized (insn) != -1
+      && get_attr_sve_type (insn) == SVE_TYPE_SVE_FFR)
+    extra_cost = 100;
+
   if (rtx set = single_set (insn))
-    return set_rtx_cost (set, speed);
+    return set_rtx_cost (set, speed) + extra_cost;
 
   /* If the instruction does multiple sets in parallel, use the cost
      of the most expensive set.  This copes with instructions that set
@@ -17005,10 +17013,10 @@ aarch64_insn_cost (rtx_insn *insn, bool speed)
 	  if (GET_CODE (x) == SET)
 	    max_cost = std::max (max_cost, set_rtx_cost (x, speed));
 	}
-      return max_cost;
+      return max_cost + extra_cost;
     }
 
-  return pattern_cost (pat, speed);
+  return pattern_cost (pat, speed) + extra_cost;
 }
 
 /* Implement TARGET_INIT_BUILTINS.  */
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.