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)


Kevin Lawton wrote:
> The __attibute_ angle is simple, I can exactly tell the
> compiler when I care to have it applied (maybe only one
> case in all the code), and it disappears quickly with
> an #ifdef'd macro.  Which makes it play nice with "other"
> compilers.

If your proposal is actually implemented, could it please be changed
so that the attribute goes _inside_ the switch parentheses?

Then it can be used to optimise "variant type" macros without having
to uglify thousands of switch statements in a program (just the macro
definitions).  To use a few example from GCC itself, these kind of
can all be optimised in this way:

    switch (TREE_CODE (t)) { /* ... */ }
    switch (GET_CODE (rtx)) { /* ... */ }
    switch (GET_MODE (rtx)) { /* ... */ }

(I'm not sure you'd want to optimise these in GCC because of the risk
of bugs, but there are programs which use similar macros where it is
more desirable to optimise).

-- Jamie


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