On 22 February 2015 at 20:58, David Jones <djones at xtreme-eda.com> wrote:> Not sure if this is your problem, but it was mine: > > You must create (or obtain) a DataLayout *and install it into the Module*. > > It is possible to generate machine code for IR and not install the > DataLayout into the Module. Rather, the DataLayout is used locally at the > point where code is generated. However, if you do this, then the alias > analyses required to get rid of your redundant loads and stores cannot > reason about possible aliasing. >Hi David, I tried setting the module's DataLayout to the engine's DataLayout. Don't see any improvement. The memcpy() is to perform a struct assign, so I tried replacing that with member by member store. But even then the loads are not being eliminated so I guess the memcpy() isn't the issue. Regards Dibyendu
----- Original Message -----> From: "Dibyendu Majumdar" <mobile at majumdar.org.uk> > To: "David Jones" <djones at xtreme-eda.com> > Cc: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> > Sent: Sunday, February 22, 2015 4:40:52 PM > Subject: Re: [LLVMdev] Eliminating redundant loads > > On 22 February 2015 at 20:58, David Jones <djones at xtreme-eda.com> > wrote: > > Not sure if this is your problem, but it was mine: > > > > You must create (or obtain) a DataLayout *and install it into the > > Module*. > > > > It is possible to generate machine code for IR and not install the > > DataLayout into the Module. Rather, the DataLayout is used locally > > at the > > point where code is generated. However, if you do this, then the > > alias > > analyses required to get rid of your redundant loads and stores > > cannot > > reason about possible aliasing. > > > > Hi David, > > I tried setting the module's DataLayout to the engine's DataLayout. > Don't see any improvement. > The memcpy() is to perform a struct assign, so I tried replacing that > with member by member store. > But even then the loads are not being eliminated so I guess the > memcpy() isn't the issue.If you run the IR through opt -O3 do you get the optimization you expect? -Hal> > Regards > Dibyendu > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
On 22 February 2015 at 22:54, Hal Finkel <hfinkel at anl.gov> wrote:>> I tried setting the module's DataLayout to the engine's DataLayout. >> Don't see any improvement. >> The memcpy() is to perform a struct assign, so I tried replacing that >> with member by member store. >> But even then the loads are not being eliminated so I guess the >> memcpy() isn't the issue. > > If you run the IR through opt -O3 do you get the optimization you expect? >Hi, Tried that - no improvement. Also tried removing the redundant GEP instructions, leaving just the loads. Here is a dump that shows the output after running the optimizer passes (this is from the passes in my program not opt -O3; this version does not use memcpy() either): %L_ci = getelementptr inbounds %ravi.lua_State* %L, i64 0, i32 6 %0 = load %ravi.CallInfo** %L_ci, align 8 %base = getelementptr inbounds %ravi.CallInfo* %0, i64 0, i32 4, i32 0 %1 = bitcast %ravi.CallInfo* %0 to %ravi.LClosure*** %2 = load %ravi.LClosure*** %1, align 8 %3 = load %ravi.LClosure** %2, align 8 %Proto = getelementptr inbounds %ravi.LClosure* %3, i64 0, i32 5 %4 = load %ravi.Proto** %Proto, align 8 %k = getelementptr inbounds %ravi.Proto* %4, i64 0, i32 14 %5 = load %ravi.TValue** %k, align 8 %6 = load %ravi.TValue** %base, align 8 %srcvalue = getelementptr inbounds %ravi.TValue* %5, i64 0, i32 0, i32 0 %destvalue = getelementptr inbounds %ravi.TValue* %6, i64 0, i32 0, i32 0 %7 = load double* %srcvalue, align 8 store double %7, double* %destvalue, align 8 %srctype = getelementptr inbounds %ravi.TValue* %5, i64 0, i32 1 %desttype = getelementptr inbounds %ravi.TValue* %6, i64 0, i32 1 %8 = load i32* %srctype, align 4 store i32 %8, i32* %desttype, align 4 %9 = load %ravi.TValue** %base, align 8 %srcvalue1 = getelementptr inbounds %ravi.TValue* %5, i64 1, i32 0, i32 0 %destvalue2 = getelementptr inbounds %ravi.TValue* %9, i64 1, i32 0, i32 0 %10 = load double* %srcvalue1, align 8 store double %10, double* %destvalue2, align 8 Regards Dibyendu