[LLVMbugs] [Bug 17956] New: LLVM introduces unneeded shifts in bitfield comparison

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Nov 16 00:49:54 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=17956

            Bug ID: 17956
           Summary: LLVM introduces unneeded shifts in bitfield comparison
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: david.majnemer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

consider:
struct foo {
  int f_x : 1;
  int f_y : 1;
};

int foo(struct foo *f) {
  return f->f_x == f->f_y;
}

we generate:
    movb    (%rdi), %al
    movb    %al, %cl
    shlb    $6, %cl
    sarb    $7, %cl
    shlb    $7, %al
    sarb    $7, %al
    cmpb    %cl, %al
    sete    %al
    movzbl    %al, %eax
    ret

All of those shifts seem superfluous:
    movl    (%rdi), %ecx
    testl    %ecx, %ecx
    sete    %al # set $al to 1 if *f == zero
    cmpl    $3, %ecx
    sete    %cl # set $cl to 1 if *f == 3
    orb    %al, %cl
    movzbl    %cl, %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/20131116/19716343/attachment.html>


More information about the llvm-bugs mailing list