[LLVMbugs] [Bug 17109] New: generate more efficient code for logical and operation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 5 10:45:14 PDT 2013


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

            Bug ID: 17109
           Summary: generate more efficient code for logical and operation
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: kkhoo at perfwizard.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ ./clang -v
clang version 3.4 (trunk 189776)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

$ cat and.c 
#include <stdbool.h>

bool and(unsigned int x, unsigned int y) {
        return (x != 0 && y != 0);
}

$ ./clang -S -O3 -fomit-frame-pointer and.c -o /dev/stdout 
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _and
    .align    4, 0x90
_and:                                   ## @and
    .cfi_startproc
## BB#0:                                ## %entry
    testl    %edi, %edi
    setne    %cl
    testl    %esi, %esi
    setne    %al
    andb    %cl, %al
    ret

...

I think this codegen can be improved in size and speed by taking advantage of
the fact that the x86 'test' instruction does a bitwise 'and' operation.
Something like this:

testl %edi, %esi
setne %al
ret

-- 
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/20130905/82a66a50/attachment.html>


More information about the llvm-bugs mailing list