From: Jakub Jelinek Date: Tue, 17 Feb 2026 16:44:04 +0000 (+0100) Subject: testsuite: Add testcase for latent PR [PR123048] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0c32988904caf13a2ac439efd9061b50586e998;p=thirdparty%2Fgcc.git testsuite: Add testcase for latent PR [PR123048] This testcase started to be miscompiled with r16-4186 and went latent again r16-6651. 2026-02-17 Jakub Jelinek PR rtl-optimization/123048 * gcc.dg/pr123048.c: New test. --- diff --git a/gcc/testsuite/gcc.dg/pr123048.c b/gcc/testsuite/gcc.dg/pr123048.c new file mode 100644 index 00000000000..4c9f584a7a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr123048.c @@ -0,0 +1,76 @@ +/* PR rtl-optimization/123048 */ +/* { dg-do run { target int32 } } */ +/* { dg-options "-O3 -fschedule-insns" } */ +/* { dg-require-effective-target scheduling } */ + +int a[] = { + 4, 7, 5, 5, 54, 2044508324, 0, 4, 7, 4049, 8, 6, 4089016648, 4, 50548861, 3, + 107580753, 9, 2, 6, 7, 5, 5, 7, 7073096, 6, 2, 2, 1006888145, 607687, 101629, + 3, 901097722, 9000684, 6, 8065728, 1, 1, 705015759, 5, 0, 6, 4, 104598, 3, 1, + 5, 3099436303, 4, 4, 30930, 70347812, 7, 5, -1810856918, 907459465, 5, 3, + 904427059, 2013776290, 6, 4, 0, 3, 3, 9, 7, 802195444, 6, 8001368, + 4066508878, 70925, 3092731, 5, 706088902, 4, 2, 2, 1, 7, 3, 5, 303535960, 6, + 7007092, 9037538, 70817, 1, 3, 4079995, 6, 6, 909243462, 6, 7, 7, 1, + 708648649, 8, 6, 6048, 4, 909, 5, 10523913, 5, 4, 702138776, 0, 2, 504918807, + 3, 3082640443, 9, 4, 6, 7068, 10842, 1, 70997, 3, 0, 4, 0, 2053790376, 90386, + 2, 2050814, 5, 5, 0, 6, 2, 708143, 5, 3, 7, 604390888, 8, 2, 6, 5, 60999, + 1068828381, 9, 0, 8, 906185462, 1090812512, 3, 9, 5, 1, 4, 60834842, 8085408, + 6, 109, 8078467, 3, 400815, 2, 608, 4, 6, 5, 3, 1, 607071920, 0, 2, 40735498, + 5, 1, 3087877, 908371, 4, 803740692, 2075208622, 2, 3, 90285, 2094854071, 1, + 2029012, 0, 2, 0, 1, 5, 1, 7, 4, 200368, 4, 405801727, 5, 5, 1, 5067896, + 608007406, 308918612, 8, 808555105 +}; +int c, d, e, k, j[3] = { 1, 2 }, *l; +unsigned h; + +int +foo (int o, unsigned p) +{ + return o >> 8 ^ a[(o ^ p) & 255]; +} + +int +bar (int o, int p) +{ + d = (o >> 8 & 16777215) ^ a[(o ^ p) & 255]; + o = d; + o = foo (o, p >> 8 & 255); + o = foo (o, p >> 6); + c = o >> 8 ^ a[(o ^ 24) & 255]; + return c; +} + +int +baz (int o, int p, int r[], int s) +{ + unsigned b = -1; + int m, f; + m = -1 - o; + if (m + e) + goto lab; + do + { + while (k) + ; + for (int i = 0; i < 6; ++i) + h = bar (h, l[i]); + } + while (o); +lab: + f = -(1 % r[1]); + m = 1 / s; + int a[] = { o, p, r[0], r[1], r[2], f, m, s }; + for (int i = 0; i < 8; i++) + b = bar (b, a[i]); + return b; +} + +int +main () +{ + if (__CHAR_BIT__ != 8 || sizeof (int) != 4) + return 0; + int g = baz (-5, 1, j, 2); + if (g != 4639) + __builtin_abort (); +}