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

            Bug ID: 50545
           Summary: Failure to optimize loop of and by progressively
                    bigger operand to single and+select
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedb...@nondot.org
          Reporter: gabrav...@gmail.com
                CC: llvm-bugs@lists.llvm.org

int f(int c)
{
    int i = 1;
    while ((c & i)) {
        c &= i;
        i <<= 1;
    }
    return c;
}

This can be optimized to `return (c & 1) == 0 ? c : (c & 1);`. This
transformation is done by GCC, but not by LLVM.

Godbolt comparison: https://godbolt.org/z/oTxbxv5fo
alive2 comparison: https://alive2.llvm.org/ce/z/oDxuS4

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