<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 - -expandmemcmp generates loads with incorrect alignment"
href="https://bugs.llvm.org/show_bug.cgi?id=43880">43880</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-expandmemcmp generates loads with incorrect alignment
</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>Common Code Generator Code
</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>--
$ cat memcmp.ll
target datalayout = "e-i8:8:8-i16:16:16"
target triple = "x86_64-unknown-unknown"
declare i32 @memcmp(i8* nocapture, i8* nocapture, i64)
define i32 @cmp2(i8* nocapture readonly %x, i8* nocapture readonly %y) {
%call = tail call i32 @memcmp(i8* %x, i8* %y, i64 2)
ret i32 %call
}
$ ./llvm/bin/opt -expandmemcmp -S -o - memcmp.ll
; ModuleID = 'memcmp.ll'
source_filename = "memcmp.ll"
target datalayout = "e-i8:8:8-i16:16:16"
target triple = "x86_64-unknown-unknown"
declare i32 @memcmp(i8* nocapture, i8* nocapture, i64)
define i32 @cmp2(i8* nocapture readonly %x, i8* nocapture readonly %y) {
%1 = bitcast i8* %x to i16*
%2 = bitcast i8* %y to i16*
%3 = load i16, i16* %1
%4 = load i16, i16* %2
%5 = call i16 @llvm.bswap.i16(i16 %3)
%6 = call i16 @llvm.bswap.i16(i16 %4)
%7 = zext i16 %5 to i32
%8 = zext i16 %6 to i32
%9 = sub i32 %7, %8
ret i32 %9
}
; Function Attrs: nounwind readnone speculatable willreturn
declare i16 @llvm.bswap.i16(i16) #0
attributes #0 = { nounwind readnone speculatable willreturn }
--
This is incorrect because the loads in the output has align 2 (omitted
alignment in loads mean they have the ABI alignment). If %x or %y is not 2-byte
aligned, the optimized code raises undefined behavior, where as the source
wouldn't.</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>