<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 - memcpyopt adds incorrect align to memset"
href="https://bugs.llvm.org/show_bug.cgi?id=44388">44388</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>memcpyopt adds incorrect align to memset
</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>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>juneyoung.lee@sf.snu.ac.kr
</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=22966" name="attach_22966" title="memset.src.ll">attachment 22966</a> <a href="attachment.cgi?id=22966&action=edit" title="memset.src.ll">[details]</a></span>
memset.src.ll
```
$ cat memset.src.ll
; Transforms/MemCpyOpt/form-memset.ll
define void @test6(i32* nocapture %P) nounwind ssp {
entry:
%0 = bitcast i32* %P to i8*
tail call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 12, i1 false)
%add.ptr = getelementptr inbounds i32, i32* %P, i64 3
%1 = bitcast i32* %add.ptr to i8*
tail call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 12, i1 false)
ret void
}
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind
$ ../llvm/build/bin/opt -memcpyopt memset.src.ll -S -o -
; ModuleID = 'memset.src.ll'
source_filename = "memset.src.ll"
; Function Attrs: nounwind ssp
define void @test6(i32* nocapture %P) #0 {
entry:
%0 = bitcast i32* %P to i8*
%add.ptr = getelementptr inbounds i32, i32* %P, i64 3
%1 = bitcast i32* %add.ptr to i8*
%2 = bitcast i32* %P to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %2, i8 0, i64 24, i1 false)
ret void
}
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
#1
attributes #0 = { nounwind ssp }
attributes #1 = { argmemonly nounwind willreturn }
```
memcpyopt merges two memsets if they overlap and write the same value.
After merging, align 4 is added, which is incorrect because %P is not
guaranteed to have alignment 4.</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>