[LLVMbugs] [Bug 4189] New: redundant load from constant not eliminated

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon May 11 03:48:02 PDT 2009


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

           Summary: redundant load from constant not eliminated
           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: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


void
copy_text (char *p)
{
  const char *text = "hello world/n";
  do
    {
      *p = *text;
    }
  while (*text++);
}

->

@.str = internal constant [14 x i8] c"hello world/n\00"         ; <[14 x i8]*>
[#uses=1]

define void @copy_text(i8* nocapture %p) nounwind {
entry:
        br label %bb

bb:             ; preds = %bb, %entry
        %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %bb ]          ; <i64>
[#uses=2]
        %tmp = add i64 %indvar, ptrtoint ([14 x i8]* @.str to i64)             
; <i64> [#uses=1]
        %text.0 = inttoptr i64 %tmp to i8*              ; <i8*> [#uses=2]
        %0 = load i8* %text.0, align 1          ; <i8> [#uses=1]
        store i8 %0, i8* %p, align 1
        %1 = load i8* %text.0, align 1          ; <i8> [#uses=1]
        %2 = icmp eq i8 %1, 0           ; <i1> [#uses=1]
        %indvar.next = add i64 %indvar, 1               ; <i64> [#uses=1]
        br i1 %2, label %return, label %bb

return:         ; preds = %bb
        ret void
}

The second load is redundant.


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