public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Yang Yujie <yangyujie@loongson.cn>
To: gcc-patches@gcc.gnu.org
Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn,
	panchenghui@loongson.cn, xry111@xry111.site,
	Yang Yujie <yangyujie@loongson.cn>
Subject: [PATCH v2 3/4] LoongArch: add new configure option --with-strict-align-lib
Date: Wed, 30 Aug 2023 09:58:07 +0800	[thread overview]
Message-ID: <20230830015808.19870-4-yangyujie@loongson.cn> (raw)
In-Reply-To: <20230830015808.19870-1-yangyujie@loongson.cn>

LoongArch processors may not support memory accesses without natural
alignments.  Building libraries with -mstrict-align may help with
toolchain binary compatiblity and performance on these implementations
(e.g. Loongson 2K1000LA).

No significant performance degredation is observed on current mainstream
LoongArch processors when the option is enabled.

gcc/ChangeLog:

	* config.gcc: use -mstrict-align for building libraries
	if --with-strict-align-lib is given.
---
 gcc/config.gcc | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 4fae672a3b7..ed70fa63268 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4892,7 +4892,7 @@ case "${target}" in
 		;;
 
 	loongarch*-*)
-		supported_defaults="abi arch tune fpu simd multilib-default"
+		supported_defaults="abi arch tune fpu simd multilib-default strict-align-lib"
 
 		# Local variables
 		unset \
@@ -5089,6 +5089,17 @@ case "${target}" in
 			;;
 		esac
 
+		# Build libraries with -mstrict-align if --with-strict-align-lib is given.
+		case ${with_strict_align_lib} in
+		yes) strict_align_opt="/mstrict-align" ;;
+		""|no)  ;;
+		*)
+			echo "Unknown option: --with-strict-align-lib=${with_strict_align_lib}" 1>&2
+			exit 1
+			;;
+		esac
+
+
 		# Handle --with-multilib-default
 		if echo "${with_multilib_default}" \
 		| grep -E -e '[[:space:]]' -e '//' -e '/$' -e '^/' > /dev/null 2>&1; then
@@ -5250,6 +5261,9 @@ case "${target}" in
 					;;
 			esac
 
+			# Use mstrict-align for building libraries if --with-strict-align-lib is given.
+			loongarch_multilib_list_make="${loongarch_multilib_list_make}${strict_align_opt}"
+
 			# Check for repeated configuration of the same multilib variant.
 			if echo "${elem_abi_base}/${elem_abi_ext}" \
 			 | grep -E "^(${all_abis%|})$" >/dev/null 2>&1; then
-- 
2.36.0


  parent reply	other threads:[~2023-08-30  1:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  1:58 [PATCH 0/4] LoongArch: target configuration interface update Yang Yujie
2023-08-30  1:58 ` [PATCH v2 1/4] LoongArch: improved target configuration interface Yang Yujie
2023-08-30 21:36   ` Joseph Myers
2023-08-31  3:14     ` Yujie Yang
2023-08-31  7:36       ` Yujie Yang
2023-08-31 17:56       ` Joseph Myers
2023-09-01  1:19         ` Yujie Yang
2023-08-30  1:58 ` [PATCH v2 2/4] LoongArch: define preprocessing macros "__loongarch_{arch,tune}" Yang Yujie
2023-08-30  1:58 ` Yang Yujie [this message]
2023-08-30  5:25   ` [PATCH v2 3/4] LoongArch: add new configure option --with-strict-align-lib Xi Ruoyao
2023-08-30  6:51     ` Yujie Yang
2023-08-30  8:22       ` Xi Ruoyao
2023-08-30 10:01         ` Yujie Yang
2023-08-30  1:58 ` [PATCH v2 4/4] LoongArch: support loongarch*-elf target Yang Yujie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230830015808.19870-4-yangyujie@loongson.cn \
    --to=yangyujie@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=panchenghui@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).