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

            Bug ID: 50550
           Summary: Loop simplification with invariant code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

#include <stddef.h>

bool s;


bool test1() {
    bool r = false;

    for(size_t i = 0; i < 1; ++i) {
        if (s)
            r = true;
    }

    return r;
}

bool test2() {
    bool r = false;

    for(size_t i = 0; i < 2; ++i) {
        if (s)
            r = true;
    }

    return r;
}

test1():                              # @test1()
        cmp     byte ptr [rip + s], 0
        setne   al
        ret
test2():                              # @test2()
        mov     al, byte ptr [rip + s]
        ret
s:
        .byte   0                               # 0x0

https://godbolt.org/z/rGv7z9q5W

BTW, LLVM 12 and lower produces same ideal codegen for both functions

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to