[LLVMbugs] [Bug 5816] New: Scalarrepl leads to nasty results with function equivalent to fixed-size memmove

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 16 21:03:53 PST 2009


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

           Summary: Scalarrepl leads to nasty results with function
                    equivalent to fixed-size memmove
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu, regehr at cs.utah.edu


C Testcase:
#include <string.h>
void a(char* a, char* b) { char c[100]; memcpy(c, a, sizeof(c)); memcpy(b, c,
sizeof(c)); }

IR Testcase (C testcase run through -mem2reg):
define void @a(i8* %a, i8* %b) nounwind {
entry:
  %c = alloca [100 x i8], align 1                ; <[100 x i8]*> [#uses=2]
  %arraydecay = getelementptr inbounds [100 x i8]* %c, i32 0, i32 0 ; <i8*>
[#uses=1]
  call void @llvm.memcpy.i32(i8* %arraydecay, i8* %a, i32 100, i32 1)
  %arraydecay2 = getelementptr inbounds [100 x i8]* %c, i32 0, i32 0 ; <i8*>
[#uses=1]
  call void @llvm.memcpy.i32(i8* %b, i8* %arraydecay2, i32 100, i32 1)
  ret void
}
declare void @llvm.memcpy.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind

Result of running -scalarrepl:
define void @a(i8* %a, i8* %b) nounwind {
entry:
  %0 = bitcast i8* %a to i800*                    ; <i800*> [#uses=1]
  %srcval1 = load i800* %0, align 1               ; <i800> [#uses=1]
  %1 = bitcast i8* %b to i800*                    ; <i800*> [#uses=1]
  store i800 %srcval1, i800* %1, align 1
  ret void
}

The i800 load+store turns into completely nasty code, essentially an expanded
memmove.

Testcase derived from pattern seen in "embarassing" code examples.


-- 
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