https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
Bug ID: 106415
Summary: loop-ivopts prevents correct usage of dbra with 16-bit
loop counters on m68k
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
--- Comment #1 from Undefined Opcode ---
Adding `-fno-tree-loop-ivcanon -fno-ivopts` to the compiler flags ensures the
second example function gets a properly optimized DBRA loop.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
--- Comment #3 from Undefined Opcode ---
Created attachment 53348
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53348&action=edit
dump of buggy optimization pass
(In reply to Andrew Pinski from comment #2)
> I suspect this is a target co
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
--- Comment #4 from Undefined Opcode ---
As an experiment, I added the following logic to m68k_rtx_costs():
case PLUS:
//
if(TUNE_68000_10 && !(mode == QImode || mode == HImode))
{
*total = 400; // make non-b
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
--- Comment #6 from Undefined Opcode ---
(In reply to Kewen Lin from comment #5)
> 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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106415
--- Comment #7 from Undefined Opcode ---
(In reply to Undefined Opcode from comment #6)
A little more context:
Group 1:
cand costcompl. inv.expr. inv.vars
0 0 0 NIL;NIL;
1 0 0 NIL;NIL;