[LLVMbugs] [Bug 13307] New: Failure to notice that all arguments of a phi are the same

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 9 10:47:21 PDT 2012


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

             Bug #: 13307
           Summary: Failure to notice that all arguments of a phi are the
                    same
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


We compile

void * malloc_rtree_get(void **node) {
  void *ret;
  unsigned i;

  for (i = 0; i < 10; i++) {
    void **child = (void**)node[0];
    if (child == ((void*)0)) {
      return (((void*)0));
    }
    node = child;
  }
  ret = node[0];
  return (ret);
}

to


define i8* @malloc_rtree_get(i8** nocapture %node) nounwind uwtable readonly
ssp {
entry:
  br label %for.cond
for.cond:                                         ; preds = %if.end, %entry
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %if.end ]
  %node.addr.0 = phi i8** [ %node, %entry ], [ %1, %if.end ]
  %cmp = icmp ult i32 %i.0, 10
  %0 = load i8** %node.addr.0, align 8, !tbaa !0
  br i1 %cmp, label %for.body, label %return
for.body:                                         ; preds = %for.cond
  %cmp1 = icmp eq i8* %0, null
  br i1 %cmp1, label %return, label %if.end
if.end:                                           ; preds = %for.body
  %1 = bitcast i8* %0 to i8**
  %inc = add i32 %i.0, 1
  br label %for.cond
return:                                           ; preds = %for.cond,
%for.body
  %retval.0 = phi i8* [ null, %for.body ], [ %0, %for.cond ]
  ret i8* %retval.0
}

Note that if we jump from for.body to return then %0 is null and we could just
use %0 instead of creating %retval.0.

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