<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">One of my coworkers ran across a very
      similar case as well.  He's still reducing his test case to
      identify the problematic area, but based on the initial results,
      it looks like we have an overly conservative aliasing result being
      returned for two locations in disjoint elements of an array.  Your
      example is slightly different, but an imprecise alias query (i.e.
      not recognizing that the load is completely covered by the store)
      might explain it as well.  <br>
      <br>
      If you could file a bug with your example, that would be helpful. 
      If you can further reduce it that would be nice, but you've
      already gotten it down small enough to be useful.  Thanks.<br>
      <br>
      Philip<br>
      <br>
      On 09/09/2014 09:30 AM, Peng Cheng wrote:<br>
    </div>
    <blockquote
cite="mid:CAKYsbjuc2c5Vr2mCioF-vEjMXcuU2m8Y4H1-VJeE3836M8iUSw@mail.gmail.com"
      type="cite">
      <div dir="ltr">I have the following simplified llvm ir, which
        basically returns value based on the first value of a constant
        array.  
        <div><br>
        </div>
        <div>----</div>
        <div>
          <div>; ModuleID = 'simple_ir3.txt'</div>
          <div><br>
          </div>
          <div>@f.b = constant [1 x i32] [i32 1], align 4          ;
            constant array with value 1 at the first element</div>
          <div><br>
          </div>
          <div>define void @f(i32* nocapture %l0) {</div>
          <div>entry:</div>
          <div>  %fc_ = alloca [1 x i32]</div>
          <div>  %f.b.v = load [1 x i32]* @f.b</div>
          <div>  store [1 x i32] %f.b.v, [1 x i32]* %fc_</div>
          <div>  %0 = getelementptr [1 x i32]* %fc_, i64 0, i64 0  ;
            load the first element of the constant array, which is
            actually 1</div>
          <div>  %1 = load i32* %0</div>
          <div>  %tobool = icmp ne i32 %1, 0             ; check the
            first element to see if it is 1, which is actually always
            true since the first element of constant array is 1</div>
          <div>  br i1 %tobool, label %2, label %4</div>
          <div><br>
          </div>
          <div>; <label>:2               ; true branch</div>
          <div>  store i32 1, i32* %l0;</div>
          <div>  %3 = load i32* %l0;</div>
          <div>  br label %4</div>
          <div><br>
          </div>
          <div>; <label>:4</div>
          <div>  %storemerge = phi i32 [ %3, %2 ], [ 0, %entry ]</div>
          <div>  store i32 %storemerge, i32* %l0</div>
          <div>  ret void</div>
          <div>}</div>
        </div>
        <div>---</div>
        <div><br>
        </div>
        <div>I ran opt -O3 simple_ir.txt -S, and got:</div>
        <div><br>
        </div>
        <div>---</div>
        <div>
          <div>; ModuleID = 'simple_ir3.txt'</div>
          <div><br>
          </div>
          <div>@f.b = constant [1 x i32] [i32 1], align 4</div>
          <div><br>
          </div>
          <div>; Function Attrs: nounwind</div>
          <div>define void @f(i32* nocapture %l0) #0 {</div>
          <div>entry:</div>
          <div>  %fc_ = alloca [1 x i32]</div>
          <div>  store [1 x i32] [i32 1], [1 x i32]* %fc_</div>
          <div>  %0 = getelementptr [1 x i32]* %fc_, i64 0, i64 0</div>
          <div>  %1 = load i32* %0</div>
          <div>  %tobool = icmp eq i32 %1, 0</div>
          <div>  br i1 %tobool, label %3, label %2</div>
          <div><br>
          </div>
          <div>; <label>:2                                       ;
            preds = %entry</div>
          <div>  store i32 1, i32* %l0</div>
          <div>  br label %3</div>
          <div><br>
          </div>
          <div>; <label>:3                                       ;
            preds = %entry, %2</div>
          <div>  %storemerge = phi i32 [ 1, %2 ], [ 0, %entry ]</div>
          <div>  store i32 %storemerge, i32* %l0</div>
          <div>  ret void</div>
          <div>}</div>
          <div><br>
          </div>
          <div>attributes #0 = { nounwind }</div>
        </div>
        <div>---</div>
        <div><br>
        </div>
        <div>I would expect that the constant folding, or some other
          transformations, would be able to fold the constant to get the
          following ir:<br>
        </div>
        <div><br>
        </div>
        <div>---</div>
        <div>
          <div>define void @f(i32* nocapture %l0) #0 {</div>
          <div>  store i32 1, i32* %l0</div>
          <div>  ret void</div>
          <div>}</div>
        </div>
        <div>---</div>
        <div><br>
        </div>
        <div>How could I get the expected optimized ir?  update the
          original ir, or use different set of transformations?</div>
        <div><br>
        </div>
        <div>Any suggestions or comments?  </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>-Peng</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>