How can it be so sure that they won't overlap? Does it do runtime checking (which would be pretty slow...)?
You can promise the C/C++ compiler that two pointers won't overlap using __restrict:
int fast(int * __restrict A, int * __restrict B)
{
*A = 5;
*B = 7; // RESTRICT promises that A != B
return *A + *B; // no stall; the compiler hangs onto
// 5 and 7 in the registers.
}
int slow(int *A, int *B)
{
*A = 5;
*B = 7;
return *A + *B; // LHS stall: the compiler doesn't
// know whether A == B, so it has to
// reload both before the add
}