[LLVMbugs] [Bug 6155] New: Unneeded load not eliminated

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Jan 26 20:45:28 PST 2010


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

           Summary: Unneeded load not eliminated
           Product: new-bugs
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: code-quality, regression
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: abbeyj at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=4125)
 --> (http://llvm.org/bugs/attachment.cgi?id=4125)
Example input

Take the following input:
define i32 @foo(i32* %stack) {
  %stack1 = getelementptr i32* %stack, i32 1  ; &stack[1]
  store i32 10, i32* %stack                   ; stack[0] = 10
  store i32 20, i32* %stack1                  ; stack[1] = 20
  %retval = load i32* %stack                  ; return stack[0] (i.e. 10)
  ret i32 %retval
}

Running this through `opt -O3` from LLVM 2.6, the load will be eliminated:
define i32 @foo(i32* nocapture %stack) nounwind {
  %stack1 = getelementptr i32* %stack, i64 1
  store i32 10, i32* %stack
  store i32 20, i32* %stack1
  ret i32 10
}

But with current trunk the load is not eliminated:
define i32 @foo(i32* nocapture %stack) nounwind {
  %stack1 = getelementptr i32* %stack, i32 1
  store i32 10, i32* %stack
  store i32 20, i32* %stack1
  %retval = load i32* %stack
  ret i32 %retval
}

Note that this happens with or without inbounds on the GEP.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list