<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 - Improvement Oppurtunity in CodeGen instruction Selection"
href="https://bugs.llvm.org/show_bug.cgi?id=32755">32755</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Improvement Oppurtunity in CodeGen instruction Selection
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lama.saba@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>for the following IR code
{code}
define void @foo(%struct.SA* nocapture %ctx, i32 %n) local_unnamed_addr #0 {
entry:
%h0 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 0
%0 = load i32, i32* %h0, align 8, !tbaa !1
%h3 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 3
%h4 = getelementptr inbounds %struct.SA, %struct.SA* %ctx, i64 0, i32 4
%1 = load i32, i32* %h4, align 8, !tbaa !7
%add = add i32 %0, 1
%add4 = add i32 %add, %1
store i32 %add4, i32* %h3, align 4, !tbaa !8
%add29 = add i32 %add4, %1
store i32 %add29, i32* %h4, align 8, !tbaa !7
ret void
}
{code}
The generated code from Clang with command llc test.ll -o :
{code}
# BB#0: # %entry
movl (%rdi), %eax
movl 16(%rdi), %ecx
leal (%rax,%rcx), %edx
leal 1(%rax,%rcx), %eax
movl %eax, 12(%rdi)
leal 1(%rcx,%rdx), %eax
movl %eax, 16(%rdi)
retq
{code}
It can be generated as:
{code}
# BB#0: # %entry
movl (%rdi), %eax
movl 16(%rdi), %ecx
leal 1(%rax,%rcx), %eax
movl %eax, 12(%rdi)
lea (%ecx,%eax), %newReg
movl %newReg, 16(%rdi)
retq
{code}
which avoids expensive lea instructions.
Instruction selection generates an ADD instruction which later gets replaced by
leal (%rax,%rcx), %edx (by the RA)</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>