<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 - Incorrect MemorySSA result after LICM"
href="https://bugs.llvm.org/show_bug.cgi?id=45927">45927</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect MemorySSA result after LICM
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mattias.v.eriksson@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I was debugging a wrong-code bug and think it is caused by LICM incorrectly
saying it preserves MemorySSA.
input.ll:
@a = external dso_local global i16, align 1
@c = external dso_local global i16, align 1
define dso_local void @main() {
entry:
%res.addr.i = alloca i16, align 1
br label %for.cond.i
for.cond.i: ; preds = %f.exit.i, %entry
%0 = load i16, i16* @c, align 1
%inc.i = add nsw i16 %0, 1
store i16 %inc.i, i16* @c, align 1
br i1 false, label %f.exit.thread.i, label %f.exit.i
f.exit.thread.i: ; preds = %for.cond.i
store i16 1, i16* @a, align 1
br label %g.exit
f.exit.i: ; preds = %for.cond.i
br i1 false, label %g.exit, label %for.cond.i
g.exit: ; preds = %f.exit.i,
%f.exit.thread.i
%1 = load i16, i16* @c, align 1
store i16 %1, i16* %res.addr.i, align 1
ret void
}
$ opt -O0 -licm -early-cse-memssa -S -o - input.ll
@a = external dso_local global i16, align 1
@c = external dso_local global i16, align 1
define dso_local void @main() {
entry:
%res.addr.i = alloca i16, align 1
%c.promoted = load i16, i16* @c, align 1
br label %for.cond.i
for.cond.i: ; preds = %f.exit.i, %entry
%inc.i1 = phi i16 [ %inc.i, %f.exit.i ], [ %c.promoted, %entry ]
%inc.i = add nsw i16 %inc.i1, 1
br i1 false, label %f.exit.thread.i, label %f.exit.i
f.exit.thread.i: ; preds = %for.cond.i
store i16 %inc.i, i16* @c, align 1
store i16 1, i16* @a, align 1
br label %g.exit
f.exit.i: ; preds = %for.cond.i
br i1 false, label %g.exit.loopexit, label %for.cond.i
g.exit.loopexit: ; preds = %f.exit.i
store i16 %inc.i, i16* @c, align 1
br label %g.exit
g.exit: ; preds = %g.exit.loopexit,
%f.exit.thread.i
store i16 %c.promoted, i16* %res.addr.i, align 1
ret void
}
The store to %res.addr.i now incorrectly stores the entry value of @c from
%c.promoted.
If I run -licm and -early-cse-memssa in separate opt processes correct code is
generated:
$ opt -O0 -licm -o - input.ll | opt -O0 -early-cse-memssa -S -o -
@a = external dso_local global i16, align 1
@c = external dso_local global i16, align 1
define dso_local void @main() {
entry:
%res.addr.i = alloca i16, align 1
%c.promoted = load i16, i16* @c, align 1
br label %for.cond.i
for.cond.i: ; preds = %f.exit.i, %entry
%inc.i1 = phi i16 [ %inc.i, %f.exit.i ], [ %c.promoted, %entry ]
%inc.i = add nsw i16 %inc.i1, 1
br i1 false, label %f.exit.thread.i, label %f.exit.i
f.exit.thread.i: ; preds = %for.cond.i
store i16 %inc.i, i16* @c, align 1
store i16 1, i16* @a, align 1
br label %g.exit
f.exit.i: ; preds = %for.cond.i
br i1 false, label %g.exit.loopexit, label %for.cond.i
g.exit.loopexit: ; preds = %f.exit.i
store i16 %inc.i, i16* @c, align 1
br label %g.exit
g.exit: ; preds = %g.exit.loopexit,
%f.exit.thread.i
%0 = load i16, i16* @c, align 1
store i16 %0, i16* %res.addr.i, align 1
ret void
}
It also works when I remove
AU.addPreserved<MemorySSAWrapperPass>();
from LegacyLICMPass::getAnalysisUsage()</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>