This is the mail archive of the gcc-help@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: How can I make this code friendly to GCC's optimizer?


On 16 March 2014 18:41, Steven Stewart-Gallus wrote:
>
> Converting an unsigned integer to a signed integer is easy in C. The
> implicit conversion works fine. However, converting from a signed
> integer to an unsigned integer invokes implementation defined
> behaviour (or can raise an implementation defined signal) if "the
> value cannot be represented in it". So I wrote some simple code to
> convert a uint_fast32_t to an int_fast32_t.

Since GCC (and Clang) do what you expect when converting from a signed
integer to an unsigned integer, the most optimizer-friendly thing to
do is rely on the implementation-defined conversion rather than doing
it yourself.


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