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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to