From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 05A773857C53; Mon, 27 Nov 2023 18:33:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05A773857C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701110036; bh=KFJnhbbv4bo6ynpPXhF8ZsShV7y7LSI/LkPuA/9xJcI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HTabqge0HGpgBLW/Eu9C3XRPt3yUtJBzlkkAD+hrbPkeNEu2joZfW4udBGL8zFx4K 6+S3BKe3OiulWA9A2WNaptPuBXT+yO6TNyOW45FCw3xQS6iUQl+dx+XRj/CVxAc5yC 3Qnbz83zgvnetd+X8NJC1S196NFfbzLXov/q8AD8= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug bootstrap/111601] [14 Regression] profilebootstrap fails in stagestrain in libcody on x86_64-linux-gnu and powerpc64le-linux-gnu Date: Mon, 27 Nov 2023 18:33:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: bootstrap X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: build, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW 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=3D111601 --- Comment #21 from Jakub Jelinek --- Reduced testcase (though, just the function in question, not a runable testcase): struct tree_base { int code:16; }; struct saved_scope { void *pad[14]; int x_processing_template_decl; }; extern struct saved_scope *scope_chain; struct z_candidate { tree_base *fn; void *pad[11]; z_candidate *next; int viable; int flags; }; __attribute__((noipa)) struct z_candidate * splice_viable (struct z_candidate *cands, bool strict_p, bool *any_viable_p) { struct z_candidate *viable; struct z_candidate **last_viable; struct z_candidate **cand; bool found_strictly_viable =3D false; if (scope_chain->x_processing_template_decl) strict_p =3D true; viable =3D (z_candidate *) 0; last_viable =3D &viable; *any_viable_p =3D false; cand =3D &cands; while (*cand) { struct z_candidate *c =3D *cand; if (!strict_p && (c->viable =3D=3D 1 || ((int) (c->fn)->code) =3D=3D = 273)) { strict_p =3D true; if (viable && !found_strictly_viable) { *any_viable_p =3D false; *last_viable =3D cands; cands =3D viable; viable =3D (z_candidate *) 0; last_viable =3D &viable; } } if (strict_p ? c->viable =3D=3D 1 : c->viable) { *last_viable =3D c; *cand =3D c->next; c->next =3D (z_candidate *) 0; last_viable =3D &c->next; *any_viable_p =3D true; if (c->viable =3D=3D 1) found_strictly_viable =3D true; } else cand =3D &c->next; } return viable ? viable : cands; } With this and ./cc1plus -quiet -fpreprocessed -O2 -fprofile-generate -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -fno-common -fno-PIE -mcpu=3Dpower8 pr111601.ii -o pr111601.s3 -ffold-mem-offsets -da vs. ./cc1plus -quiet -fpreprocessed -O2 -fprofile-generate -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -fno-common -fno-PIE -mcpu=3Dpower8 pr111601.ii -o pr111601.s4 -fno-fold-mem-offsets -da the assembly difference is just .L13: std 9,0(10) mr 10,9 li 5,0 + addi 10,10,96 li 7,1 addi 4,4,1 addi 6,6,1 ld 9,96(9) std 9,0(8) - std 5,96(10) + std 5,0(10) stb 7,0(31) ori 2,2,0 ld 9,0(8) cmpdi 0,9,0 beq 0,.L18 lwz 7,104(9) li 12,1 li 5,1 cmpwi 0,7,1 beq 0,.L13 which shows the problem in a single loop. Without the pass, %r10 is set to= %r9 + 96 and 5 (NULL) is stored to it first and if the loop loops again, 9 is stored to it. While with the pass, %r10 is set to %r9, 5 (NULL) is stored = to %r10 + 96 and then next iteration overwrites the fn pointer in the structure rather than next.=