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

            Bug ID: 20568
           Summary: failure to remove trivially dead loop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

From
http://stackoverflow.com/questions/25151508/why-dont-modern-c-compilers-optimize-away-simple-loops-like-this-clang-msv

LLVM does not remove the loops in this code:

#include <stdio.h>
#include <time.h>

static int const N = 0x8000;

int main()
{
    clock_t const start = clock();
    for (int i = 0; i < N; ++i)
    {
        int a[N];    // Never used outside of this block, but not optimized
away
        for (int j = 0; j < N; ++j)
        {
            ++a[j];  // This is undefined behavior too, but Clang doesn't see
it
        }
    }
    clock_t const finish = clock();
    fprintf(stderr, "%u ms\n",
        static_cast<unsigned int>((finish - start) * 1000 / CLOCKS_PER_SEC));
    return 0;
}

(See also PR13050; this seems like a different problem, though.)

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