This is the mail archive of the
mailing list for the GCC project.
Re: Optimize based on possible enum class values?
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: âJosh Chia (èää) <joshchia at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 19 May 2016 13:03:28 +0300
- Subject: Re: Optimize based on possible enum class values?
- Authentication-results: sourceware.org; auth=none
- References: <CALxtSbTS96dhLiLa7ujcbpdjPSsU20SWFNjk4h6PYccq-bXHWg at mail dot gmail dot com>
On 05/19/2016 04:37 AM, âJosh Chia (èää) wrote:
> Is there a way to tell gcc to assume that the underlying integer value
> is for a valid enum value and optimize accordingly? Even more
> generally, is there a way to give optimization hints to the compiler
> that a variable can only have certain values at a certain point in the
You can use this idiom to tell GCC that 'condition' is true:
GCC is able to infer value ranges from conditions like e.g. (x >= a && x <= b).