[LLVMdev] Pointer aliasing issue

Artiom Myaskouvskey artiomka at gmail.com
Mon Oct 11 01:39:56 PDT 2010


Hi,
I have a question regarding pointer aliasing.
I have following C code:

void factorial(float **a, float **b)
{
  b[2][2] = a[0][2];
  b[2][2] = a[0][1];
}


Which is converted to following LLVM IR:

define void @factorial(float** nocapture %a, float** nocapture %b) nounwind
{
entry:
  %0 = getelementptr inbounds float** %b, i64 2   ; <float**> [#uses=2]
  %1 = load float** %0, align 8                   ; <float*> [#uses=1]
  %2 = load float** %a, align 8                   ; <float*> [#uses=1]
  %3 = getelementptr inbounds float* %2, i64 2    ; <float*> [#uses=1]
  %4 = load float* %3, align 4 ; <float> [#uses=1]
  %5 = getelementptr inbounds float* %1, i64 2    ; <float*> [#uses=1]
  store float %4, float* %5, align 4
  %6 = load float** %0, align 8                   ; <float*> [#uses=1]
  %7 = load float** %a, align 8                   ; <float*> [#uses=1]
  %8 = getelementptr inbounds float* %7, i64 1    ; <float*> [#uses=1]
  %9 = load float* %8, align 4                    ; <float> [#uses=1]
  %10 = getelementptr inbounds float* %6, i64 2   ; <float*> [#uses=1]
  store float %9, float* %10, align 4
  ret void
}


Assuming that a and b arrays contains pointers that are not aliased,
is it possible to remove the first store by using some C or LLVM IR specific
declarations?

Thanks.

-- 
Artiom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101011/04ae2501/attachment.html>


More information about the llvm-dev mailing list