This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request of new __attribute__ for switch statements (elimination of the bounds check)
- From: "Mattias Engdegård" <mattias at virtutech dot se>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 15 Oct 2002 13:29:18 +0200
- Subject: Re: Request of new __attribute__ for switch statements (elimination of the bounds check)
>There is a value-range-propagation branch that will do it. Comes at a
>considerable cost in compile time though.
VRP, while definitely desirable for other reasons, should not be needed just
for determining that the range test for a fully populated switch can be
skipped. Even stuff like
switch (x & 127) { case 0: ... case 127: ... }
should not need full VRP, or am I mistaken?
Both Sun WorkShop C and Intel C understand this code right away with no extra
hints. Microsoft Visual C needs the hint __assume(0) in the default: branch,
but at least it's possible to eliminate the range test that way.