[LLVMbugs] [Bug 17172] New: missed opportunity to use absolute value vector instruction (vpabsd)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 9 12:28:29 PDT 2013


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

            Bug ID: 17172
           Summary: missed opportunity to use absolute value vector
                    instruction (vpabsd)
           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

The following code is performing an absolute value operation on a 4 integer
array. LLVM is generating the straightforward unrolled loop code, but not
recognizing that these operations could be mapped to a single 'VPABSD'
instruction.

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

$ cat vpabsd.c 
void foo(int *x) {
    int i;
    for (i=0; i<4; i++) {
        x[i] = x[i] < 0 ? -x[i] : x[i];
    }
}

$ ./clang -S -O3 -fomit-frame-pointer -march=corei7-avx -o /dev/stdout vpabsd.c 
    .section    __TEXT,__text,regular,pure_instructions
    .globl    _foo
    .align    4, 0x90
_foo:                                   ## @foo
    .cfi_startproc
## BB#0:                                ## %entry
    movl    (%rdi), %eax
    movl    %eax, %ecx
    negl    %ecx
    cmovll    %eax, %ecx
    movl    %ecx, (%rdi)
    movl    4(%rdi), %eax
    movl    %eax, %ecx
    negl    %ecx
    cmovll    %eax, %ecx
    movl    %ecx, 4(%rdi)
    movl    8(%rdi), %eax
    movl    %eax, %ecx
    negl    %ecx
    cmovll    %eax, %ecx
    movl    %ecx, 8(%rdi)
    movl    12(%rdi), %eax
    movl    %eax, %ecx
    negl    %ecx
    cmovll    %eax, %ecx
    movl    %ecx, 12(%rdi)
    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/20130909/a4f3c900/attachment.html>


More information about the llvm-bugs mailing list