[v2] rtl: fix build failure on -fchecking=2 [PR111642]
Checks
Commit Message
From: Sergei Trofimovich <siarheit@google.com>
Before the change `make bootstrap4` (or `make profiledbootstrap`) failed
as:
gcc/rtl-tests.cc:249:25: in ‘constexpr’ expansion of ‘poly_int<1, long int>(1, 1)’
gcc/poly-int.h:453:5: error: too many initializers for ‘long int [1]’
The failure happened only in stage4 due to a gcc bug which accepts
invalid C++ without `-fchecking=2`: https://gcc.gnu.org/PR111647#c1.
The change hides tests that rely on 2 and more polynomials under `#if`.
gcc/
PR bootstrap/111642
* rtl-tests.cc (const_poly_int_tests): Guard tests with
NUM_POLY_INT_COEFFS > 1.
* simplify-rtx.cc (simplify_const_poly_int_tests): Ditto.
---
gcc/rtl-tests.cc | 23 +++++++----------------
gcc/simplify-rtx.cc | 21 ++++++---------------
2 files changed, 13 insertions(+), 31 deletions(-)
@@ -228,24 +228,14 @@ test_uncond_jump ()
jump_insn);
}
-template<unsigned int N>
-struct const_poly_int_tests
-{
- static void run ();
-};
-
-template<>
-struct const_poly_int_tests<1>
-{
- static void run () {}
-};
-
/* Test various CONST_POLY_INT properties. */
-template<unsigned int N>
-void
-const_poly_int_tests<N>::run ()
+static void
+const_poly_int_tests ()
{
+ /* `poly_int64` call with two parameters requires target with at
+ least 2 COEFFs. */
+#if NUM_POLY_INT_COEFFS > 1
rtx x1 = gen_int_mode (poly_int64 (1, 1), QImode);
rtx x255 = gen_int_mode (poly_int64 (1, 255), QImode);
@@ -282,6 +272,7 @@ const_poly_int_tests<N>::run ()
gen_int_mode (poly_int64 (5, -2), QImode));
ASSERT_EQ (plus_constant (QImode, x1, poly_int64 (4, -2)),
gen_int_mode (poly_int64 (5, -1), QImode));
+#endif
}
/* Check dumping of repeated RTL vectors. */
@@ -317,7 +308,7 @@ rtl_tests_cc_tests ()
test_dumping_rtx_reuse ();
test_single_set ();
test_uncond_jump ();
- const_poly_int_tests<NUM_POLY_INT_COEFFS>::run ();
+ const_poly_int_tests ();
test_dumping_repeat ();
/* Purge state. */
@@ -8671,24 +8671,14 @@ test_vector_ops ()
}
}
-template<unsigned int N>
-struct simplify_const_poly_int_tests
-{
- static void run ();
-};
-
-template<>
-struct simplify_const_poly_int_tests<1>
-{
- static void run () {}
-};
-
/* Test various CONST_POLY_INT properties. */
-template<unsigned int N>
void
-simplify_const_poly_int_tests<N>::run ()
+simplify_const_poly_int_tests ()
{
+ /* `poly_int64` call with two parameters requires target with at
+ least 2 COEFFs. */
+#if NUM_POLY_INT_COEFFS > 1
rtx x1 = gen_int_mode (poly_int64 (1, 1), QImode);
rtx x2 = gen_int_mode (poly_int64 (-80, 127), QImode);
rtx x3 = gen_int_mode (poly_int64 (-79, -128), QImode);
@@ -8716,6 +8706,7 @@ simplify_const_poly_int_tests<N>::run ()
ASSERT_EQ (simplify_binary_operation (IOR, QImode, x4, two), x7);
ASSERT_EQ (simplify_subreg (HImode, x5, QImode, 0), x8);
ASSERT_EQ (simplify_subreg (QImode, x8, HImode, offset), x5);
+#endif
}
/* Run all of the selftests within this file. */
@@ -8725,7 +8716,7 @@ simplify_rtx_cc_tests ()
{
test_scalar_ops ();
test_vector_ops ();
- simplify_const_poly_int_tests<NUM_POLY_INT_COEFFS>::run ();
+ simplify_const_poly_int_tests ();
}
} // namespace selftest