testsuite: Fix up builtin-math-6.c for mpc 1.4.* [PR124682]

MPC 1.4.0 changed the handling of signed zeros in cpow results.
These changes broke the builtin-math-6.c test.
Looking at the differences, MPC 1.3.1 to 1.4.0 changes folding of
the following calls in the test (it is always about the sign of
the imag zero part, +-0.0 means below that MPC 1.3.1 returned
positive 0.0 and MPC 1.4.0 returns -0.0 instead, and -+0.0 means
conversely that MPC 1.3.1 returned -0.0 and MPC 1.4.0 returns positive
0.0.
__builtin_cpow (__complex__ (-1.5e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-3.375e+0, +-0.0);
__builtin_cpow (__complex__ (-1.5e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-2.96296296296296279848547783331014215946197509765625e-1, -+0.0);
__builtin_cpow (__complex__ (1.5e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (3.375e+0, -+0.0);
__builtin_cpow (__complex__ (-2.0e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-8.0e+0, +-0.0);
__builtin_cpow (__complex__ (-2.0e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-1.25e-1, -+0.0);
__builtin_cpow (__complex__ (2.0e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (8.0e+0, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.2345679012345678327022824305458925664424896240234375e-2, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, 0.0), __complex__ (4.0e+0, -0.0)) = __complex__ (8.1e+1, +-0.0);
__builtin_cpow (__complex__ (3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, 0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (-2.43e+2, +-0.0);
__builtin_cpow (__complex__ (-3.0e+0, 0.0), __complex__ (-5.0e+0, -0.0)) = __complex__ (-4.11522633744856002058210009408867335878312587738037109375e-3, -+0.0);
__builtin_cpow (__complex__ (3.0e+0, -0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (2.43e+2, -+0.0);
__builtin_cpow (__complex__ (-4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpow (__complex__ (-4.0e+0, 0.0), __complex__ (2.0e+0, -0.0)) = __complex__ (1.6e+1, +-0.0);
__builtin_cpow (__complex__ (4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpow (__complex__ (1.5e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (2.96296296296296279848547783331014215946197509765625e-1, -+0.0);
__builtin_cpow (__complex__ (-1.5e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-2.96296296296296279848547783331014215946197509765625e-1, +-0.0);
__builtin_cpow (__complex__ (-1.5e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-3.375e+0, -+0.0);
__builtin_cpow (__complex__ (2.0e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (1.25e-1, -+0.0);
__builtin_cpow (__complex__ (-2.0e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-1.25e-1, +-0.0);
__builtin_cpow (__complex__ (-2.0e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-8.0e+0, -+0.0);
__builtin_cpow (__complex__ (3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.2345679012345678327022824305458925664424896240234375e-2, -+0.0);
__builtin_cpow (__complex__ (3.0e+0, 0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (4.11522633744856002058210009408867335878312587738037109375e-3, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, -0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (-4.11522633744856002058210009408867335878312587738037109375e-3, +-0.0);
__builtin_cpow (__complex__ (-3.0e+0, -0.0), __complex__ (5.0e+0, -0.0)) = __complex__ (-2.43e+2, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpow (__complex__ (-3.0e+0, -0.0), __complex__ (-4.0e+0, -0.0)) = __complex__ (1.2345679012345678327022824305458925664424896240234375e-2, +-0.0);
__builtin_cpow (__complex__ (4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpow (__complex__ (-4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpow (__complex__ (-4.0e+0, -0.0), __complex__ (-2.0e+0, -0.0)) = __complex__ (6.25e-2, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-3.375e+0, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-2.96296298503875732421875e-1, -+0.0);
__builtin_cpowf (__complex__ (1.5e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (3.375e+0, -+0.0);
__builtin_cpowf (__complex__ (-2.0e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-8.0e+0, +-0.0);
__builtin_cpowf (__complex__ (-2.0e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-1.25e-1, -+0.0);
__builtin_cpowf (__complex__ (2.0e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (8.0e+0, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.2345679104328155517578125e-2, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (4.0e+0, -0.0)) = __complex__ (8.1e+1, +-0.0);
__builtin_cpowf (__complex__ (3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (-2.43e+2, +-0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (-5.0e+0, -0.0)) = __complex__ (-4.1152262128889560699462890625e-3, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, -0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (2.43e+2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, 0.0), __complex__ (2.0e+0, -0.0)) = __complex__ (1.6e+1, +-0.0);
__builtin_cpowf (__complex__ (4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpowf (__complex__ (1.5e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (2.96296298503875732421875e-1, -+0.0);
__builtin_cpowf (__complex__ (-1.5e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-2.96296298503875732421875e-1, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-3.375e+0, -+0.0);
__builtin_cpowf (__complex__ (2.0e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (1.25e-1, -+0.0);
__builtin_cpowf (__complex__ (-2.0e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-1.25e-1, +-0.0);
__builtin_cpowf (__complex__ (-2.0e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-8.0e+0, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.2345679104328155517578125e-2, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, 0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (4.1152262128889560699462890625e-3, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (-4.1152262128889560699462890625e-3, +-0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (5.0e+0, -0.0)) = __complex__ (-2.43e+2, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (-4.0e+0, -0.0)) = __complex__ (1.2345679104328155517578125e-2, +-0.0);
__builtin_cpowf (__complex__ (4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, -0.0), __complex__ (-2.0e+0, -0.0)) = __complex__ (6.25e-2, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-3.375e+0, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-2.96296296296296296301315750798544002009293762966990470886e-1, -+0.0);
__builtin_cpowf (__complex__ (1.5e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (3.375e+0, -+0.0);
__builtin_cpowf (__complex__ (-2.0e+0, 0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (-8.0e+0, +-0.0);
__builtin_cpowf (__complex__ (-2.0e+0, 0.0), __complex__ (-3.0e+0, -0.0)) = __complex__ (-1.25e-1, -+0.0);
__builtin_cpowf (__complex__ (2.0e+0, -0.0), __complex__ (3.0e+0, 0.0)) = __complex__ (8.0e+0, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.23456790123456790122724786341878999706977992900647222996e-2, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (4.0e+0, -0.0)) = __complex__ (8.1e+1, +-0.0);
__builtin_cpowf (__complex__ (3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (-2.43e+2, +-0.0);
__builtin_cpowf (__complex__ (-3.0e+0, 0.0), __complex__ (-5.0e+0, -0.0)) = __complex__ (-4.11522633744855967075749287806263332356593309668824076653e-3, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, -0.0), __complex__ (5.0e+0, 0.0)) = __complex__ (2.43e+2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, 0.0), __complex__ (2.0e+0, -0.0)) = __complex__ (1.6e+1, +-0.0);
__builtin_cpowf (__complex__ (4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpowf (__complex__ (1.5e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (2.96296296296296296301315750798544002009293762966990470886e-1, -+0.0);
__builtin_cpowf (__complex__ (-1.5e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-2.96296296296296296301315750798544002009293762966990470886e-1, +-0.0);
__builtin_cpowf (__complex__ (-1.5e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-3.375e+0, -+0.0);
__builtin_cpowf (__complex__ (2.0e+0, 0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (1.25e-1, -+0.0);
__builtin_cpowf (__complex__ (-2.0e+0, -0.0), __complex__ (-3.0e+0, 0.0)) = __complex__ (-1.25e-1, +-0.0);
__builtin_cpowf (__complex__ (-2.0e+0, -0.0), __complex__ (3.0e+0, -0.0)) = __complex__ (-8.0e+0, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, 0.0), __complex__ (-4.0e+0, 0.0)) = __complex__ (1.23456790123456790122724786341878999706977992900647222996e-2, -+0.0);
__builtin_cpowf (__complex__ (3.0e+0, 0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (4.11522633744855967075749287806263332356593309668824076653e-3, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (-5.0e+0, 0.0)) = __complex__ (-4.11522633744855967075749287806263332356593309668824076653e-3, +-0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (5.0e+0, -0.0)) = __complex__ (-2.43e+2, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (4.0e+0, 0.0)) = __complex__ (8.1e+1, -+0.0);
__builtin_cpowf (__complex__ (-3.0e+0, -0.0), __complex__ (-4.0e+0, -0.0)) = __complex__ (1.23456790123456790122724786341878999706977992900647222996e-2, +-0.0);
__builtin_cpowf (__complex__ (4.0e+0, 0.0), __complex__ (-2.0e+0, 0.0)) = __complex__ (6.25e-2, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, -0.0), __complex__ (2.0e+0, 0.0)) = __complex__ (1.6e+1, -+0.0);
__builtin_cpowf (__complex__ (-4.0e+0, -0.0), __complex__ (-2.0e+0, -0.0)) = __complex__ (6.25e-2, +-0.0);

The following patch adjusts the testcase, so that it ignores the sign of
zero imag part.

2026-04-21  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/124682
	* gcc.dg/torture/builtin-math-6.c (TESTIT_COMPLEX_R2_ISZ): Define.
	(TESTIT_COMPLEX_R2_ALLNEG): Use TESTIT_COMPLEX_R2_ISZ instead of
	TESTIT_COMPLEX_R2.

Reviewed-by: Richard Biener <rguenth@suse.de>
This commit is contained in:
Jakub Jelinek
2026-04-21 13:20:00 +02:00
committed by Jakub Jelinek
parent 0413057e56
commit 727f223054

View File

@@ -155,26 +155,47 @@ extern void link_error(int, int);
link_error(__LINE__, VAL_NUM); \
} while (0)
/* For complex numbers, call the TESTIT_COMPLEX_R2 macro for all
/* Similar to TESTIT_COMPLEX_R2, but doesn't check sign of imag part
if imag part is zero. MPC between 1.3.1 and 1.4.0 changed the
handling of it. */
#define TESTIT_COMPLEX_R2_ISZ(VAL_NUM, FUNC, ARG0, ARG1, RES) do { \
if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG0, ARG1), (RES)) \
|| CKSGN_F (__real__ (__builtin_##FUNC##f(ARG0, ARG1)), __real__ (RES)) \
|| (__imag__ (RES) != 0 \
&& CKSGN_F (__imag__ (__builtin_##FUNC##f(ARG0, ARG1)), __imag__ (RES)))) \
link_error(__LINE__, VAL_NUM); \
if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG0, ARG1), (RES)) \
|| CKSGN (__real__ (__builtin_##FUNC(ARG0, ARG1)), __real__ (RES)) \
|| (__imag__ (RES) != 0 \
&& CKSGN (__imag__ (__builtin_##FUNC(ARG0, ARG1)), __imag__ (RES)))) \
link_error(__LINE__, VAL_NUM); \
if (COMPLEX_DIFF1PCT_L (__builtin_##FUNC##l(ARG0, ARG1), (RES)) \
|| CKSGN_L (__real__ (__builtin_##FUNC##l(ARG0, ARG1)), __real__ (RES)) \
|| (__imag__ (RES) != 0 \
&& CKSGN_L (__imag__ (__builtin_##FUNC##l(ARG0, ARG1)), __imag__ (RES)))) \
link_error(__LINE__, VAL_NUM); \
} while (0)
/* For complex numbers, call the TESTIT_COMPLEX_R2_ISZ macro for all
combinations of neg and conj. */
#define TESTIT_COMPLEX_R2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\
RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \
TESTIT_COMPLEX_R2(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\
TESTIT_COMPLEX_R2(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \
TESTIT_COMPLEX_R2(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \
TESTIT_COMPLEX_R2(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \
TESTIT_COMPLEX_R2(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \
TESTIT_COMPLEX_R2(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \
TESTIT_COMPLEX_R2(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \
TESTIT_COMPLEX_R2(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \
TESTIT_COMPLEX_R2(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \
TESTIT_COMPLEX_R2(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \
TESTIT_COMPLEX_R2(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \
TESTIT_COMPLEX_R2(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \
TESTIT_COMPLEX_R2(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \
TESTIT_COMPLEX_R2(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \
TESTIT_COMPLEX_R2(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \
TESTIT_COMPLEX_R2(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \
TESTIT_COMPLEX_R2_ISZ(1, FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\
TESTIT_COMPLEX_R2_ISZ(2, FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \
TESTIT_COMPLEX_R2_ISZ(3, FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \
TESTIT_COMPLEX_R2_ISZ(4, FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \
TESTIT_COMPLEX_R2_ISZ(5, FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \
TESTIT_COMPLEX_R2_ISZ(6, FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \
TESTIT_COMPLEX_R2_ISZ(7, FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \
TESTIT_COMPLEX_R2_ISZ(8, FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \
TESTIT_COMPLEX_R2_ISZ(9, FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \
TESTIT_COMPLEX_R2_ISZ(10, FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \
TESTIT_COMPLEX_R2_ISZ(11, FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \
TESTIT_COMPLEX_R2_ISZ(12, FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \
TESTIT_COMPLEX_R2_ISZ(13, FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \
TESTIT_COMPLEX_R2_ISZ(14, FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \
TESTIT_COMPLEX_R2_ISZ(15, FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \
TESTIT_COMPLEX_R2_ISZ(16, FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \
} while (0)
int main (void)