This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Value Range Propagation Pass Status
- To: jamie dot lokier at cern dot ch (Jamie Lokier)
- Subject: Re: Value Range Propagation Pass Status
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Sat, 5 Feb 2000 13:40:03 -0800 (PST)
- Cc: john at feith dot com (John Wehle), gcc at gcc dot gnu dot org
> I'd like the range check for switches on certain enums to be eliminated.
> In C, enums can actually have a value that's not in the enumeration list
> which defeats the optimisation: you can't assume every case is covered.
The situation is a bit different in C++: the legal values the compiler may
assume for an enum are those of the smallest signed or unsigned bitfield
that includes all the values (thus for two valid enums a and b, a|b
and a&b are always valid, and anything between the two values is valid).
That was a compromise between those who wanted really strong typing
and those that wanted to make sure that traditional C usages would
continue work.
> However, there are two approaches to eliminating the bounds check:
>
> - __builtin_assume (x < 6);
>
> - __attribute__ ((bounded)) enum Foo { A, B, C} foo;
In C++, the compiler may assume that a Foo is 0, 1, 2, or 3 (so there is
one extra value).