Re: [PATCH v2] bitint: Lower the partial limbs of extended _BitInts with m_limb_type

2025-09-09 Thread Yang Yujie
v1 -> v2: - Add a new test for LoongArch. Check if extensions are omitted when loading large/huge parameters from the stack.

Re: [PATCH v2] bitint: Lower the partial limbs of extended _BitInts with m_limb_type

2025-09-08 Thread Yang Yujie
On Tue, Sep 09, 2025 at 02:18:54PM +0800, Yang Yujie wrote: > v1 -> v2: > > - Add a new test for LoongArch. Check if extensions are omitted > when loading large/huge parameters from the stack. Bootstrapped and tested on x86_64-linux-gnu and loongarch64-linux-gnu. Ok for trunk?

[PATCH v2] bitint: Lower the partial limbs of extended _BitInts with m_limb_type

2025-09-08 Thread Yang Yujie
Lower the partial limbs of extended _BitInts like the full limbs for most operations, so that explicit extensions can be inserted only where they are really needed. gcc/ChangeLog: * gimple-lower-bitint.cc (struct bitint_large_huge): Remove the abi_load_p parameter of limb_access.

Re: [PATCH] bitint: Fix regressions [PR117599]

2025-09-05 Thread Yang Yujie
On Tue, Sep 02, 2025 at 04:51:37PM GMT, Jakub Jelinek wrote: > On Tue, Aug 19, 2025 at 07:37:29PM +0800, Yang Yujie wrote: > > This patch fixes regressions of the gcc.dg/torture/bitint-* tests > > caused by r16-3036-ga76a032354ee48 with --enable-checking=all. > > > > Th

[PATCH] bitint: Lower the partial limbs of extended _BitInts with m_limb_type.

2025-09-04 Thread Yang Yujie
Lower the partial limbs of extended _BitInts like the full limbs for most operations, so that explicit extensions can be inserted only where they are really needed. gcc/ChangeLog: * gimple-lower-bitint.cc (struct bitint_large_huge): Remove the abi_load_p parameter of limb_access.

[PATCH] bitint: Fix regressions [PR117599]

2025-08-19 Thread Yang Yujie
This patch fixes regressions of the gcc.dg/torture/bitint-* tests caused by r16-3036-ga76a032354ee48 with --enable-checking=all. The errors are similar to the following: ../../gcc/testsuite/gcc.dg/torture/bitint-14.c:54:1: error: type mismatch in 'array_ref' unsigned long _42 = VIEW_CONVERT_E

[PATCH v6 0/4] LoongArch: Add support for _BitInt [PR117599]

2025-08-06 Thread Yang Yujie
-linux-gnu. Yang Yujie (4): bitint: Avoid extending ABI-extended large/huge _BitInts on load bitint: Make sure BEXTC checks extension when optimized bitint: Zero-extend the result of a signed->unsigned widening cast bitint: Do not optimize away conversion to _BitInt before a VCE gcc

Re: [PATCH v6 1/4] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-08-06 Thread Yang Yujie
On Wed, Aug 06, 2025 at 11:58:09AM GMT, Jakub Jelinek wrote: > On Wed, Aug 06, 2025 at 05:57:49PM +0800, Yang Yujie wrote: > > This patch also make casts of ABI-extended large/huge _BitInts > > behave the same as the small/middle case, i.e. no-op for casts > > to a higher p

[PATCH v6 4/4] bitint: Do not optimize away conversion to _BitInt before a VCE

2025-08-06 Thread Yang Yujie
A _BitInt value may rely on a conversion to become properly extended. So a conversion to _BitInt is not trivially removable even if the types of the result and the operand have the same precision and size. This patch fixes gcc.dg/torture/bitint-64.c at -O2 on LoongArch, which fails because extensi

[PATCH v6 1/4] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-08-06 Thread Yang Yujie
This patch also make casts of ABI-extended large/huge _BitInts behave the same as the small/middle case, i.e. no-op for casts to a higher precision _BitInt with the same number of limbs / extension for casts that turns a full top limb into a partial limb. This conveniently helps keep some code with

[PATCH v6 3/4] bitint: Zero-extend the result of a signed->unsigned widening cast

2025-08-06 Thread Yang Yujie
A widening cast from a signed _BitInt operand to an unsigned _BitInt type involves filling the extra limb(s) with sign extension. On a target that wants _BitInts extended in memory, if this unsigned type has a partial limb, the unused part of it should be zeroed. e.g. Assuming limb_mode == E_DImod

[PATCH v6 2/4] bitint: Make sure BEXTC checks extension when optimized

2025-08-06 Thread Yang Yujie
In BEXTC, whether a _BitInt object is properly extended is examined by a value comparison against a copied object in a wider _BitInt type that utilizes all of the partial limb. Since the (implicit) conversion to the wider type may be optimized away now and cause the result of the comparison to alw

Re: [PATCH v5 4/9] bitint: Make sure BEXTC checks extension when optimized

2025-08-05 Thread Yang Yujie
On Tue, Aug 05, 2025 at 11:58:45AM GMT, Jakub Jelinek wrote: > On Sat, Aug 02, 2025 at 05:14:21PM +0800, Yang Yujie wrote: > > In BEXTC, whether a _BitInt object is properly extended is examined > > by a value comparison against a copied object in a wider _BitInt > > type tha

Re: [PATCH v5 6/9] bitint: Zero-extend the result of a signed->unsigned widening cast

2025-08-05 Thread Yang Yujie
On Tue, Aug 05, 2025 at 12:22:17PM GMT, Jakub Jelinek wrote: > On Sat, Aug 02, 2025 at 05:14:23PM +0800, Yang Yujie wrote: > > A widening cast from a signed _BitInt operand to an unsigned _BitInt > > type involves filling the extra limb(s) with sign extension. > > On a targe

Re: [PATCH v5 3/9] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-08-05 Thread Yang Yujie
On Tue, Aug 05, 2025 at 12:26:08PM GMT, Jakub Jelinek wrote: > On Tue, Aug 05, 2025 at 06:21:40PM +0800, Yang Yujie wrote: > > On Tue, Aug 05, 2025 at 11:49:42AM GMT, Jakub Jelinek wrote: > > > On Sat, Aug 02, 2025 at 05:14:20PM +0800, Yang Yujie wrote: > > > > In Lo

Re: [PATCH v5 5/9] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-08-05 Thread Yang Yujie
On Tue, Aug 05, 2025 at 12:04:56PM GMT, Jakub Jelinek wrote: > On Sat, Aug 02, 2025 at 05:14:22PM +0800, Yang Yujie wrote: > > tree > > -bitint_large_huge::limb_access (tree type, tree var, tree idx, bool > > write_p) > > +bitint_large_huge::limb_access (tree typ

Re: [PATCH v5 3/9] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-08-05 Thread Yang Yujie
On Tue, Aug 05, 2025 at 11:49:42AM GMT, Jakub Jelinek wrote: > On Sat, Aug 02, 2025 at 05:14:20PM +0800, Yang Yujie wrote: > > In LoongArch psABI, large _BitInt(N) (N > 64) objects are only > > extended to fill the highest 8-byte chunk that contains any used bit, > > but

[PATCH v5 6/9] bitint: Zero-extend the result of a signed->unsigned widening cast

2025-08-02 Thread Yang Yujie
A widening cast from a signed _BitInt operand to an unsigned _BitInt type involves filling the extra limb(s) with sign extension. On a target that wants _BitInts extended in memory, if this unsigned type has a partial limb, the unused part of it should be zeroed. e.g. Assuming limb_mode == E_DImod

[PATCH v5 4/9] bitint: Make sure BEXTC checks extension when optimized

2025-08-02 Thread Yang Yujie
In BEXTC, whether a _BitInt object is properly extended is examined by a value comparison against a copied object in a wider _BitInt type that utilizes all of the partial limb. Since the (implicit) conversion to the wider type may be optimized away and cause the result of the comparison to always

[PATCH v5 9/9] LoongArch: Add support for _BitInt [PR117599]

2025-08-02 Thread Yang Yujie
This patch adds support for C23's _BitInt for LoongArch. >From the LoongArch psABI[1]: > _BitInt(N) objects are stored in little-endian order in memory > and are signed by default. > > For N ≤ 64, a _BitInt(N) object have the same size and alignment > of the smallest fundamental integral type tha

[PATCH v5 3/9] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-08-02 Thread Yang Yujie
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, an

[PATCH v5 5/9] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-08-02 Thread Yang Yujie
This patch also make casts of ABI-extended large/huge _BitInts behave the same as the small/middle case, i.e. no-op for casts to a higher precision _BitInt with the same number of limbs / extension for casts that turns a full top limb into a partial limb. This conveniently helps keep some code with

[PATCH v5 8/9] LoongArch: Prioritize target-specific makefile fragments

2025-08-02 Thread Yang Yujie
libgcc/ChangeLog: * config.host: Remove unused code. Include LoongArch-specific tmake_files after the OS-specific ones. --- libgcc/config.host | 31 --- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libgcc/config.host b/libgcc/config.h

[PATCH v5 7/9] bitint: Do not optimize away conversion to _BitInt before a VCE

2025-08-02 Thread Yang Yujie
A _BitInt value may rely on a conversion to become properly extended. So a conversion to _BitInt is not trivially removable even if the types of the result and the operand have the same precision and size. This patches fixes gcc.dg/torture/bitint-64.c at -O2 on LoongArch, which fails because exten

[PATCH v5 2/9] expand: Reduce unneeded _BitInt extensions

2025-08-02 Thread Yang Yujie
For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided. gcc/ChangeLog: * expr.cc (expand_expr_real_1): Do not call r

[PATCH v5 1/9] bitint: Allow mode promotion of _BitInt types

2025-08-02 Thread Yang Yujie
For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. gcc/ChangeLog: * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same. --- gcc/explow.cc

[PATCH v5 0/9] LoongArch: Add support for _BitInt [PR117599]

2025-08-02 Thread Yang Yujie
parision of the partial limbs. This series was bootstrapped and tested on x86_64-linux-gnu and loongarch64-linux-gnu. Yang Yujie (9): bitint: Allow mode promotion of _BitInt types expand: Reduce unneeded _BitInt extensions bitint: Allow unused bits when testing extended _BitInt ABIs bitint:

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 01:07:32PM +0200, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 06:52:40PM +0800, Yang Yujie wrote: > > I'm OK with your implementation. Just curious, do you mean that > > memcmp shouldn't be used on "(x)" at all? > > If there a

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 12:37:33PM GMT, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 06:24:42PM +0800, Yang Yujie wrote: > > On Wed, Jul 30, 2025 at 12:19:24PM GMT, Jakub Jelinek wrote: > > > On Wed, Jul 30, 2025 at 06:15:56PM +0800, Yang Yujie wrote: > > > > So wo

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 12:19:24PM GMT, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 06:15:56PM +0800, Yang Yujie wrote: > > So wouldn't it be simpler if I just change the comparison in my patch into > > a memcmp? This works regardless of how comparison is implemented. >

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 11:28:11AM GMT, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 04:56:06PM +0800, Yang Yujie wrote: > > I'm not sure if this is correct, but isn't accessing __x in its own type > > after do_copy already an undefined behavior? > > > > N

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 10:17:42AM GMT, Jakub Jelinek wrote: > On Wed, Jul 30, 2025 at 10:16:06AM +0200, Jakub Jelinek wrote: > > Or maybe better > > _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x; > > int __y = S (x); > > do_copy (&__x, &(x), sizeof (__x)); > > if (__y < PROMOTED_SIZE (x) *

Re: [PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 09:37:10AM GMT, Jakub Jelinek wrote: > On Fri, Jul 25, 2025 at 10:53:39AM +0800, Yang Yujie wrote: > > In BEXTC, whether a _BitInt object is properly extended is examined > > by a value comparison against a copied object in a wider _BitInt > > type tha

Re: [PATCH v4 4/9] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-07-30 Thread Yang Yujie
On Wed, Jul 30, 2025 at 09:29:49AM GMT, Jakub Jelinek wrote: > On Fri, Jul 25, 2025 at 10:53:37AM +0800, Yang Yujie wrote: > > + > >addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (var)); > >if (as != TYPE_ADDR_SPACE (ltype)) > > ltype = build_qualified_typ

[PATCH v4 8/9] LoongArch: Prioritize target-specific makefile fragments

2025-07-24 Thread Yang Yujie
libgcc/ChangeLog: * config.host: Remove unused code. Include LoongArch-specific tmake_files after the OS-specific ones. --- libgcc/config.host | 31 --- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libgcc/config.host b/libgcc/config.h

[PATCH v4 9/9] LoongArch: Add support for _BitInt [PR117599]

2025-07-24 Thread Yang Yujie
This patch adds support for C23's _BitInt for LoongArch. >From the LoongArch psABI[1]: > _BitInt(N) objects are stored in little-endian order in memory > and are signed by default. > > For N ≤ 64, a _BitInt(N) object have the same size and alignment > of the smallest fundamental integral type tha

[PATCH v4 7/9] bitint: Do not optimize away conversion to _BitInt before a VCE

2025-07-24 Thread Yang Yujie
A _BitInt value may rely on a conversion to become properly extended. So a conversion to _BitInt is not trivially removable even if the types of the result and the operand have the same precision and size. This patches fixes gcc.dg/torture/bitint-64.c at -O2 on LoongArch, which fails because exten

[PATCH v4 5/9] bitint: Zero-extend the result of a signed->unsigned widening cast

2025-07-24 Thread Yang Yujie
A widening cast from a signed _BitInt operand to an unsigned _BitInt type involves filling the extra limb(s) with sign extension. On a target that wants _BitInts extended in memory, if this unsigned type has a partial limb, the unused part of it should be zeroed. e.g. Assuming limb_mode == E_DImod

[PATCH v4 3/9] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-07-24 Thread Yang Yujie
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, an

[PATCH v4 0/9] LoongArch: Add support for _BitInt [PR117599]

2025-07-24 Thread Yang Yujie
al limb. 4. Other fixes from Jakub's review on v3. This series has been bootstrapped and tested on x86_64-linux-gnu, and tested on loongarch64-linux-gnu (right now bootstrap on LoongArch do not pass due to some strict checks failing in final.cc). Yang Yujie (9): bitint: Allow mode promo

[PATCH v4 6/9] bitint: Make sure BEXTC checks extension when optimized

2025-07-24 Thread Yang Yujie
In BEXTC, whether a _BitInt object is properly extended is examined by a value comparison against a copied object in a wider _BitInt type that utilizes all of the partial limb. Since the (implicit) conversion to the wider type may be optimized away and cause the result of the comparison to always

[PATCH v4 4/9] bitint: Avoid extending ABI-extended large/huge _BitInts on load

2025-07-24 Thread Yang Yujie
This patch also make casts of ABI-extended large/huge _BitInts behave the same as the small/middle case, i.e. no-op for casts to a higher precision _BitInt with the same number of limbs / extension for casts that turns a full top limb into a partial limb. This conveniently helps keep some code with

[PATCH v4 2/9] expand: Reduce unneeded _BitInt extensions

2025-07-24 Thread Yang Yujie
For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided. gcc/ChangeLog: * expr.cc (expand_expr_real_1): Do not call r

[PATCH v4 1/9] bitint: Allow mode promotion of _BitInt types

2025-07-24 Thread Yang Yujie
For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. gcc/ChangeLog: * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same. --- gcc/explow.cc

Re: [PATCH v3 6/6] LoongArch: Add support for _BitInt [PR117599]

2025-06-27 Thread Yang Yujie
On Fri, Jun 27, 2025 at 10:00:00AM GMT, Jakub Jelinek wrote: > On Fri, Jun 27, 2025 at 03:33:35PM +0800, Yang Yujie wrote: > > @@ -11291,6 +11296,13 @@ expand_expr_real_1 (tree exp, rtx target, > > machine_mode tmode, > >type = TREE_TYPE (exp); > >mode = TYPE_MO

[PATCH v3 2/6] expand: Reduce unneeded _BitInt extensions

2025-06-27 Thread Yang Yujie
For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided. gcc/ChangeLog: * expr.cc (expand_expr_real_1): Do not call r

[PATCH v3 0/6] LoongArch: Add support for _BitInt [PR117599]

2025-06-27 Thread Yang Yujie
. (Note: It seems that atomic fetch/op doesn't work for _BitInts even they have the right size, CAS loop is always used when handling modification. Fixing this later.) This series has been bootstrapped and regtested on loongarch64-linux-gnu and x86_64-linux-gnu. Yang Yujie (6): bitint: Allow

[PATCH v3 6/6] LoongArch: Add support for _BitInt [PR117599]

2025-06-27 Thread Yang Yujie
This patch adds support for C23's _BitInt for LoongArch. >From the LoongArch psABI[1]: > _BitInt(N) objects are stored in little-endian order in memory > and are signed by default. > > For N ≤ 64, a _BitInt(N) object have the same size and alignment > of the smallest fundamental integral type tha

[PATCH v3 4/6] bitint: Do not optimize away conversion to _BitInt before a VCE

2025-06-27 Thread Yang Yujie
A _BitInt value may rely on a conversion to become properly extended. So a conversion to _BitInt is not trivially removable even if the types of the result and the operand have the same precision and size. This patches fixes gcc.dg/torture/bitint-64.c at -O2 on LoongArch, which fails because exten

[PATCH v3 5/6] LoongArch: Prioritize target-specific makefile fragments

2025-06-27 Thread Yang Yujie
libgcc/ChangeLog: * config.host: Remove unused code. Include LoongArch-specific tmake_files after the OS-specific ones. --- libgcc/config.host | 31 --- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libgcc/config.host b/libgcc/config.h

[PATCH v3 3/6] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-06-27 Thread Yang Yujie
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, an

[PATCH v3 1/6] bitint: Allow mode promotion of _BitInt types

2025-06-27 Thread Yang Yujie
For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. gcc/ChangeLog: * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same. --- gcc/explow.cc

Re: [PATCH v2 5/7] LoongArch: Add support for _BitInt [PR117599]

2025-06-19 Thread Yang Yujie
On Thu, Jun 19, 2025 at 12:32:57PM GMT, Jakub Jelinek wrote: > As mentioned in another mail, please follow what aarch64 is doing here (at > least unless you explain how it violates your psABI): > if (n <= 8) > info->limb_mode = QImode; > else if (n <= 16) > info->limb_mode = HImode; >

Re: [PATCH v2 5/7] LoongArch: Add support for _BitInt [PR117599]

2025-06-19 Thread Yang Yujie
On Thu, Jun 19, 2025 at 01:18:10PM GMT, Jakub Jelinek wrote: > On Thu, Jun 19, 2025 at 07:13:07PM +0800, Yang Yujie wrote: > > On Thu, Jun 19, 2025 at 12:32:57PM GMT, Jakub Jelinek wrote: > > > As mentioned in another mail, please follow what aarch64 is doing here (at >

[PATCH v2 6/7] bitint: Allow unused bits when testing extended _BitInt ABIs

2025-06-19 Thread Yang Yujie
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, an

[PATCH v2 3/7] bitint: Extend the new value before atomic exchange

2025-06-19 Thread Yang Yujie
For targets that have extended bitints, we need to ensure these are extended before writing to the memory, including via atomic exchange. gcc/c-family/ChangeLog: * c-common.cc (resolve_overloaded_atomic_exchange): Extend _BitInts before atomic exchange if needed. (resolve_

[PATCH v2 7/7] expand: Reduce unneeded _BitInt extensions

2025-06-19 Thread Yang Yujie
For targets that set the "extended" flag in TARGET_C_BITINT_TYPE_INFO, we assume small _BitInts to be internally extended after arithmetic operations. In this case, an extra extension during RTL expansion can be avoided. gcc/ChangeLog: * expr.cc (expand_expr_real_1): Do not call r

[PATCH v2 0/7] LoongArch: Add support for _BitInt [PR117599]

2025-06-19 Thread Yang Yujie
-bitint.cc, maybe later. 3. Add symbol versions (GCC_16.0.0) for bitint helper functions in libgcc. This series has been bootstrapped and regtested on loongarch64-linux-gnu and x86_64-linux-gnu. Yang Yujie (7): bitint: Allow mode promotion of _BitInt types bitint: Allow different limb_mode

[PATCH v2 2/7] bitint: Allow different limb_mode and abi_limb_mode in more cases

2025-06-19 Thread Yang Yujie
abi_limb_mode and limb_mode were asserted to be the same when the target has different endianness for limbs in _BitInts and words in objects. Otherwise, this assertion also held when the TYPE_PRECISION of _BitInt type being laid out is less than or equal to the precision of abi_limb_mode. But in

[PATCH v2 4/7] LoongArch: Prioritize target-specific makefile fragments

2025-06-19 Thread Yang Yujie
libgcc/ChangeLog: * config.host: Remove unused code. Include LoongArch-specific tmake_files after the OS-specific ones. --- libgcc/config.host | 31 --- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/libgcc/config.host b/libgcc/config.h

[PATCH v2 5/7] LoongArch: Add support for _BitInt [PR117599]

2025-06-19 Thread Yang Yujie
This patch adds support for C23's _BitInt for LoongArch. >From the LoongArch psABI[1]: > _BitInt(N) objects are stored in little-endian order in memory > and are signed by default. > > For N ≤ 64, a _BitInt(N) object have the same size and alignment > of the smallest fundamental integral type tha

[PATCH v2 1/7] bitint: Allow mode promotion of _BitInt types

2025-06-19 Thread Yang Yujie
For targets that treat small _BitInts like the fundamental integral types, we should allow their machine modes to be promoted in the same way. gcc/ChangeLog: * explow.cc (promote_function_mode): Add a case for small/medium _BitInts. (promote_mode): Same. --- gcc/explow.cc

Re: [RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-21 Thread Yang Yujie
On Wed, May 21, 2025 at 11:48:08AM GMT, Jakub Jelinek wrote: > In gimple-lower-bitint.cc I'd strongly prefer to differentiate between > changes required to get info->extended working correctly (that is what > should be committed first, and right now should include the LSHIFT_EXPR in > lower_shift_s

Re: [RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-21 Thread Yang Yujie
On Wed, May 21, 2025 at 09:21:40AM GMT, Jakub Jelinek wrote: > > The existing testsuite never tests whether the padding bits are sign or zero > extended or contain unknown values. > In the s390x patch, info->extended is set to true, yet all bitint tests but > bitint-64.c at -O3 pass. > > So, I'm

Re: [RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-20 Thread Yang Yujie
On Tue, May 20, 2025 at 03:44:09PM GMT, Jakub Jelinek wrote: > I'd suggest working on it incrementally rather than with a full patch set. > In one or multiple patches handle the promote_mode stuff, the atomic > extension and expr.cc changes with the feedback incorporated. Ok. > For gimple-lower-b

Re: [RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-20 Thread Yang Yujie
On Tue, May 20, 2025 at 09:55:04PM GMT, Xi Ruoyao wrote: > On Tue, 2025-05-20 at 15:44 +0200, Jakub Jelinek wrote: > > > Specifically, the tests told me to extend (thought "truncate" > > > was kind of an equivalent word) the output of left shift, plus/minus, > > > > Truncation is the exact opposit

Re: [RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-20 Thread Yang Yujie
Hi Jakub, Thanks for the quick review. Aside from code formatting issues, can I conclude that you suggest we should rebase this onto your new big-endian support patch? Or do you think it's necessary to add big-endian && extended support together? > Are you sure all those changes were really nec

[RFC PATCH 0/3] _BitInt(N) support for LoongArch

2025-05-19 Thread Yang Yujie
o be made to gimple lowering and expand. This series has been bootstrapped and regtested with x86_64-linux-gnu and loongarch64-linux-gnu (against a version that leaves the partial limbs undefined). Please help us find if there's something we've missed. Thanks, Yujie Yang Yujie (3):

[RFC PATCH 1/3] bitint: Support ABI-extended _BitInt(N)

2025-05-19 Thread Yang Yujie
The padding bits of _BitInt(N) are undefined in the x86-64 and the aarch64 ABI. In general, the current lowering and expand process perform truncations when taking a _BitInt value as input, while leaving them as-is in the output. By adding truncation on the output side, we can define psABIs (e.g.

[RFC PATCH 2/3] bitint: Allow wider abi_limb_mode than limb_mode during layout

2025-05-19 Thread Yang Yujie
gcc/ChangeLog: * stor-layout.cc (layout_type): Allow limb_mode to be DImode while abi_limb_mode is TImode for _BitInt(N), N > 64. --- gcc/stor-layout.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc index 18b5af56124.

[RFC PATCH 3/3] LoongArch: Add support for _BitInt [PR117599]

2025-05-19 Thread Yang Yujie
This patch adds support for C23's _BitInt for LoongArch. Though there's not an official psABI definition, our plan is to have 16-byte alignment for N > 64 and the padding bits sign/zero-extended when passed between procedures. One exception would be "unsigned _BitInt(32)". To match the behavior o

[PATCH] LoongArch: Fix awk / sed usage for compatibility

2025-04-06 Thread Yang Yujie
Tested with nawk, mawk, and gawk. gcc/ChangeLog: * config/loongarch/genopts/gen-evolution.awk: remove usage of "asort". * config/loongarch/genopts/genstr.sh: replace sed with awk. --- .../loongarch/genopts/gen-evolution.awk | 12 +++- gcc/config/loongarch/genopts/ge

[PATCH 1/1] LoongArch: Remove gawk extension from a generator script.

2024-07-22 Thread Yang Yujie
gcc/ChangeLog: * config/loongarch/genopts/gen-evolution.awk: Do not use "length()" to compute the size of an array. --- gcc/config/loongarch/genopts/gen-evolution.awk | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/config/loongarch/genopts/gen-evolut

[PATCH 0/1] LoongArch: Remove gawk extension from a generator script.

2024-07-22 Thread Yang Yujie
Builds for the LoongArch target fail if the system "awk" is not "gawk". This patch removes this unnecessary requirement. Thanks to Jan-Benedict Glaw for finding and reporting this issue. Yang Yujie (1): LoongArch: Remove gawk extension from a generator script. gcc/conf

Re: [PATCH v4 1/2] LoongArch: Define ISA versions

2024-04-22 Thread Yang Yujie
v1 -> v2: - Fixed build issues of runtime libraries caused by the new header. - Restored the default ARCH of lp64f/lp64s ABI to "abi-default". v2 -> v3: - Fixed libobjc build. - Modify "LoongArch v1.1 features" to "LoongArch v1.1 instructions" in invoke.texi. v3 -> v4: - Do not define __loongarc

[PATCH v4 1/2] LoongArch: Define ISA versions

2024-04-22 Thread Yang Yujie
These ISA versions are defined as -march= parameters and are recommended for building binaries for distribution. Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog:

[PATCH v4 2/2] LoongArch: Define builtin macros for ISA evolutions

2024-04-22 Thread Yang Yujie
Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog: * config.gcc: Add loongarch-evolution.o. * config/loongarch/genopts/genstr.sh: Enable generation of

Re: [PATCH v3 1/2] LoongArch: Define ISA versions

2024-04-22 Thread Yang Yujie
v1 -> v2: - Fixed build issues of runtime libraries caused by the new header. - Restored the default ARCH of lp64f/lp64s ABI to "abi-default". v2 -> v3: - Fixed libobjc build. - Modify "LoongArch v1.1 features" to "LoongArch v1.1 instructions" in invoke.texi.

[PATCH v3 2/2] LoongArch: Define builtin macros for ISA evolutions

2024-04-22 Thread Yang Yujie
Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog: * config.gcc: Add loongarch-evolution.o. * config/loongarch/genopts/genstr.sh: Enable generation of

[PATCH v3 1/2] LoongArch: Define ISA versions

2024-04-22 Thread Yang Yujie
These ISA versions are defined as -march= parameters and are recommended for building binaries for distribution. Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog:

Re: [PATCH v2 1/2] LoongArch: Define ISA versions

2024-04-20 Thread Yang Yujie
v1 -> v2: - Fixed build issues of runtime libraries caused by the new header. - Restored the default ARCH of lp64f/lp64s ABI to "abi-default".

[PATCH v2 2/2] LoongArch: Define builtin macros for ISA evolutions

2024-04-20 Thread Yang Yujie
Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog: * config.gcc: Add loongarch-evolution.o. * config/loongarch/genopts/genstr.sh: Enable generation of

[PATCH v2 1/2] LoongArch: Define ISA versions

2024-04-20 Thread Yang Yujie
These ISA versions are defined as -march= parameters and are recommended for building binaries for distribution. Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog:

Re: [PATCH 1/2] LoongArch: Define ISA versions

2024-04-19 Thread Yang Yujie
On Fri, Apr 19, 2024 at 07:34:33PM +0800, Xi Ruoyao wrote: > On Fri, 2024-04-19 at 19:04 +0800, Yang Yujie wrote: > > These ISA versions are defined as -march= parameters and > > are recommended for building binaries for distribution. > > > > Detailed description of the

[PATCH 1/2] LoongArch: Define ISA versions

2024-04-19 Thread Yang Yujie
These ISA versions are defined as -march= parameters and are recommended for building binaries for distribution. Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog:

[PATCH 2/2] LoongArch: Define builtin macros for ISA evolutions

2024-04-19 Thread Yang Yujie
Detailed description of these definitions can be found at https://github.com/loongson/la-toolchain-conventions, which the LoongArch GCC port aims to conform to. gcc/ChangeLog: * config.gcc: Add loongarch-evolution.o. * config/loongarch/genopts/genstr.sh: Enable generation of

Re: [PATCH v2] LoongArch: Enable switchable target

2024-04-08 Thread Yang Yujie
On Mon, Apr 08, 2024 at 04:49:58PM +0800, Xi Ruoyao wrote: > On Mon, 2024-04-08 at 16:46 +0800, Yang Yujie wrote: > > v1 -> v2: > > Remove spaces from changelog. > > I've rebuilt the base system with a GCC including this patch. LTO+PGO > bootstrap fine, regtes

Re: [PATCH v2] LoongArch: Enable switchable target

2024-04-08 Thread Yang Yujie
v1 -> v2: Remove spaces from changelog.

[PATCH v2] LoongArch: Enable switchable target

2024-04-08 Thread Yang Yujie
This patch fixes the back-end context switching in cases where functions should be built with their own target contexts instead of the global one, such as LTO linking and functions with target attributes (TBD). PR target/113233 gcc/ChangeLog: * config/loongarch/loongarch.cc (loon

Re: [PATCH] LoongArch: Enable switchable target

2024-04-07 Thread Yang Yujie
On Sun, Apr 07, 2024 at 08:56:53PM +0800, Xi Ruoyao wrote: > On Sun, 2024-04-07 at 15:47 +0800, Yang Yujie wrote: > > * config/loongarch/loongarch-builtins.cc > > (loongarch_init_builtins): > >     Initialize all builtin functions at startup. > > git gcc-verif

Re: [PATCH] LoongArch: Enable switchable target

2024-04-07 Thread Yang Yujie
On Sun, Apr 07, 2024 at 04:23:53PM +0800, Xi Ruoyao wrote: > On Sun, 2024-04-07 at 15:47 +0800, Yang Yujie wrote: > > This patch fixes the back-end context switching in cases where functions > > should be built with their own target contexts instead of the > > global one, su

[PATCH] LoongArch: Enable switchable target

2024-04-07 Thread Yang Yujie
This patch fixes the back-end context switching in cases where functions should be built with their own target contexts instead of the global one, such as LTO linking and functions with target attributes (TBD). PR target/113233 gcc/ChangeLog: * config/loongarch/loongarch.cc (loon

[PATCH] LoongArch: Fix missing plugin header

2024-04-01 Thread Yang Yujie
gcc/ChangeLog: * config/loongarch/t-loongarch: Add loongarch-def-arrays.h to OPTION_H_EXTRA. --- gcc/config/loongarch/t-loongarch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/loongarch/t-loongarch b/gcc/config/loongarch/t-loongarch index 3dd7

[PATCH v4] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-03-30 Thread Yang Yujie
gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark -m[no-]recip as aliases to -mrecip={all,none}, respectively. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch-def.h (ABI_FPU_64): Rename to... (ABI_FPU64_P): ...this.

Re: [PATCH v4] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-03-30 Thread Yang Yujie
v1 -> v2: - Rebased to master. - Specifies "(void)" for the empty parameter list of loongarch_global_init. v2 -> v3: - Keep the original option-processing behavior (-march=la664 enables -mrecip=all) and fix the ICE when -mfrecipe is not passed with -mrecip. v3 -> v4: - Rewrite changelog.

[PATCH] LoongArch: Use /lib instead of /lib64 as the library search path for MUSL.

2024-03-05 Thread Yang Yujie
gcc/ChangeLog: * config.gcc: Add a case for loongarch*-*-linux-musl*. * config/loongarch/linux.h: Disable the multilib-compatible treatment for *musl* targets. * config/loongarch/musl.h: New file. --- gcc/config.gcc | 3 +++ gcc/config/loongarch/linu

Re: [PATCH v3] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-02-22 Thread Yang Yujie
v1 -> v2: - Rebased to master. - Specifies "(void)" for the empty parameter list of loongarch_global_init. v2 -> v3: - Keep the original option-processing behavior (-march=la664 enables -mrecip=all) and fix the ICE when -mfrecipe is not passed with -mrecip.

[PATCH v3] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-02-22 Thread Yang Yujie
gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark -m[no-]recip as aliases to -mrecip={all,none}. * config/loongarch/loongarch.opt: Same. * config/loongarch/loongarch-def.h: Modify ABI condition macros for convenience. * config/loongarc

Re: [PATCH v2] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-02-20 Thread Yang Yujie
v1 -> v2: - Rebased to master. - Specifies "(void)" for the empty parameter list of loongarch_global_init.

[PATCH v2] LoongArch: Split loongarch_option_override_internal into smaller procedures

2024-02-20 Thread Yang Yujie
gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Mark -m[no-]recip as aliases to -mrecip={all,none}. * config/loongarch/loongarch.opt: Same. * config/loongarch/loongarch-def.h: Modify ABI condition macros for convenience. * config/loongarc

  1   2   >