<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 - remove the phi requirement that each predecessor edge has an incoming value"
href="https://bugs.llvm.org/show_bug.cgi?id=50228">50228</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>remove the phi requirement that each predecessor edge has an incoming value
</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>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>Support Libraries
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Splitting from <a class="bz_bug_link
bz_status_NEW "
title="NEW - optimizer segfault on IR input"
href="show_bug.cgi?id=46721">bug 46721</a> - this is invalid IR:
define i64 @func(i64 %x) {
L0:
switch i64 %x, label %L2 [
i64 1, label %L1
i64 4, label %L2
i64 6, label %L2
]
L1:
br label %L2
L2:
%r = phi i64 [%x, %L0], [42, %L1]
ret i64 %r
}
$ opt -verify phi.ll -S
PHINode should have one entry for each predecessor of its parent basic block!
%r = phi i64 [ %x, %L0 ], [ %x, %L0 ], [ 42, %L1 ]
opt: phi.ll: error: input module is broken!
--------------------------------------------------------------------------
To make it valid, we need to repeat the incoming value from %L0 three times:
once for the 'default' edge of the switch, once for case 4, and once for case
6:
define i64 @func(i64 %x) {
L0:
switch i64 %x, label %L2 [
i64 1, label %L1
i64 4, label %L2
i64 6, label %L2
]
L1: ; preds = %L0
br label %L2
L2: ; preds = %L1, %L0, %L0, %L0
%r = phi i64 [ %x, %L0 ], [ %x, %L0 ], [ %x, %L0 ], [ 42, %L1 ]
ret i64 %r
}
--------------------------------------------------------------------------
This is confusing and may cause problems for other passes as they
simplify/reduce code (SLP had a relatively recent bug report because of this).
Can we accept the reduced form as valid IR (and canonicalize to it)?</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>