On Thu, 16 Nov 2023, Dimitar Dimitrov wrote: > On Wed, Nov 15, 2023 at 12:11:50PM +0000, Richard Biener wrote: > > The following avoids hoisting of invariants from conditionally > > executed parts of an if-converted loop. That now makes a difference > > since we perform bitfield lowering even when we do not actually > > if-convert the loop. if-conversion deals with resetting flow-sensitive > > info when necessary already. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. > > > > PR tree-optimization/112282 > > * tree-if-conv.cc (ifcvt_hoist_invariants): Only hoist from > > the loop header. > > > > * gcc.dg/torture/pr112282.c: New testcase. > > --- > > gcc/testsuite/gcc.dg/torture/pr112282.c | 132 ++++++++++++++++++++++++ > > gcc/tree-if-conv.cc | 44 ++++---- > > 2 files changed, 153 insertions(+), 23 deletions(-) > > create mode 100644 gcc/testsuite/gcc.dg/torture/pr112282.c > > > > diff --git a/gcc/testsuite/gcc.dg/torture/pr112282.c > > b/gcc/testsuite/gcc.dg/torture/pr112282.c > > new file mode 100644 > > index 00000000000..23e0ed64b82 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.dg/torture/pr112282.c > > @@ -0,0 +1,132 @@ > > +/* { dg-do run } */ > > + > > +int printf(const char *, ...); > > +void __assert_fail(); > > This function is glibc-only. Thus the test fails on newlib targets with: > > FAIL: gcc.dg/torture/pr112282.c -O0 (test for excess errors) > Excess errors: > pr112282.c:(.text+0x1944): undefined reference to `__assert_fail' > pr112282.c:(.text+0x2480): undefined reference to `__assert_fail' > > Perhaps __builtin_abort should be used instead?
Ah. We need an abort that isn't noreturn to reproduce the problem though. I verified the following still reproduces the original problem. Pushed. >From 6cb42f8398d10e5161c7e412a7706d2e31bae708 Mon Sep 17 00:00:00 2001 From: Richard Biener <rguent...@suse.de> Date: Thu, 16 Nov 2023 08:03:55 +0100 Subject: [PATCH] tree-optimization/112282 - fix testcase To: gcc-patches@gcc.gnu.org Avoid requiring a glibc specific symbol. PR tree-optimization/112282 * gcc.dg/torture/pr112282.c: Do not use __assert_fail. --- gcc/testsuite/gcc.dg/torture/pr112282.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr112282.c b/gcc/testsuite/gcc.dg/torture/pr112282.c index 23e0ed64b82..6190b90cf66 100644 --- a/gcc/testsuite/gcc.dg/torture/pr112282.c +++ b/gcc/testsuite/gcc.dg/torture/pr112282.c @@ -1,7 +1,12 @@ /* { dg-do run } */ int printf(const char *, ...); -void __assert_fail(); +void abort (); +/* We need an abort that isn't noreturn. */ +void __attribute__((noipa)) my_abort () +{ + abort (); +} int a, g, h, i, v, w = 2, x, y, ab, ac, ad, ae, af, ag; static int f, j, m, n, p, r, u, aa; struct b { @@ -72,7 +77,7 @@ ak: ah.e = l.c % q.d; q.c = au.e; if ((q.d && q.c) || ah.e) - __assert_fail(); + my_abort (); q.c = 0; if (au.d > m || ah.e) w = au.c | (n & ah.c); @@ -93,7 +98,7 @@ ak: if (ah.d) o.c = l.c & o.c & q.c; if (q.d) - __assert_fail(); + my_abort (); printf("", an); printf("", q); printf("", au); -- 2.35.3