On Fri, Jun 27, 2025 at 03:04:35PM +0000, 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_constant_p(acospi(0.5)) is 1. > > Thanks again for your helpful advice. > > I've added the foldable_pi_based_trigonometry effective target and removed the > conditional branch in the test case. The test results look good.
--- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -14495,3 +14495,15 @@ proc check_effective_target_xtensa_atomic { } { #endif }] } + +# Return 1 if pi-based trigonometry function is foldable +# We should remove this after bumping the minimum mpfr version to 4.2.0. +proc check_effective_target_foldable_pi_based_trigonometry { } { + return [check_runtime foldable_pi_based_trigonometry { + #include <math.h> Please don't include math.h here. + int main () + { + return !__builtin_constant_p (acospi (0.5)); And instead of this line use __builtin_acospi (0.5). and, in dejagnu for runtime tests we prefer __builtin_abort on failure, so if (!__builtin_constant_p (__builtin_acospi (0.5))) __builtin_abort (); return 0; or so. Otherwise LGTM. Jakub