Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-07-01 Thread Jakub Jelinek
On Sat, Jun 28, 2025 at 02:19:59AM +, Yuao Ma wrote: > > signbit is documented to be a macro, so please don't declare > > int signbit (double); > > function in the testcase and instead of signbit use __builtin_signbit. > > This is indeed my negligence. Done. > > If everything looks good, coul

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Yuao Ma
Hi Jakub, > signbit is documented to be a macro, so please don't declare > int signbit (double); > function in the testcase and instead of signbit use __builtin_signbit. This is indeed my negligence. Done. If everything looks good, could you please help me merge this patch? Thank you! Yuao 0

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Jakub Jelinek
On Fri, Jun 27, 2025 at 03:38:32PM +, Yuao Ma wrote: > Hi Jakub, > > > Please don't include math.h here. > > Done. > > > And instead of this line use __builtin_acospi (0.5). > > and, in dejagnu for runtime tests we prefer __builtin_abort on failure, so > > Done. Oh, one more thing. signbit

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Yuao Ma
Hi Jakub, > Please don't include math.h here. Done. > And instead of this line use __builtin_acospi (0.5). > and, in dejagnu for runtime tests we prefer __builtin_abort on failure, so Done. Yuao 0001-gcc-middle-end-opt-for-trigonometric-pi-based-functi.patch Description: 0001-gcc-middle-en

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Jakub Jelinek
On Fri, Jun 27, 2025 at 03:04:35PM +, Yuao Ma wrote: > > I think the __builtin_constant_p(acospi(0.5)) approach is usable, but would > > be much better done on the lib/target-supports.exp side. > > So, have foldable_pi_based_trigonometry effective target, which would test > > if __builtin_const

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Yuao Ma
Hi Jakub, > I think the __builtin_constant_p(acospi(0.5)) approach is usable, but would > be much better done on the lib/target-supports.exp side. > So, have foldable_pi_based_trigonometry effective target, which would test > if __builtin_constant_p(acospi(0.5)) is 1. Thanks again for your helpfu

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-27 Thread Jakub Jelinek
On Fri, Jun 27, 2025 at 08:17:46AM +0200, Tobias Burnus wrote: > Hi Yuao, > > > Yuao Ma wrote: > > >//but the testcases don't seem to be conditionalized on this. Would the > > >//new tests fail if gcc is built against an insufficiently recent version > > >//of mpfr, > … > > The test case is indee

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-26 Thread Tobias Burnus
Hi Yuao, Yuao Ma wrote: >//but the testcases don't seem to be conditionalized on this. Would the >//new tests fail if gcc is built against an insufficiently recent version >//of mpfr, … The test case is indeed conditionalized, though in a different manner than you might expect. The condition

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-26 Thread Yuao Ma
Hi Dave, > but the testcases don't seem to be conditionalized on this. Would the > new tests fail if gcc is built against an insufficiently recent version > of mpfr, and is/should there be some kind of dg-requires for this, so > that the new tests gracefully are "UNSUPPORTED" on such configuration

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-26 Thread David Malcolm
On Thu, 2025-06-26 at 17:45 +, Yuao Ma wrote: > Hi all, > > This patch, a follow-up to r16-1652-g0606d2b979f401, implements > middle-end > optimizations (e.g., constant folding) for our trigonometric pi-based > function > built-ins. > > This patch is part of > https://gcc.gnu.org/pipermail/fo

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-26 Thread Yuao Ma
Hi all, This patch, a follow-up to r16-1652-g0606d2b979f401, implements middle-end optimizations (e.g., constant folding) for our trigonometric pi-based function built-ins. This patch is part of https://gcc.gnu.org/pipermail/fortran/attachments/20250607/4a4a9cb6/attachment.obj Please take a look

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-26 Thread Yuao Ma
Hi all, This patch, a follow-up to r16-1652-g0606d2b979f401, implements middle-end optimizations (e.g., constant folding) for our trigonometric pi-based function built-ins. This patch is part of https://gcc.gnu.org/pipermail/fortran/attachments/20250607/4a4a9cb6/attachment.obj Please take a look

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-23 Thread Richard Biener
On Sat, Jun 7, 2025 at 3:56 PM Yuao Ma wrote: > > Hi all, > > This patch has been updated to conditionally fold the specified math functions > only when using MPFR version 4.2.0 or newer. > > To accompany this change, the test case now utilizes `__builtin_constant_p` to > determine whether to exec

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-07 Thread Yuao Ma
Hi all, This patch has been updated to conditionally fold the specified math functions only when using MPFR version 4.2.0 or newer. To accompany this change, the test case now utilizes `__builtin_constant_p` to determine whether to execute the tests against the folded functions. Let me know if t

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-02 Thread Yuao Ma
Hi Joseph, > I don't see tests for the various special cases from Annex F (for example, > "tanpi(n) returns +0, for positive even and negative odd integers n." and > "tanpi(n) returns -0, for positive odd and negative even integers n."). > In such cases the sign of zero would need to be checked sp

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-02 Thread Tobias Burnus
Joseph Myers wrote: On Sun, 1 Jun 2025, Yuao Ma wrote: For MPFR versions older than 4.2.0, we've included our own folding functions. I think the normal practice in GCC would be to avoid the optimizations when the MPFR support is absent, instead of working around the absence with possibly less a

Re: [PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-02 Thread Joseph Myers
On Sun, 1 Jun 2025, Yuao Ma wrote: > For MPFR versions older than 4.2.0, we've included our own folding functions. I think the normal practice in GCC would be to avoid the optimizations when the MPFR support is absent, instead of working around the absence with possibly less accurate implementa

[PATCH] gcc: middle-end opt for trigonometric pi-based functions builtins

2025-06-01 Thread Yuao Ma
Hello world, This patch partially handled PR118592. This patch builds upon r16-710-g591d3d02664c7b and r16-711-g89935d56f768b4. It introduces middle-end optimizations, such as constant folding, for our trigonometric pi-based function built-ins. For MPFR versions older than 4.2.0, we've included