I have just started reading the gcc code a bit, and while looking at the avr port I noticed that in the function avr_rtx_costs in avr.c there is some code to calculate the cost of a multiplication: case MULT: switch (mode) { case QImode: if (AVR_HAVE_MUL) *total = COSTS_N_INSNS (optimize_size ? 3 : 4); else if (optimize_size) *total = COSTS_N_INSNS (AVR_MEGA ? 2 : 1); else return false; case HImode: if (AVR_HAVE_MUL) *total = COSTS_N_INSNS (optimize_size ? 7 : 10); else if (optimize_size) *total = COSTS_N_INSNS (AVR_MEGA ? 2 : 1); else return false; default: return false; } *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code); *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code); return true; if AVR_HAVE_MUL is true, the above code will be equal to the following: case MULT: switch (mode) { case QImode: *total = COSTS_N_INSNS (optimize_size ? 3 : 4); case HImode: *total = COSTS_N_INSNS (optimize_size ? 7 : 10); default: return false; } *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code); *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code); return true; which I belive is incorrect since it means that the assignments to *total in the switch statement are useless. It probably doesn't break anything serious but might give slightly worse optimizations.
Created attachment 13217 [details] Patch to add in the missing break statements.
Subject: Bug 31137 Author: aesok Date: Mon Apr 2 22:43:53 2007 New Revision: 123437 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123437 Log: PR target/31137 * config/avr/avr.c (avr_rtx_costs): Add missing 'break' statements. Modified: trunk/gcc/ChangeLog trunk/gcc/config/avr/avr.c
Subject: Bug 31137 Author: aesok Date: Mon Apr 2 22:53:14 2007 New Revision: 123438 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123438 Log: PR target/31137 * config/avr/avr.c (avr_rtx_costs): Add missing 'break' statements. Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/config/avr/avr.c
Subject: Bug 31137 Author: aesok Date: Mon Apr 2 23:00:28 2007 New Revision: 123439 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123439 Log: PR target/31137 * config/avr/avr.c (avr_rtx_costs): Add missing 'break' statements. Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/config/avr/avr.c
Fixed.