[LLVMbugs] [Bug 15187] New: logic function not optimized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 6 14:37:51 PST 2013


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

            Bug ID: 15187
           Summary: logic function not optimized
           Product: new-bugs
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: matic at nimp.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 9973
  --> http://llvm.org/bugs/attachment.cgi?id=9973&action=edit
C source file to reproduce the problem, IAR compiler output, LLVM 3-2 output

I gave the following function to IAR compiler (targeting CortexM0) and to
clang/LLVM 3.2 (clang -O3 -target thumbv6-eabi -emit-llvm)

int calleeSave8(int in[]){
    int out=0;
    int i;
    for(i=0;i<8;i++){
        out ^= in[i] & in[(i+1)%8];
    }//expand to out =
(in[0]&in[1])^(in[1]&in[2])^(in[2]&in[3])^(in[3]&in[4])^(in[4]&in[5])^(in[5]&in[6])^(in[6]&in[7])^(in[7]&in[0]) 
    return out;
}

In such case, IAR compiler is able to factor out half of the and operations so
it performs 4 and + 7 xor, LLVM factored only one and operation so it performs
7 and + 7 xor. (I looked at IR code and assembly output)

same thing with Cortex-M3 (clang -O3 -target thumbv7-eabi -emit-llvm ...; llc
... -debug -O3 -code-model=small -march=thumb -mcpu=cortex-m3  ...)

-- 
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/20130206/afb81466/attachment.html>


More information about the llvm-bugs mailing list