<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 - Failed to remove cmp and merge identical blocks"
href="https://bugs.llvm.org/show_bug.cgi?id=50199">50199</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Failed to remove cmp and merge identical blocks
</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>Scalar Optimizations
</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>union any {
any(any& x) {
if (x.st < 4) {
x.st = 0;
} else {
x.ex = nullptr;
}
}
long st;
void* ex;
};
void f(any* b) {
(any(*b));
}
%union.any = type { i64 }
define dso_local void @_Z1fP3any(%union.any* nocapture %0) local_unnamed_addr
#0 {
%2 = getelementptr inbounds %union.any, %union.any* %0, i64 0, i32 0
%3 = load i64, i64* %2, align 8, !tbaa !3
%4 = icmp slt i64 %3, 4
br i1 %4, label %5, label %6
5: ; preds = %1
store i64 0, i64* %2, align 8, !tbaa !3
br label %8
6: ; preds = %1
%7 = bitcast %union.any* %0 to i8**
store i8* null, i8** %7, align 8, !tbaa !3
br label %8
8: ; preds = %5, %6
ret void
}
f(any*): # @f(any*)
cmp qword ptr [rdi], 3
mov qword ptr [rdi], 0
ret
<a href="https://godbolt.org/z/b17vfY9eK">https://godbolt.org/z/b17vfY9eK</a>
It seems that backend already does a good job and merges the blocks.
Middle-end should be able to simplify this even futher - remove condition,
merge blocks & unify stores, ..</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>