From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8178C3858CDA; Tue, 26 Jul 2022 05:59:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8178C3858CDA From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106415] loop-ivopts prevents correct usage of dbra with 16-bit loop counters on m68k Date: Tue, 26 Jul 2022 05:59:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw 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: cc 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jul 2022 05:59:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106415 Kewen Lin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |linkw at gcc dot gnu.org --- Comment #5 from Kewen Lin --- At the top of tree-ssa-loop-ivopts.cc file, there are some useful comments describing the costs for iv candidate itself and group, it may help. : cand cost 0 5 1 5 2 5 3 4 4 5 5 5 6 5 7 5 8 5 This part is for "variable costs". : Group 0: cand cost compl. inv.expr. inv.vars 0 400 0 NIL; NIL; 7 0 0 NIL; NIL; 8 400 0 NIL; NIL; This part is for "group/use costs". There would be no dumping for a candidate when it has infinite cost for the group, so the above means only candidate 0, 7 and 8 are valid to be used for group 0. Final cost looks like: cost: 7 (complexity 0) reg_cost: 2 cand_cost: 5 cand_group_cost: 0 (complexity 0) candidates: 7 group:0 --> iv_cand:7, cost=3D(0,0) group:1 --> iv_cand:7, cost=3D(0,0) invariant variables: invariant expressions: ---- By quick checking, it looks the inf cost for the pair (cand 3, group 0) is = due to: /* Check if we have enough precision to express the values of use. */ if (TYPE_PRECISION (utype) > TYPE_PRECISION (ctype)) return infinite_cost;=