diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 5024815ed9dfae31b295e48e1380990a7caa63eb..09eb7a34e91b6b9a71d0d0f2171708af58fc7efc 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -4028,11 +4028,11 @@ bitint_large_huge::lower_addsub_overflow (tree obj, gimple *stmt) edge edge_true_true, edge_true_false, edge_false; gimple *g2 = NULL; if (!single_comparison) - g2 = gimple_build_cond (EQ_EXPR, idx, + g2 = gimple_build_cond (NE_EXPR, idx, size_int (startlimb), NULL_TREE, NULL_TREE); if_then_if_then_else (g, g2, profile_probability::likely (), - profile_probability::unlikely (), + profile_probability::likely (), edge_true_true, edge_true_false, edge_false); unsigned tidx = startlimb + (cmp_code == GT_EXPR); diff --git a/gcc/testsuite/gcc.dg/bitint-41.c b/gcc/testsuite/gcc.dg/bitint-41.c index d87ea08bdf6497a49e0b7beb4826db0804f9c449..f97f03cd091c44ca14b0ef490c7961b9f9f260d3 100644 --- a/gcc/testsuite/gcc.dg/bitint-41.c +++ b/gcc/testsuite/gcc.dg/bitint-41.c @@ -1,6 +1,6 @@ /* PR middle-end/112336 */ /* { dg-do compile { target bitint } } */ -/* { dg-options "-std=c2x" } */ +/* { dg-options "-std=c23" } */ unsigned _BitInt(1) v1; unsigned _BitInt(1) *p1 = &v1; diff --git a/gcc/testsuite/gcc.dg/torture/bitint-43.c b/gcc/testsuite/gcc.dg/torture/bitint-43.c index 4265bffef7066fa2f34d0209b2d85c73f94a492b..a45f5c6b493ba3c49e7b4c104522a4194da14044 100644 --- a/gcc/testsuite/gcc.dg/torture/bitint-43.c +++ b/gcc/testsuite/gcc.dg/torture/bitint-43.c @@ -1,6 +1,6 @@ /* PR c/111309 */ /* { dg-do run { target bitint } } */ -/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/bitint-44.c b/gcc/testsuite/gcc.dg/torture/bitint-44.c index 938c0e917f344223dcdae281219d4dd12d814eca..fe5c168538781a15ef9200e53a2b2e1395ab1a62 100644 --- a/gcc/testsuite/gcc.dg/torture/bitint-44.c +++ b/gcc/testsuite/gcc.dg/torture/bitint-44.c @@ -1,6 +1,6 @@ /* PR c/111309 */ /* { dg-do run { target bitint } } */ -/* { dg-options "-std=c2x -pedantic-errors" } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ /* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ /* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/bitint-45.c b/gcc/testsuite/gcc.dg/torture/bitint-45.c new file mode 100644 index 0000000000000000000000000000000000000000..50c622d83d42e76d9fd7da1de476caa6f3ce09ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-45.c @@ -0,0 +1,32 @@ +/* PR middle-end/112750 */ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 256 +_BitInt(256) a = __INT_MAX__ + (_BitInt(256)) 1; +_BitInt(256) b = __INT_MAX__; +#endif +#if __BITINT_MAXWIDTH__ >= 512 +_BitInt(512) c = 0x7fffffffffffffffffffffffffffffffffffffffwb + (_BitInt(512)) 1; +_BitInt(512) d = 0x7fffffffffffffffffffffffffffffffffffffffwb; +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 256 + if (!__builtin_sub_overflow_p (a, 0, 0)) + __builtin_abort (); + if (!__builtin_sub_overflow_p (b, -1, 0)) + __builtin_abort (); +#endif +#if __BITINT_MAXWIDTH__ >= 512 + if (!__builtin_sub_overflow_p (c, 0, (_BitInt(160)) 0)) + __builtin_abort (); + if (!__builtin_sub_overflow_p (d, -1, 0)) + __builtin_abort (); +#endif + return 0; +}