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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to