[LLVMbugs] [Bug 12461] New: clang does not optimize some recursive function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 4 10:20:35 PDT 2012


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

             Bug #: 12461
           Summary: clang does not optimize some recursive function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: llvm-bugs at quasiparticle.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Given the function

int sum(int d)
{
    if (d == 99999) return 1;
    return !d ? 0 : (d + sum(d-1));
}

clang does not generate loopified code at any optimization level, while gcc
does at -O2 and above. returning 0 instead if 1 for d == 99999 lets clang
optimize the function properly.

gcc also folds evaluations of that function with arguments not too large, while
clang does not. Even in the "return 0" case, clang only inlines the function
instead evaluating it at compile time - but that's just minor.

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