Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Dibyendu Majumdar <mobile <at> majumdar.org.uk>
Subject: Eliminating redundant loads
Newsgroups: gmane.comp.compilers.llvm.devel
Date: Sunday 22nd February 2015 20:42:28 UTC (over 3 years ago)
Hi,

I am generating following code:

  %base = getelementptr inbounds %ravi.CallInfo* %6, i32 0, i32 4, i32 0
  %7 = load %ravi.TValue** %base
  %8 = bitcast %ravi.TValue* %7 to i8*
  %9 = bitcast %ravi.TValue* %5 to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %8, i8* %9, i32 16, i32 8, i1
false)
  %10 = load %ravi.CallInfo** %L_ci
  %base1 = getelementptr inbounds %ravi.CallInfo* %10, i32 0, i32 4, i32 0
  %11 = load %ravi.TValue** %base1
  %12 = getelementptr inbounds %ravi.TValue* %11, i32 1
  %13 = getelementptr inbounds %ravi.TValue* %5, i32 1
  %14 = bitcast %ravi.TValue* %12 to i8*
  %15 = bitcast %ravi.TValue* %13 to i8*
  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %14, i8* %15, i32 16, i32 8, i1
false
)
  %16 = load %ravi.CallInfo** %L_ci
  %base2 = getelementptr inbounds %ravi.CallInfo* %16, i32 0, i32 4, i32 0
  %17 = load %ravi.TValue** %base2

Now base, base2 and base1 are really the same - i.e., nothing's
happened to change the pointer held at this location. So should I
expect the redundant getelementptr and load instructions to be
eliminated during optimization phase?

I am using the optimisation passes as described in Kaleidoscope
tutorial but it seems that the redundant loads are not being removed.

Is it the call to memcpy that's preventing this?

Thanks and Regards
Dibyendu
 
CD: 4ms