<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 - Suboptimal code for (size_t) (int) (size_t) X"
href="https://bugs.llvm.org/show_bug.cgi?id=42644">42644</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Suboptimal code for (size_t) (int) (size_t) X
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>size_t pat(size_t r) {
int len = r + 1;
return len;
}
GCC -O3 trunk:
pat(unsigned long):
lea eax, [rdi+1]
cdqe
ret
CLang -O3 trunk:
pat(unsigned long):
shl rdi, 32
movabs rax, 4294967296
add rax, rdi
sar rax, 32
ret
ICC -O3 trunk:
pat(unsigned long):
inc rdi
movsxd rax, edi
ret
Maybe InstCombine is too aggresive and backend is unable to undo it?
** IR Dump After Dead Argument Elimination ***
; ModuleID = '<source>'
source_filename = "<source>"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define dso_local i64 @_Z2f2m(i64) local_unnamed_addr #0 !dbg !255 {
call void @llvm.dbg.value(metadata i64 %0, metadata !260, metadata
!DIExpression()), !dbg !262
%2 = add i64 %0, 1, !dbg !263
%3 = trunc i64 %2 to i32, !dbg !264
call void @llvm.dbg.value(metadata i32 %3, metadata !261, metadata
!DIExpression()), !dbg !262
%4 = sext i32 %3 to i64, !dbg !265
ret i64 %4, !dbg !266
}
*** IR Dump After Combine redundant instructions ***
; Function Attrs: nounwind uwtable
define dso_local i64 @_Z2f2m(i64) local_unnamed_addr #0 !dbg !255 {
call void @llvm.dbg.value(metadata i64 %0, metadata !260, metadata
!DIExpression()), !dbg !262
%2 = shl i64 %0, 32, !dbg !263
%3 = add i64 %2, 4294967296, !dbg !263
%4 = ashr exact i64 %3, 32, !dbg !263
ret i64 %4, !dbg !264
}</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>