From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C304D3858D32; Tue, 26 Jul 2022 05:01:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C304D3858D32 From: "undefinedopcode2 at gmail dot com" 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:01:51 +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: undefinedopcode2 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: --- 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 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:01:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106415 --- Comment #4 from Undefined Opcode --- As an experiment, I added the following logic to m68k_rtx_costs(): case PLUS: // if(TUNE_68000_10 && !(mode =3D=3D QImode || mode =3D=3D HImode)) { *total =3D 400; // make non-byte/word ADD outrageously expensive return true; } Sure enough, the costs for all non-short IV shot up. However, it's still choosing candidate 7, same as before: : cand cost force_expr_to_var_cost size costs: integer 2 symbol 4 address 4 other 16 force_expr_to_var_cost speed costs: integer 2 symbol 4 address 4 other 16 0 401 1 5 2 5 3 4 4 5 5 5 6 5 7 401 8 401 Later, when we get to group costs, the results aren't what I'd expect: : Group 0: cand cost compl. inv.expr. inv.vars 0 400 0 NIL; NIL; 7 0 0 NIL; NIL; 8 400 0 NIL; NIL; Group 1: cand cost compl. inv.expr. inv.vars 0 0 0 NIL; NIL; 1 0 0 NIL; NIL; 2 0 0 NIL; NIL; 3 0 0 NIL; NIL; 4 0 0 NIL; NIL; 5 0 0 NIL; NIL; 6 -1 0 NIL; NIL; 7 0 0 NIL; NIL; 8 0 0 NIL; NIL; I'm not entirely sure what's going on here. Why does candidate 7 suddenly c= ost 0?=