[llvm-dev] RFC: Resolving TBAA issues

Ivan A. Kosarev via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 20 07:11:21 PDT 2017


Hello Daniel,

Like gcc, icc says "no alias", except when the members we access are 
part of the common initial sequence so it seems they treat it as if we 
were accessing the members through a union, which in turn looks like a 
way to handle the problem with taking pointers to union members. We know 
that gcc makes no guarantees about dereferencing of such pointers and so 
can afford the luxury of further optimizations regardless of how 
accessed members relate to common initial sequences.

Either way, they clearly do not think that these accesses may alias 
because base types have members of the same type.

https://godbolt.org/g/jqn7GC

struct BUF1 {
   char x[8];
   int b1;
};

struct BUF2 {
   char x1[7];
   char x2;
   int b2;
};

int foo(int n, struct BUF1* p, struct BUF2* q) {
     for (int i = 0; i < n; i++)
         p->b1 += q->b2;
     return 0;
}

icc -Os results in:

foo(int, BUF1*, BUF2*):
   test edi, edi #16.25
   jle ..B1.3 # Prob 0% #16.25
   inc edi #16.5
   mov eax, DWORD PTR [8+rsi] #17.9
   mov edx, DWORD PTR [8+rdx] #17.18
   sub eax, edx #17.9
   imul edx, edi #16.5
   add eax, edx #17.9
   mov DWORD PTR [8+rsi], eax #17.9
..B1.3: # Preds ..B1.1 ..B1.2
   xor eax, eax #18.12
   ret #18.12

Thanks,

-- 



More information about the llvm-dev mailing list