[llvm-bugs] [Bug 28466] New: regression of bit manipulation optimization for certain bit positions

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 7 19:40:32 PDT 2016


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

            Bug ID: 28466
           Summary: regression of bit manipulation optimization for
                    certain bit positions
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nowak-llvm at tepeserwery.pl
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

f1 and f2 have the same meaning but produce different code - f2 is not
correctly optimized and this happens only with bits 7, 15 and 31.
3.7.1 didn't have this problem.

unsigned int f1(unsigned int v) {
  unsigned int r = (v & 0x80u) ? v : (v | 0x80u);
  return r;
}

unsigned int f2(unsigned int v) {
  unsigned int r;
  if (v & 0x80u) {
    r = v;
  } else {
    r = v | 0x80u;
  }
  return r;
}

unsigned int f3(unsigned int v) {
  unsigned int r;
  if (v & 0x40u) {
    r = v;
  } else {
    r = v | 0x40u;
  }
  return r;
}

f1(unsigned int):                                 # @f1(unsigned int)
        orl     $128, %edi
        movl    %edi, %eax

f2(unsigned int):                                 # @f2(unsigned int)
        movl    %edi, %eax
        orl     $128, %eax
        testb   %dil, %dil
        cmovsl  %edi, %eax

f3(unsigned int):                                 # @f3(unsigned int)
        orl     $64, %edi
        movl    %edi, %eax

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160708/71e50c5e/attachment.html>


More information about the llvm-bugs mailing list