diff mbox series

[pushed] aarch64: More SME vs -mtrack-speculation

Message ID mptjzmyjce2.fsf@arm.com
State New
Headers show
Series [pushed] aarch64: More SME vs -mtrack-speculation | expand

Commit Message

Richard Sandiford Feb. 21, 2024, 11:16 a.m. UTC
The sequence to commit a lazy save includes a branch based on
whether TPIDR2_EL0 is zero.  The code assumed that CBZ could
be used for this, but that instruction is forbidden when
-mtrack-speculation is being used.

Tested on aarch64-linux-gnu & pushed.

Richard


gcc/
	* config/aarch64/aarch64.cc (aarch64_mode_emit_local_sme_state):
	Use aarch64_gen_compare_zero_and_branch rather than emitting
	a CBZ directly.

gcc/testsuite/
	* gcc.target/aarch64/sme/locally_streaming_1_ts.c: New test.
	* gcc.target/aarch64/sme/sibcall_7_ts.c: Likewise.
---
 gcc/config/aarch64/aarch64.cc                                 | 3 ++-
 gcc/testsuite/gcc.target/aarch64/sme/locally_streaming_1_ts.c | 3 +++
 gcc/testsuite/gcc.target/aarch64/sme/sibcall_7_ts.c           | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sme/locally_streaming_1_ts.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sme/sibcall_7_ts.c
diff mbox series

Patch

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 8a3aa98a32e..28d1555dada 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -29344,7 +29344,8 @@  aarch64_mode_emit_local_sme_state (aarch64_local_sme_state mode,
       auto tmp_reg = gen_reg_rtx (DImode);
       emit_insn (gen_aarch64_read_tpidr2 (tmp_reg));
       auto label = gen_label_rtx ();
-      auto jump = emit_jump_insn (gen_aarch64_cbeqdi1 (tmp_reg, label));
+      rtx branch = aarch64_gen_compare_zero_and_branch (EQ, tmp_reg, label);
+      auto jump = emit_jump_insn (branch);
       JUMP_LABEL (jump) = label;
       emit_insn (gen_aarch64_tpidr2_save ());
       emit_insn (gen_aarch64_clear_tpidr2 ());
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/locally_streaming_1_ts.c b/gcc/testsuite/gcc.target/aarch64/sme/locally_streaming_1_ts.c
new file mode 100644
index 00000000000..25ac345a6dd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sme/locally_streaming_1_ts.c
@@ -0,0 +1,3 @@ 
+// { dg-options "-O -fomit-frame-pointer -mtrack-speculation" }
+
+#include "locally_streaming_1.c"
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/sibcall_7_ts.c b/gcc/testsuite/gcc.target/aarch64/sme/sibcall_7_ts.c
new file mode 100644
index 00000000000..4b47678bf00
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sme/sibcall_7_ts.c
@@ -0,0 +1,3 @@ 
+// { dg-options "-O2 -mtrack-speculation" }
+
+#include "sibcall_7.c"