SPRUI04F july 2015 – april 2023
The --no_bad_aliases option informs the compiler that it can make certain assumptions about how aliases are used in your code. These assumptions allow the compiler to improve optimization. The --no_bad_aliases option also specifies that loop-invariant counter increments and decrements are non-zero. Loop invariant means the value of an expression does not change within the loop.
Do not use the --aliased_variables option with the --no_bad_aliases option. If you do, the --no_bad_aliases option overrides the --aliased_variables option.
{
long l;
char *p = (char *) &l;
p[2] = 5;
}
g(int j)
{
int a[20];
f(&a, &a) /* Bad */
f(&a+42, &a+j) /* Also Bad */
}
f(int *ptr1, int *ptr2)
{
...
}
static int ary[20][20];
int g()
{
return f(5, -4); /* -4 is a negative index */
return f(0, 96); /* 96 exceeds 20 as an index */
return f(4, 16); /* This one is OK */
}
int f(int I, int j)
{
return ary[i][j];
}
In this example, ary[5][-4], ary[0][96], and ary[4][16] access the same memory location. Only the reference ary[4][16] is acceptable with the --no_bad_aliases option because both of its indices are within the bounds (0..19).
If your code does not contain any of the aliasing techniques described above, you should use the --no_bad_aliases option to improve the optimization of your code. However, you must use discretion with the --no_bad_aliases option; unexpected results may occur if these aliasing techniques appear in your code and the --no_bad_aliases option is used.