[LLVMbugs] [Bug 17028] New: bextr not generated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 28 13:28:57 PDT 2013


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

            Bug ID: 17028
           Summary: bextr not generated
           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 189409)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

$ cat bextr.c
int foo(int x)
{
    return (x >> 4) & 0xfff; /* extract bits 15:4 */
}

$ ./clang -S -O3 -march=core-avx2 bextr.c -o /dev/stdout 
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _foo
    .align    4, 0x90
_foo:                                   ## @foo
    .cfi_startproc
## BB#0:                                ## %entry
    pushq    %rbp
Ltmp2:
    .cfi_def_cfa_offset 16
Ltmp3:
    .cfi_offset %rbp, -16
    movq    %rsp, %rbp
Ltmp4:
    .cfi_def_cfa_register %rbp
    shrl    $4, %edi
    andl    $4095, %edi             ## imm = 0xFFF
    movl    %edi, %eax
    popq    %rbp
    ret
    .cfi_endproc

...

I was expecting the codegen to use the new BMI instruction "bextr" here.
Something like this would be smaller and probably faster than the current
shift/and/mov codegen:

mov 0x0C04, %eax
bextr %eax, %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/20130828/4f6aa3da/attachment.html>


More information about the llvm-bugs mailing list