[llvm-bugs] [Bug 41497] New: Missing optimization, elimination of empty data dependant loops

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 14 14:43:07 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41497

            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
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gareth at ignition-web.co.uk
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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
.LBB0_3:
        ret

As you can see it currently traverses pointers even though it could be
optimized away. 

6.8.2.2 Forward progress
The implementation may assume that any thread will eventually do one of the
following:

    (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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190414/b25a25ef/attachment.html>


More information about the llvm-bugs mailing list