[PATCH] Fix 'array subscript is above array bounds' warning in res_send.c
Ondřej Bílka
neleai@seznam.cz
Tue Dec 16 22:00:00 GMT 2014
On Tue, Dec 16, 2014 at 10:05:36AM -0800, Roland McGrath wrote:
> When changing the source code does not actually cause any de-optimization
> of the generated code, then it seems cleaner to change the code rather than
> to suppress the warning. In this case, changing the condition will change
> what conditional-branch instruction is emitted, but it won't change the
> number (or size) of instructions emitted or change anything that would
> affect performance.
That is false, could change code as compiler thinks that branches with
equality are less probable than with inequality and decide to optimize
branch for size only where there is equality.
A simplest example is look on icc assembly as it also writes guessed
probabilities.
icc -O3 test.c -S
test.c:
int foo(int x)
{
return (x == 42) ? sin (32.0) : cos (14.3);
}
test.s:
je ..B1.4 # Prob 16% #4.16
test.c:
int foo(int x)
{
return (x >= 42) ? sin (32.0) : cos (14.3);
}
test.s:
jl ..B1.3 # Prob 50% #4.16
More information about the Libc-alpha
mailing list