<div dir="ltr">Hi  Dibyendu,<div><br></div><div>It would be very helpful if you could post the original source code or snippet.</div><div>That way, one can investigate deeper to understand the problem.</div><div><br></div><div>Regards,</div><div>Kamal Sharma</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 22, 2015 at 4:44 PM, Dibyendu Majumdar <span dir="ltr"><<a href="mailto:mobile@majumdar.org.uk" target="_blank">mobile@majumdar.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 22 February 2015 at 22:54, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br>
>> I tried setting the module's DataLayout  to the engine's DataLayout.<br>
>> Don't see any improvement.<br>
>> The memcpy() is to perform a struct assign, so I tried replacing that<br>
>> with member by member store.<br>
>> But even then the loads are not being eliminated so I guess the<br>
>> memcpy() isn't the issue.<br>
><br>
> If you run the IR through opt -O3 do you get the optimization you expect?<br>
><br>
<br>
</span>Hi,<br>
Tried that - no improvement.<br>
<br>
Also tried removing the redundant GEP instructions, leaving just the<br>
loads. Here is a dump that shows the output after running the<br>
optimizer passes (this is from the passes in my program not opt -O3;<br>
this version does not use memcpy() either):<br>
<br>
  %L_ci = getelementptr inbounds %ravi.lua_State* %L, i64 0, i32 6<br>
  %0 = load %ravi.CallInfo** %L_ci, align 8<br>
  %base = getelementptr inbounds %ravi.CallInfo* %0, i64 0, i32 4, i32 0<br>
  %1 = bitcast %ravi.CallInfo* %0 to %ravi.LClosure***<br>
  %2 = load %ravi.LClosure*** %1, align 8<br>
  %3 = load %ravi.LClosure** %2, align 8<br>
  %Proto = getelementptr inbounds %ravi.LClosure* %3, i64 0, i32 5<br>
  %4 = load %ravi.Proto** %Proto, align 8<br>
  %k = getelementptr inbounds %ravi.Proto* %4, i64 0, i32 14<br>
  %5 = load %ravi.TValue** %k, align 8<br>
  %6 = load %ravi.TValue** %base, align 8<br>
  %srcvalue = getelementptr inbounds %ravi.TValue* %5, i64 0, i32 0, i32 0<br>
  %destvalue = getelementptr inbounds %ravi.TValue* %6, i64 0, i32 0, i32 0<br>
  %7 = load double* %srcvalue, align 8<br>
  store double %7, double* %destvalue, align 8<br>
  %srctype = getelementptr inbounds %ravi.TValue* %5, i64 0, i32 1<br>
  %desttype = getelementptr inbounds %ravi.TValue* %6, i64 0, i32 1<br>
  %8 = load i32* %srctype, align 4<br>
  store i32 %8, i32* %desttype, align 4<br>
  %9 = load %ravi.TValue** %base, align 8<br>
  %srcvalue1 = getelementptr inbounds %ravi.TValue* %5, i64 1, i32 0, i32 0<br>
  %destvalue2 = getelementptr inbounds %ravi.TValue* %9, i64 1, i32 0, i32 0<br>
  %10 = load double* %srcvalue1, align 8<br>
  store double %10, double* %destvalue2, align 8<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
Regards<br>
Dibyendu<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>