From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B49643858C50; Mon, 20 Nov 2023 09:42:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B49643858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700473342; bh=1yS7VlawQmE72RL+IGmfmfip4pgAITjLSQ/VmE9i+/Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=c8Fge5Fv+A5Tu/uc4MeixK52gtQ59Aa/XOpAh06N0F4a7WNOzU9GPHfhZjDFQUbea sv5dV60L8NJs72eWENenbrSy7iQSJ0o9lfoDlQdpzSd3KW/ULaFvgmDpveldYqzI91 c4JUnqy8Sw/JnA+43+Y/RUFFidEZr/8g1cCem2Rg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112612] Holding on the loop variable rather than a derived value which can replace it Date: Mon, 20 Nov 2023 09:42:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status everconfirmed cf_reconfirmed_on 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=3D112612 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2023-11-20 --- Comment #3 from Richard Biener --- Confirmed. Candidate 1: Var befor: ivtmp.5 Var after: ivtmp.5 Incr POS: before exit test IV struct: Type: unsigned long Base: 0 Step: 1 Biv: N Overflowness wrto loop niter: No-overflow ... Candidate 8: Var befor: ivtmp.10 Var after: ivtmp.10 Incr POS: before exit test IV struct: Type: unsigned int Base: 0 Step: 2 Biv: N Overflowness wrto loop niter: No-overflow Candidate 9: Var befor: ivtmp.11 Var after: ivtmp.11 Incr POS: before exit test IV struct: Type: unsigned long Base: (unsigned long) a_8(D) Step: 4 Object: (void *) a_8(D) Biv: N Overflowness wrto loop niter: Overflow so we do have this candidate. Improved to: cost: 16 (complexity 0) reg_cost: 4 cand_cost: 10 cand_group_cost: 2 (complexity 0) candidates: 8, 9 group:0 --> iv_cand:8, cost=3D(0,0) group:1 --> iv_cand:9, cost=3D(2,0) group:2 --> iv_cand:8, cost=3D(0,0) invariant variables: invariant expressions: Initial set of candidates: cost: 15 (complexity 2) reg_cost: 3 cand_cost: 5 cand_group_cost: 7 (complexity 2) candidates: 1 group:0 --> iv_cand:1, cost=3D(4,0) group:1 --> iv_cand:1, cost=3D(3,2) group:2 --> iv_cand:1, cost=3D(0,0) invariant variables: 1 invariant expressions: but somehow we fail to express(?) some of the uses with just candidate 8? It "works" with -m32 added: [local count: 1063004408]: # ivtmp.10_12 =3D PHI val_7 =3D (int) ivtmp.10_12; MEM[(int *)a_8(D) + ivtmp.10_12 * 2] =3D val_7; ivtmp.10_11 =3D ivtmp.10_12 + 2; if (ivtmp.10_11 !=3D 200) goto ; [98.99%] so it might be the 32->64bit promotion is what gets us off. We might possibly want to consider a 'unsigned long' candidate with step 2. .L2: movl %eax, (%edx,%eax,2) addl $2, %eax cmpl $200, %eax jne .L2=