<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - OpenPOWER: Evaluate branch before storing values"
href="https://bugs.llvm.org/show_bug.cgi?id=35336">35336</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>OpenPOWER: Evaluate branch before storing values
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</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>Keywords</th>
<td>code-quality, performance
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sbiersdorff@nvidia.com
</td>
</tr>
<tr>
<th>CC</th>
<td>eric.schweitz@pgroup.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19434" name="attach_19434" title="Example code showing performance issue">attachment 19434</a> <a href="attachment.cgi?id=19434&action=edit" title="Example code showing performance issue">[details]</a></span>
Example code showing performance issue
Consider the attached code. On entry to the ‘quick_return’ function a check is
made whether to return immediately. Hopefully if this flag is true this
function returns quickly--executing only a minimal number of instructions.
However, compare Clang generated instruction verses GNU generated code:
Clang:
0000000010000630 <quick_return>:
10000630: 02 10 40 3c lis r2,4098
10000634: 00 8c 42 38 addi r2,r2,-29696
10000638: a6 02 08 7c mflr r0
1000063c: f8 ff e1 fb std r31,-8(r1)
10000640: 10 00 01 f8 std r0,16(r1)
10000644: 91 ff 21 f8 stdu r1,-112(r1)
10000648: 78 0b 3f 7c mr r31,r1
1000064c: 00 00 03 28 cmplwi r3,0
10000650: 60 00 df fb std r30,96(r31)
10000654: 78 23 9e 7c mr r30,r4
10000658: 50 00 82 40 bne 100006a8 <quick_return+0x78>
GNU:
00000000100007c0 <quick_return>:
100007c0: 02 10 40 3c lis r2,4098
100007c4: 00 7f 42 38 addi r2,r2,32512
100007c8: 00 00 a3 2f cmpdi cr7,r3,0
100007cc: 20 00 9e 4c bnelr cr7
Notice the three ‘store’ instruction generated by Clang before the branch is
evaluated. An improvement would be generating code more similar to GNU placing
these ‘store’ instruction after the check to see if the function should return
immediately.
Note these examples both used the flag ‘-O3’.</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>