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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to