<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 - Wrong-code rewrite of memcpy in instcombine"
href="https://bugs.llvm.org/show_bug.cgi?id=31990">31990</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong-code rewrite of memcpy in instcombine
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mikael.holmen@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18000" name="attach_18000" title="reproducer">attachment 18000</a> <a href="attachment.cgi?id=18000&action=edit" title="reproducer">[details]</a></span>
reproducer
Running opt:
opt -S -instcombine -o - tr13025.ll
on this little program:
@g = constant i8 -1
define void @foo() {
entry:
%0 = alloca i8
%1 = bitcast i8* %0 to i4*
call void @bar(i4* %1)
%2 = bitcast i4* %1 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %2, i8* @g, i32 1, i32 1, i1 false)
call void @gaz(i8* %2)
ret void
}
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly,
i8* nocapture readonly, i32, i32, i1)
declare void @bar(i4*)
declare void @gaz(i8*)
gives:
define void @foo() {
entry:
%0 = alloca i4, align 1
call void @bar(i4* nonnull %0)
%1 = bitcast i4* %0 to i8*
store i4 -1, i4* %0, align 1
call void @gaz(i8* %1)
ret void
}
So a memcpy of one word has been replaced by a store of an i4:
store i4 -1, i4* %0, align 1
This doesn't seem right to me.
Also:
%0 = alloca i8
has been replaced with
%0 = alloca i4, align 1
since i4 and i8 have the same store sizes, but I'm not sure if that is a
problem
or not.
The memcpy change is done by InstCombiner::SimplifyMemTransfer, especially
this code is involved:
if (SrcETy->isSized() && DL.getTypeStoreSize(SrcETy) == Size) {
// The SrcETy might be something like {{{double}}} or [1 x double]. Rip
// down through these levels if so.
SrcETy = reduceToSingleValueType(SrcETy);
Since i4 has store size 1, we pass the above check and then conclude that it's
ok to just do a store i4 -1 instead of store i8 -1.</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>