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

            Bug ID: 42197
           Summary: Canonicalize OR with operands which do not have shared
                    bits to ADD
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: david.bolvan...@gmail.com
                CC: llvm-bugs@lists.llvm.org

typedef unsigned char byte;

byte add_no_common_bits(byte x, byte y) {
    // hint, no common bits
    __builtin_assume((x & y) == 0);
    return x | y;
}

byte or_no_common_bits(byte x, byte y) {
    // hint, no common bits
    __builtin_assume((x & y) == 0);
    return x + y;
}

add_no_common_bits(unsigned char, unsigned char):
  mov eax, edi
  or eax, esi
  ret
or_no_common_bits(unsigned char, unsigned char):
  lea eax, [rsi + rdi]
  ret


If we can prove that there are no shared bits between X and Y, maybe we could
turn OR to ADD.

Or ADD to OR.. not sure which form is better.

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