This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Request of new __attribute__ for switch statements (elimination of the bounds check)


--- Zack Weinberg <zack@codesourcery.com> wrote:

> Sure.  The question is how _soon_ you will be screwed to the point
> that the program crashes.  Ideally this happens as soon after the
> actual data corruption event as possible.

The question is, will the compiler allow a coder to
eliminate the check or not.  The idea is that a coder
may have confidence in the case targets.  Thinking
past that doesn't solve anything.

If we wanted to stop people from shooting theirselves
in the feet, we wouldn't allow them to use C.  At
any rate, sometimes it's even possible to prove the
case targets are populated:

  switch (a & 0x3) {
    case 0: ...
    case 1: ...
    case 2: ...
    case 3: ...
    }

This is a request for a feature for high performance programs.
Basically, I want to be able to make my own decisions because
the compiler is too brain dead to.


> It's just that I see removing the bounds checks on a switch statement
> as a marginal optimization compared to the risk.  I've never seen a
> switch be the bottleneck in anything.

Listen, when you do it 10 million times a second, you start caring.

There's nothing marginal about it.  If people don't want to
use extensions, they shouldn't.  I see it as really that
simple.

-Kevin

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]