<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - GVN PRE not respecting the "inbounds" keyword of GEP"
href="https://llvm.org/bugs/show_bug.cgi?id=29057">29057</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GVN PRE not respecting the "inbounds" keyword of GEP
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>youngju.song@sf.snu.ac.kr
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Related with: <a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - GVN ignores inbounds of getelementptr"
href="show_bug.cgi?id=28562">https://llvm.org/bugs/show_bug.cgi?id=28562</a>
As stated, GVN ignores the "inbounds" keyword of GEP during numbering.
And it actually performs PRE on GEP regardless of "inbounds" keyword.
Below is the actual code transformation. (Using 'opt -gvn')
source:
================================================================
define i32* @foo(i32* %a, i1 %cond) {
entry:
br i1 %cond, label %brA, label %brB
brA:
%xA = getelementptr inbounds i32, i32* %a, i32 10
br label %out
brB:
%xB = getelementptr inbounds i32, i32* %a, i32 10
br label %out
out:
%x = getelementptr i32, i32* %a, i32 10
ret i32* %x
}
================================================================
target:
================================================================
define i32* @foo(i32* %a, i1 %cond) {
entry:
br i1 %cond, label %brA, label %brB
brA: ; preds = %entry
%xA = getelementptr inbounds i32, i32* %a, i32 10
br label %out
brB: ; preds = %entry
%xB = getelementptr inbounds i32, i32* %a, i32 10
br label %out
out: ; preds = %brB, %brA
%x.pre-phi = phi i32* [ %xB, %brB ], [ %xA, %brA ]
ret i32* %x.pre-phi
}
================================================================
This may be problematic because GEP with "inbounds" keyword may produce poison
value while normal one does not, and poison value may produce UB. More behavior
in target code is problematic.
One possible solution may to use "patchAndReplaceAllUsesWith" instead of naive
"replaceAllUsesWith" in "performScalarPRE".</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>