public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: gertom@rgai.hu
To: gcc-gnats@gcc.gnu.org
Subject: middle-end/9707: Unnecessary range test in switches with less than 4 cases
Date: Fri, 14 Feb 2003 16:46:00 -0000	[thread overview]
Message-ID: <20030214164315.26069.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2604 bytes --]


>Number:         9707
>Category:       middle-end
>Synopsis:       Unnecessary range test in switches with less than 4 cases
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 14 16:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Tamás Gergely
>Release:        gcc version 3.3 20030210 (prerelease)
>Organization:
>Environment:
BUILD & HOST: Linux 2.4.20 i686 unknown
TARGET: arm-unknown-elf
>Description:
When a switch has less than 4 cases gcc tests for the middle-case-value and makes an additional less-greater check instead of immediately evaluating the other case-values. If there are more case branches in the switch, this kind of checking would speed up the search of the corresponding case branch (but those switches are solved with jump-tables anyway). But for only a few case branches, the direct equality checks would be better.
>How-To-Repeat:
arm-elf-gcc -S -g0 -Os -o 01_3d.s ./01_3d.i

//01_3d.i

# 1 "01_3d.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "01_3d.c"
unsigned int g;
int main ()
{
  int r;
  switch (r) {
    case 1:
             g=11;
        break;
    case 2:
             g=12;
        break;
    case 3:
             g=13;
        break;
    default:
             g=20;
        break;
  }
  return 0;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-gzip; name="switch.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="switch.tar.gz"

H4sIAAgbTT4AA+2YXW/aMBSGuQ0S/+GIbhJIJPMHHyus06RedBfTdjHtappQSA6Z1SRmjlPWTfvv
s01KUb+lCaZKfi6Iffwex8GcFwyhc55GorVPCCVkPCYtQgidjIb2Suhwc7WMOG+RyZhxRobcxikl
bNQCstdVNdSVjhVAK0OlZXG/Ls4xOcR6DswRUOgS9yFIup22675Z1CLXoSjfbiOJLIq4TCEXJW6j
12l1WYmsxBREqSGbddr2WsSihF6/0/7daYMbUTPbqtZCJ9+hp/rgRgCSuEKg001nS3ZC6ew6tlAY
n892EtgdCeyhBH5HAr8nIcVlXOf6dgYjd2b8sS8Kda1KsArT/99b+yQ2e1jt+R4P1j8ldmxT/3w0
Zq7++dDX/yEIoqXIMdip5SDS+FPba5ybog6YbWa5XMR5YEvaKS5X6DoDeLmsy0QLaeI2YAomeAex
yio4ATKAlakJNMbhOksVF2ibTuR68xIxxWa8rrCax6UsLwtZm1Yzi1Mb5zk3BZaJSqOCKr5AwFwU
oow1ppGRJMUqUHwAR2yjV9BMvZTKLEPmMqvRDBXyAn8EihkltdKF6UUfjm0r06b1encueiPB9hdG
RM2ijHS6q+U3tNxKKJluwiVuwsxlHttoniqXaVTNfQJl3oUj+8CVVk7/1U1NvjXjq2RgnsxNbO1v
Z4/sJC6ylioNMtuqxK+rXYrCq62zTh5kAxgOgLutFSmWOuienZ5OoXf28UsfeMSBEcIJowR6ZgcV
5mgMtN99JqbmeTKu7ueFTMVS4J6+CB71/yHd/v4jfGz0bDwh3v8Pgff/a/9/2PVvy7zhe5475gCT
Frjfezx2/ieTUeP/lE+YO/8z7v3/ILyXa9DSGOsKY3vafWG8uwgxX4ZZkkD4GcKMQPipglBCc1aE
6BU5wL9GHo/H4/F4PB6Px+PxeDwej8fj+Rf+AoRk6ToAKAAA


                 reply	other threads:[~2003-02-14 16:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030214164315.26069.qmail@sources.redhat.com \
    --to=gertom@rgai.hu \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).