Bug 31137 - missing "break" in switch for MULT in avr_rtx_costs
Summary: missing "break" in switch for MULT in avr_rtx_costs
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.1.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-11 20:47 UTC by Christer Weinigel
Modified: 2007-04-09 23:45 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: avr-unknown-none
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Patch to add in the missing break statements. (252 bytes, patch)
2007-03-16 21:34 UTC, Eric Weddington
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christer Weinigel 2007-03-11 20:47:02 UTC
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.
Comment 1 Eric Weddington 2007-03-16 21:34:49 UTC
Created attachment 13217 [details]
Patch to add in the missing break statements.
Comment 2 aesok 2007-04-02 22:44:04 UTC
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

Comment 3 aesok 2007-04-02 22:53:24 UTC
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

Comment 4 aesok 2007-04-02 23:00:42 UTC
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

Comment 5 aesok 2007-04-02 23:03:51 UTC
Fixed.