[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-dev
Subject:    [LLVMdev] Pointer aliasing issue
From:       Artiom Myaskouvskey <artiomka () gmail ! com>
Date:       2010-10-11 8:39:56
Message-ID: AANLkTikBUngj+Xx+AwLY27Np38Fd0NupBzh=p-yxi01z () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

<div dir="ltr">Hi, 
<div>I have a question regarding pointer aliasing.</div>
<div>I have following C code:</div>
<blockquote style="MARGIN-RIGHT: 0px">
<div>void factorial(float **a, float **b)</div>
<div>{</div>
<div>  b[2][2] = a[0][2];</div>
<div>  b[2][2] = a[0][1];</div>
<div>}</div></blockquote>
<div>  </div>
<div>Which is converted to following LLVM IR:</div>
<blockquote style="MARGIN-RIGHT: 0px">
<div>define void @factorial(float** nocapture %a, float** nocapture %b) nounwind {</div>
<div>entry:</div>
<div>  %0 = getelementptr inbounds float** %b, i64 2   ; &lt;float**&gt; [#uses=2]</div>
<div>  %1 = load float** %0, align 8                   ; &lt;float*&gt; [#uses=1]</div>
<div>  %2 = load float** %a, align 8                   ; &lt;float*&gt; [#uses=1]</div>
<div>  %3 = getelementptr inbounds float* %2, i64 2    ; &lt;float*&gt; [#uses=1]</div>
<div>  %4 = load float* %3, align 4 ; &lt;float&gt; [#uses=1]</div>
<div>  %5 = getelementptr inbounds float* %1, i64 2    ; &lt;float*&gt; [#uses=1]</div>
<div>  store float %4, float* %5, align 4</div>
<div>  %6 = load float** %0, align 8                   ; &lt;float*&gt; [#uses=1]</div>
<div>  %7 = load float** %a, align 8                   ; &lt;float*&gt; [#uses=1]</div>
<div>  %8 = getelementptr inbounds float* %7, i64 1    ; &lt;float*&gt; [#uses=1]</div>
<div>  %9 = load float* %8, align 4                    ; &lt;float&gt; [#uses=1]</div>
<div>  %10 = getelementptr inbounds float* %6, i64 2   ; &lt;float*&gt; [#uses=1]</div>
<div>  store float %9, float* %10, align 4</div>
<div>  ret void</div>
<div>}</div></blockquote>
<div>  </div>
<div>Assuming that a and b arrays contains pointers that are not aliased,</div>
<div>is it possible to remove the first store by using some C or LLVM IR specific declarations?</div>
<div>  </div>
<div>Thanks.</div>
<div clear="all"> </div>
<div>-- </div>
<div>Artiom</div>
<div> </div></div>


_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic