From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83BAF384F6F2; Sat, 26 Nov 2022 15:46:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83BAF384F6F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669477610; bh=3QxaG8UEMq766ZJMgF38b1VyuCaLXoc4w5HLm8mdkx0=; h=From:To:Subject:Date:From; b=Gs2wR9T+wunhuUDJvruU1mvRvWsT9ppUjCoNnZ0+wMJeTpiFmxTbdNS8Dhcp/8ytm JSxlxUl2sHoT2Mt4JQg15zX5RM+N6LhgwUAwCJ7559eqwegNxymjzsmnRuD2AJuHVH VU5WsWXMLhcUBoMzUgbhGPzSAspUHkT6itwEzRtg= From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107879] New: [13 Regression] ffmpeg-4 test suite fails on FPU arithmetics Date: Sat, 26 Nov 2022 15:46:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107879 Bug ID: 107879 Summary: [13 Regression] ffmpeg-4 test suite fails on FPU arithmetics Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Test failure is initially observed on ffmpeg-4.4.2 test suite where a bunch= of tests started failing comparison against golden values. Extracted minimized example: // $ cat a.c /* Extracted from ffmpeg-4 test failure initially. How to reproduce: $ gcc-13/bin/gcc -O0 -lm a.c -o a -mfpmath=3Dsse -fexcess-precision=3Ds= tandard -Wall -Wextra && ./a ... OK $ gcc-13/bin/gcc -O1 -lm a.c -o a -mfpmath=3Dsse -fexcess-precision=3Ds= tandard -Wall -Wextra && ./a ... BUG */ #include __attribute__((noinline, noipa)) static double build_filter(double * y) { volatile int ph =3D 0; volatile double vf =3D 1.0; double factor =3D vf; double x =3D - (double)ph * factor; /* should be -0.0 */ fprintf(stderr, "z =3D %f\n", x); /* prints -0.0, ok */ /* This 'if / else' code should not affect calculation of 'ffm', but removing it does change things. */ if (x =3D=3D 0) *y =3D 1.0; /* should be 1.0 or .. */ else *y =3D 1.0 / x; /* -inf? */ fprintf(stderr, "*y =3D %f\n", *y); /* printf 1.0, ok */ double w =3D 2.0 * x / factor; /* should be -0.0 */ fprintf(stderr, "w =3D %f\n", w); /* prints -0.0, ok */ double omww =3D 1 - w; /* should be 1.0 */ fprintf(stderr, "omww =3D %f\n", omww); /* printf 1.0, ok */ double ffm =3D (omww > 0.0) ? omww : 0.0; /* should be 1.0 */ fprintf(stderr, "ffm =3D %f\n", ffm); /* printf 0.0 or 1.0, BUG */ return ffm; } int main() { double y =3D 42.0; double filter =3D build_filter(&y); fprintf(stderr, "f =3D %.20f; y =3D %.20f\n", filter, y); /* Should be 1.0, sometimes returns 0.0. */ fprintf(stderr, "%s\n", (filter > 0.5) ? "OK" : "BUG"); } How to reproduce: # -O0, good: $ gcc-HEAD/bin/gcc -O0 -lm a.c -o a -mfpmath=3Dsse -fexcess-precision=3Dsta= ndard -Wall -Wextra && ./a z =3D -0.000000 *y =3D 1.000000 w =3D -0.000000 omww =3D 1.000000 ffm =3D 1.000000 f =3D 1.00000000000000000000; y =3D 1.00000000000000000000 OK # -O1, bad: $ gcc-HEAD/bin/gcc -O1 -lm a.c -o a -mfpmath=3Dsse -fexcess-precision=3Dsta= ndard -Wall -Wextra && ./a z =3D -0.000000 *y =3D 1.000000 w =3D -0.000000 omww =3D 1.000000 ffm =3D 0.000000 f =3D 0.00000000000000000000; y =3D 1.00000000000000000000 BUG I think the code does not have anything controversial. Probably a code generation bug? $ LANG=3DC gcc-HEAD/bin/gcc -v Using built-in specs. COLLECT_GCC=3D/<>/gcc-13.0.0/bin/gcc COLLECT_LTO_WRAPPER=3D/<>/gcc-13.0.0/libexec/gcc/x86_64-unknown-linux-= gnu/13.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221126 (experimental) (GCC)=