[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