public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5584] LoongArch: Don't emit dbar 0x700 if -mld-seq-sa
@ 2023-11-18 20:46 Xi Ruoyao
0 siblings, 0 replies; only message in thread
From: Xi Ruoyao @ 2023-11-18 20:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:181ed726b22afc3e2897447d0631ef0bcc2d106d
commit r14-5584-g181ed726b22afc3e2897447d0631ef0bcc2d106d
Author: Xi Ruoyao <xry111@xry111.site>
Date: Thu Nov 16 09:30:14 2023 +0800
LoongArch: Don't emit dbar 0x700 if -mld-seq-sa
This option (CPUCFG word 0x3 bit 23) means "the hardware guarantee that
two loads on the same address won't be reordered with each other". Thus
we can omit the "load-load" barrier dbar 0x700.
This is only a micro-optimization because dbar 0x700 is already treated
as nop if the hardware supports LD_SEQ_SA.
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_print_operand): Don't
print dbar 0x700 if TARGET_LD_SEQ_SA.
* config/loongarch/sync.md (atomic_load<mode>): Likewise.
Diff:
---
gcc/config/loongarch/loongarch.cc | 2 +-
gcc/config/loongarch/sync.md | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 9a2da89db78..4a6a6e33e67 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -6061,7 +6061,7 @@ loongarch_print_operand (FILE *file, rtx op, int letter)
if (loongarch_cas_failure_memorder_needs_acquire (
memmodel_from_int (INTVAL (op))))
fputs ("dbar\t0b10100", file);
- else
+ else if (!TARGET_LD_SEQ_SA)
fputs ("dbar\t0x700", file);
break;
diff --git a/gcc/config/loongarch/sync.md b/gcc/config/loongarch/sync.md
index 67848d72b87..ce3ce89a61d 100644
--- a/gcc/config/loongarch/sync.md
+++ b/gcc/config/loongarch/sync.md
@@ -119,13 +119,14 @@
case MEMMODEL_SEQ_CST:
return "dbar\t0x11\\n\\t"
"ld.<size>\t%0,%1\\n\\t"
- "dbar\t0x14\\n\\t";
+ "dbar\t0x14";
case MEMMODEL_ACQUIRE:
return "ld.<size>\t%0,%1\\n\\t"
- "dbar\t0x14\\n\\t";
+ "dbar\t0x14";
case MEMMODEL_RELAXED:
- return "ld.<size>\t%0,%1\\n\\t"
- "dbar\t0x700\\n\\t";
+ return TARGET_LD_SEQ_SA ? "ld.<size>\t%0,%1\\n\\t"
+ : "ld.<size>\t%0,%1\\n\\t"
+ "dbar\t0x700";
default:
/* The valid memory order variants are __ATOMIC_RELAXED, __ATOMIC_SEQ_CST,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-18 20:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-18 20:46 [gcc r14-5584] LoongArch: Don't emit dbar 0x700 if -mld-seq-sa Xi Ruoyao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).