<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - logic function not optimized"
href="http://llvm.org/bugs/show_bug.cgi?id=15187">15187</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>logic function not optimized
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.2
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>matic@nimp.co.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=9973" name="attach_9973" title="C source file to reproduce the problem, IAR compiler output, LLVM 3-2 output">attachment 9973</a> <a href="attachment.cgi?id=9973&action=edit" title="C source file to reproduce the problem, IAR compiler output, LLVM 3-2 output">[details]</a></span>
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 ...)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>