Bug ID: 41497
           Summary: Missing optimization, elimination of empty data
                    dependant loops
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs

void * x;
void test(){ for(void * p = x; p; p=*(void**)p); }

With -O3 gives:

test():                               # @test()
        mov     rax, qword ptr [rip + x]
        test    rax, rax
        je      .LBB0_3
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        mov     rax, qword ptr [rax]
        test    rax, rax
        jne     .LBB0_1

As you can see it currently traverses pointers even though it could be
optimized away. Forward progress
The implementation may assume that any thread will eventually do one of the

    (1.1) terminate,
    (1.2) make a call to a library I/O function,
    (1.3) perform an access through a volatile glvalue, or
    (1.4) perform a synchronization operation or an atomic operation.

[ Note: This is intended to allow compiler transformations such as removal of
empty loops, even when termination cannot be proven. — end note ]

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to