[llvm-bugs] [Bug 40750] New: Better optimizations for logical ops with bit fields

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 17 12:17:01 PST 2019


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

            Bug ID: 40750
           Summary: Better optimizations for logical ops with bit fields
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

Tested on Intel Haswell 4720HQ

struct test {
    int a : 1;
    int b : 1; // if changed to 2, GCC and Clang produces same codegen
};

int get(struct test *s) {
    return s->a || s->b;
}

GCC:
get:
        xor     eax, eax
        test    BYTE PTR [rdi], 3
        setne   al
        ret

Clang:
get:                                    # @get
        movzx   ecx, byte ptr [rdi]
        mov     eax, 1
        test    cl, 1
        jne     .LBB0_2
        shr     ecx
        and     ecx, 1
        mov     eax, ecx
.LBB0_2:
        ret

-- 
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/20190217/7431909d/attachment.html>


More information about the llvm-bugs mailing list