<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 - Regression with GEPs after ""[InstCombine] Negator: -(X << C) --> X * (-1 << C)"""
href="https://bugs.llvm.org/show_bug.cgi?id=51968">51968</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Regression with GEPs after ""[InstCombine] Negator: -(X << C) --> X * (-1 << C)""
</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>llvm/test/Transforms/InstCombine/icmp.llm see test24
define i1 @test24_neg_offs(i32* %p, i64 %offs) {
%p1 = getelementptr inbounds i32, i32* %p, i64 %offs
%conv1 = ptrtoint i32* %p to i64
%conv2 = ptrtoint i32* %p1 to i64
%delta = sub i64 %conv1, %conv2
%cmp = icmp eq i64 %delta, 8
ret i1 %cmp
}
After that commit, LLVM produces:
define i1 @test24_neg_offs(i32* nocapture readnone %p, i64 %offs)
local_unnamed_addr #0 {
%p1.idx.neg = mul i64 %offs, -4
%cmp = icmp eq i64 %p1.idx.neg, 8
ret i1 %cmp
}
instead of:
define i1 @mulnsw(i64 %offs) local_unnamed_addr #0 {
%cmp = icmp eq i64 %offs, -2
ret i1 %cmp
}
And there is nothing we can do that form to simplify it (missing nsw).
But.. we can add nsw on mul and everything will work fine.
define i1 @src(* %p, i64 %offs) {
%0:
%p1 = gep inbounds * %p, 4 x i64 %offs
%conv1 = ptrtoint * %p to i64
%conv2 = ptrtoint * %p1 to i64
%delta = sub i64 %conv1, %conv2
%cmp = icmp eq i64 %delta, 8
ret i1 %cmp
}
=>
define i1 @tgt(* nocapture noread nowrite %p, i64 %offs) {
%0:
%p1.idx.neg = mul nsw i64 %offs, -4
%cmp = icmp eq i64 %p1.idx.neg, 8
ret i1 %cmp
}
Transformation seems to be correct!
And then LLVM can optimize:
define i1 @mulnsw(i64 %offs) local_unnamed_addr #0 {
%p1.idx.neg = mul nsw i64 %offs, -4
%cmp = icmp eq i64 %p1.idx.neg, 8
ret i1 %cmp
}
To:
define i1 @mulnsw(i64 %offs) local_unnamed_addr #0 {
%cmp = icmp eq i64 %offs, -2
ret i1 %cmp
}</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>