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

            Bug ID: 48559
           Summary: Optimizer does not take advantage of `-value ==
                    !(value -1)`
           Product: libraries
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: ju.o...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Test case:

long f(long align) {
        return (align - 1) & -align;
}

long g(long align) {
        return (align - 1) & ~(align - 1);
}

int h(long align) {
        return -align == ~(align - 1);
}

Generated assembly:

f:
        leaq    -1(%rdi), %rax
        negq    %rdi
        andq    %rdi, %rax
        retq
g:
        xorl    %eax, %eax
        retq
h:
        movl    $1, %eax
        retq

-- 
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