From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 21F633858423; Wed, 8 Nov 2023 14:42:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21F633858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699454576; bh=LZHbqfW9gdOXhGiB0F+mGbP51bikyJuR5POsRcJfos0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qozrsjuc0qHXto3Fn3LffEb52TvH3a3LYP70TPA0unordnXN9x7JPObieF5fB7O3u 1H/h2zdnLRU2N+2K8ShXwbbi/VEdYFOwKMkvVg14c57XlIqr3R0psZUR6tjWyAzz1d opCaPlWhEnKJA4dzJpQTl4DkrWCfNbeoM/gqbaS0= From: "jeffreyalaw at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/112415] [14 regression] Python 3.11 miscompiled on HPPA with new RTL fold mem offset pass, since r14-4664-g04c9cf5c786b94 Date: Wed, 08 Nov 2023 14:42:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jeffreyalaw at gmail dot com 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: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D112415 --- Comment #16 from Jeffrey A. Law --- On 11/8/23 03:09, manolis.tsamis at vrull dot eu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112415 >=20 > --- Comment #15 from Manolis Tsamis --- > (In reply to Sam James from comment #13) >> Created attachment 56527 [details] >> compile.c.323r.fold_mem_offsets.bad.xz >> >> Output from >> ``` >> hppa2.0-unknown-linux-gnu-gcc -c -DNDEBUG -g -fwrapv -O3 -Wall -O2 >> -std=3Dc11 -Werror=3Dimplicit-function-declaration -fvisibility=3Dhidden >> -I/home/sam/git/cpython/Include/internal -IObjects -IInclude -IPython -I. >> -I/home/sam/git/cpython/Include -DPy_BUILD_CORE -o Python/compile.o >> /home/sam/git/cpython/Python/compile.c -fdump-rtl-fold_mem_offsets-all >> ``` >> >> If I instrument certain functions in compile.c with no optimisation >> attribuet or build the file with -fno-fold-mem-offsets, Python works, so= I'm >> reasonably sure this is the relevant object. >=20 > Thanks for the dump file! There are 66 folded/eliminated instructions in = this > object file; I did look at each case and there doesn't seem to be anything > strange. In fact most of the transformations are straightforward: >=20 > - All except a couple of cases don't involve any arithmetic, so it's ju= st > moving a constant around. > - The majority of the transformations are 'trivial' and consist of a si= ngle > add and then a memory operation: a sequence like X =3D Y + Const, R =3D M= EM[X + 0] > is folded to X =3D Y, R =3D MEM[X + Const]. I wonder why so many of these= exist and > are not optimized elsewhere. > - There are some cases with negative offsets, but the calculations look > correct. > - There are few more complicated cases, but I've done these on paper an= d also > look correct. The PA port is "weird". It's addressing modes aren't a good match for=20 GCC (they're not symmetrical across loads vs stores and across fp vs=20 integer) and they have the implicit space register problem. But I don't=20 immediately recall needing to avoid propagation of constants into memory=20 references or anything like that. I'd probably continue with the process of narrowing down what code is=20 affected using the attributes. We already know the file, narrowing it=20 down to a function might help considerably with the evaluation effort. Note that QEMU has a functional PA port. So you might be able to just=20 take a root filesystem, add the tarball referenced earlier and play=20 around to narrow things down further. I haven't done work on the PA in about 20 years at this point, but I can=20 probably still grok its code. Between David and myself I'm sure we can=20 help interpret what's going on Jeff=