[LLVMbugs] [Bug 20809] New: [EarlyCSE, Missed Opt] Value forwarding based on writes which are not stores

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 29 14:24:15 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20809

            Bug ID: 20809
           Summary: [EarlyCSE, Missed Opt] Value forwarding based on
                    writes which are not stores
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: listmail at philipreames.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12959
  --> http://llvm.org/bugs/attachment.cgi?id=12959&action=edit
Failing test case for EarlyCSE (undef load from malloc)

In EarlyCSE, we currently perform value forwarding on loads from the same
generation and the single write which defines the generation.  We also define a
new generation for other instructions which may write (rmw ops, calls, etc),
and some of those have well defined effects that we can exploit.  

As an example, consider a load which reads uninitialized memory.  We can
forward an undef value to the consumers of the load.  For example (also
attached):
declare i8* @malloc(i64) nounwind
define i8 @test1() {
entry:
  %call = tail call i8* @malloc(i64 100) nounwind
  %0 = load i8* %call, align 1 <-- can become undef
  ret i8 %0
}

Similarly, there are some classes of stores which can be trivially removed.  As
an example, we can remove stores of a zero value to calloc initialized memory
(if there are no intervening stores).  

Both of these optimizations are already implemented elsewhere (GVN and DSE
respectively), but would be cheap to implement in EarlyCSE and may expose
additional optimization oppurtunities in later passes.  My suggested
implementation strategy would be to extract the current functionality as a set
of helper routines and use them in both passes.  

Going even one step farther, some non-load instructions have well understood
read sets.  (Ex: memcpy from malloced memory)  This might be worth exploring as
well, but is substaintially more complicated and is probably best done as a
separate effort.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140829/afb1d56f/attachment.html>


More information about the llvm-bugs mailing list