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

            Bug ID: 50389
           Summary: Missed optimization for A && !B
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: mv...@google.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

The ABI dictates that bool be strictly 0 or 1. A bool value outside of 0 or 1
is UB

The compiler can optimize `A && !B1 then as `A > B`, which say under x86
becomes the macro fused op:

AAndNotBAlt(bool, bool):
        cmp     dil, sil
        jbe     .LBB1_1

instead, the compiler generates:
https://gcc.godbolt.org/z/EWx63b4nz

AAndNotB(bool, bool):
        test    edi, edi
        je      .LBB0_2
        test    sil, sil
        jne     .LBB0_2
        jmp     True()

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

Reply via email to