Re: [SLUG] [PIG] First post

From: Mark Polhamus (meplists@earthlink.net)
Date: Thu Apr 27 2006 - 01:45:26 EDT


Dylan William Hardison wrote:
> ...
> So, I'll throw something out there to start discussion.
>
> If SDL_BYTEORDER and SDL_BIG_ENDIAN are preprocessor constants,
> is GCC smart enough to optimize this if-else expression away?
> I have no idea, and I'm not sure how to test it.
>
> if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
> color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1],
> colorptr[2], colorptr[3]);
> } else {
> color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2],
> colorptr[1], colorptr[0]);
> }

Gcc is way too smart to emit a runtime test in this case.

To confirm:

I looked up "gcc interspersed listing" with Google and found
http://www.linuxjournal.com/article/7269 which told me that to get
interspersed C/assembler listings from gcc to use "gcc -c -g -Wa,-ahl,-L".
Judging by the output I get from some simple test programs gcc does not emit
the test or instructions for the branch never taken.

-- Mark Polhamus
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:01:01 EDT