Message ID | 20231019140300.50323-1-xry111@xry111.site |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp406512vqb; Thu, 19 Oct 2023 07:05:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJdBPYLyJSSatrVUjS9JwfM9CTEEBCLqWCheed/E1SHJNL+dDSrtk/9wyRcYXftHJmdCve X-Received: by 2002:a05:6214:1d27:b0:66d:9051:82b1 with SMTP id f7-20020a0562141d2700b0066d905182b1mr1452102qvd.31.1697724315693; Thu, 19 Oct 2023 07:05:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697724315; cv=pass; d=google.com; s=arc-20160816; b=f+XQg83rx4Ncek8h8PX1Uyjtw+JRz9edcEE8592fgIFKJiZniJGPotoPnXdtGTBaYe /FFwI9tqQVhL9N9W7gr43Jv91nyXcqMLQjlp725zy63W4Ud6uyi2UBBz4uajlOBOzTDp KEaMwF6Nm+wflgUVuVVj3ORxQx3nso5cKnafUE4clBYJqbZV3VrpVcmN3vbsfVVQQmyM waCaGwoOAS2/rDmkqbO8i0My4PHlHlMtuNlKB4bDxedVhf8J/22XaOaSTu72NB09Orm+ xany/7cpkX6RughwD8IAS+K+uO8UBXkSOuLcLSgZIi8z25IhkhBiFcDInuwA3hpqI9Bg QFpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=5nBbCezm98e3Al9PCZ+I94SiibFytun+iP0H8+GHSjM=; fh=Q6zU0KPK9mkW4WcCQLO/dI9yShCKJrND2oM6Xx6eTlQ=; b=Bqltrvi8zONctz5RR23urS2kSqv1rfp9MRlEJXuI2mDx56V89wyd+eQUoBNzze4FVv GMZpRlLjrfMV4Mfdp5pvWhdhykfpPi2a/HQeSUgWsOUMlvo+XSJQGzj8cgvRESa1CcoI 3UuDYtTP3AVCvaepDE0FPEVCIvwF4+ROLkdkiD4iyx1s/lwxztl33ev+4W48q+6VaECx sdGIe6ox6Za1Pr2i8NOooIlD8+5iCSQhMfaBNVvZ8ssgRcrEziD2Vn8XQhUontpRn8CN mTG1qLhi8a5rkHG2sttUXp5aqLozuigdhj1ojJa/vvigx2wBPvcjLhhnZcIVfavRUGAj e/kQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=jqNHzrQJ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id oq1-20020a056214460100b0065b159315ecsi1662747qvb.519.2023.10.19.07.05.15 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:05:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=jqNHzrQJ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 06B3B3857712 for <ouuuleilei@gmail.com>; Thu, 19 Oct 2023 14:04:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 95AA93858438 for <gcc-patches@gcc.gnu.org>; Thu, 19 Oct 2023 14:03:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95AA93858438 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 95AA93858438 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.208.246.23 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697724207; cv=none; b=o4+gpbmOgj85Uv7Oc74S1L3wcSn+XPrs5pYNRhZ65Sa8gLG8UDYmSKdNT4S1aXT0EFlNOeGttOh1JA6smRSm5vUuPByuaCWhAetrVBoOMnrI66qUR7u9pu4H0MOc96co62yveOTcHIBk7wMvZsXqin3nAUJJDFM8eESdKCn6N80= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697724207; c=relaxed/simple; bh=SAPyvHAU6wKWzm8NQwdmIjcBK9Qjs0OOzusEQtwZ/bs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ptM7i9cEoCqapOiCpfX7jzColLxJCWQIjaptY92kRFFe+Cu4wjwkOEdvxhXXavWKVeQomtFeb3Lr56OtRbzj/5ZWJH304FMcAsQlxgBoCZ5vC/Tn2zjcmGUSyRDNRBpfBwQoJ+TVFnOBkSG8y7Tiu5ty2F/7qIC0zzdyVvBeaz0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1697724201; bh=SAPyvHAU6wKWzm8NQwdmIjcBK9Qjs0OOzusEQtwZ/bs=; h=From:To:Cc:Subject:Date:From; b=jqNHzrQJpt3smwB2VIgVAYV4pbEsyf0ZBjakZSzTKZiXw3sqyS6OdPxhs8S4Zi7wM uwmYN51M+RpHaB82TMLkRDE3KY9AMFuWQ4WHlZVSkP7FNelEldgztuz3BaXHEpBV1G OAEK1wHA6Ii8JocQsChZ2Qm/E8eicuuP4eW5GJA8= Received: from stargazer.. (unknown [IPv6:240e:358:1126:f000:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id E6EAA66AF4; Thu, 19 Oct 2023 10:03:16 -0400 (EDT) From: Xi Ruoyao <xry111@xry111.site> To: gcc-patches@gcc.gnu.org Cc: chenglulu <chenglulu@loongson.cn>, i@xen0n.name, xuchenghua@loongson.cn, mengqinggang <mengqinggang@loongson.cn>, Xi Ruoyao <xry111@xry111.site> Subject: [PATCH 0/5] LoongArch: Better balance between relaxation and scheduling Date: Thu, 19 Oct 2023 22:02:55 +0800 Message-ID: <20231019140300.50323-1-xry111@xry111.site> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780192972103014675 X-GMAIL-MSGID: 1780192972103014675 |
Series |
LoongArch: Better balance between relaxation and scheduling
|
|
Message
Xi Ruoyao
Oct. 19, 2023, 2:02 p.m. UTC
For relaxation we are now generating assembler macros for symbolic addresses everywhere, but this is limiting scheduling and there are known situations where the relaxation cannot improve the code. 1. When we are performing LTO during a final link and the linker plugin is used, la.global won't be relaxed because they reference to an external or preemptable symbol. 2. The linker currently do not relax la.tls.*. 3. For la.local + ld/st pairs, if the address is only used once, emitting pcalau12i + ld/st is always not worse than relying on linker relaxation. Add -mexplicit-relocs=auto to allow the compiler to use explicit relocs for these cases, but assembler macros for other cases. Use it as the default if the assembler supports both explicit relocs and relaxation. LTO-bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? Xi Ruoyao (5): LoongArch: Add enum-style -mexplicit-relocs= option LoongArch: Use explicit relocs for GOT access when -mexplicit-relocs=auto and LTO during a final link with linker plugin LoongArch: Use explicit relocs for TLS access with -mexplicit-relocs=auto LoongArch: Use explicit relocs for addresses only used for one load or store with -mexplicit-relocs=auto and -mcmodel={normal,medium} LoongArch: Document -mexplicit-relocs={auto,none,always} .../loongarch/genopts/loongarch-strings | 6 + gcc/config/loongarch/genopts/loongarch.opt.in | 21 ++- gcc/config/loongarch/loongarch-def.h | 6 + gcc/config/loongarch/loongarch-protos.h | 1 + gcc/config/loongarch/loongarch-str.h | 5 + gcc/config/loongarch/loongarch.cc | 75 ++++++++-- gcc/config/loongarch/loongarch.h | 3 + gcc/config/loongarch/loongarch.md | 128 +++++++++++++++++- gcc/config/loongarch/loongarch.opt | 21 ++- gcc/config/loongarch/predicates.md | 15 +- gcc/doc/invoke.texi | 37 +++-- .../loongarch/explicit-relocs-auto-lto.c | 26 ++++ ...-relocs-auto-single-load-store-no-anchor.c | 6 + .../explicit-relocs-auto-single-load-store.c | 14 ++ .../explicit-relocs-auto-tls-ld-gd.c | 9 ++ .../explicit-relocs-auto-tls-le-ie.c | 6 + 16 files changed, 343 insertions(+), 36 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-lto.c create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store-no-anchor.c create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store.c create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-le-ie.c
Comments
Pushed r14-{4848..4852}. On Thu, 2023-10-19 at 22:02 +0800, Xi Ruoyao wrote: > For relaxation we are now generating assembler macros for symbolic > addresses everywhere, but this is limiting scheduling and there are > known situations where the relaxation cannot improve the code. > > 1. When we are performing LTO during a final link and the linker plugin > is used, la.global won't be relaxed because they reference to an > external or preemptable symbol. > 2. The linker currently do not relax la.tls.*. > 3. For la.local + ld/st pairs, if the address is only used once, > emitting pcalau12i + ld/st is always not worse than relying on linker > relaxation. > > Add -mexplicit-relocs=auto to allow the compiler to use explicit relocs > for these cases, but assembler macros for other cases. Use it as the > default if the assembler supports both explicit relocs and relaxation. > > LTO-bootstrapped and regtested on loongarch64-linux-gnu. Ok for trunk? > > Xi Ruoyao (5): > LoongArch: Add enum-style -mexplicit-relocs= option > LoongArch: Use explicit relocs for GOT access when > -mexplicit-relocs=auto and LTO during a final link with linker > plugin > LoongArch: Use explicit relocs for TLS access with > -mexplicit-relocs=auto > LoongArch: Use explicit relocs for addresses only used for one load or > store with -mexplicit-relocs=auto and -mcmodel={normal,medium} > LoongArch: Document -mexplicit-relocs={auto,none,always} > > .../loongarch/genopts/loongarch-strings | 6 + > gcc/config/loongarch/genopts/loongarch.opt.in | 21 ++- > gcc/config/loongarch/loongarch-def.h | 6 + > gcc/config/loongarch/loongarch-protos.h | 1 + > gcc/config/loongarch/loongarch-str.h | 5 + > gcc/config/loongarch/loongarch.cc | 75 ++++++++-- > gcc/config/loongarch/loongarch.h | 3 + > gcc/config/loongarch/loongarch.md | 128 +++++++++++++++++- > gcc/config/loongarch/loongarch.opt | 21 ++- > gcc/config/loongarch/predicates.md | 15 +- > gcc/doc/invoke.texi | 37 +++-- > .../loongarch/explicit-relocs-auto-lto.c | 26 ++++ > ...-relocs-auto-single-load-store-no-anchor.c | 6 + > .../explicit-relocs-auto-single-load-store.c | 14 ++ > .../explicit-relocs-auto-tls-ld-gd.c | 9 ++ > .../explicit-relocs-auto-tls-le-ie.c | 6 + > 16 files changed, 343 insertions(+), 36 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-lto.c > create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store-no-anchor.c > create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-single-load-store.c > create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c > create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-auto-tls-le-ie.c >