<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 - Loop vectorizer miscompile; regression from r344613"
href="https://bugs.llvm.org/show_bug.cgi?id=39653">39653</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop vectorizer miscompile; regression from r344613
</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>Windows NT
</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>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>efriedma@codeaurora.org
</td>
</tr>
<tr>
<th>CC</th>
<td>anna@azul.com, ayal.zaks@intel.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Testcase follows; optimize with opt -loop-vectorize. The vectorizer completely
ignores the dependence between the load and store to the alloca, and vectorizes
anyway; this leads to a miscompile.
I can come up with an executable testcase, if necessary, but hopefully the
issue here is obvious enough.
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
define void @foo(i32 %arg, i32 %arg1, i64 %arg2, i16* %arg3, i32 %arg4, i64
%arg5) {
bb:
%tmp = alloca i32
store i32 %arg4, i32* %tmp
%tmp6 = getelementptr inbounds i16, i16* %arg3, i64 %arg5
br label %bb7
bb7:
%tmp8 = phi i64 [ 0, %bb ], [ %tmp24, %bb7 ]
%tmp9 = phi i32 [ %arg1, %bb ], [ %tmp23, %bb7 ]
%tmp10 = load i32, i32* %tmp
%tmp11 = mul nsw i32 %tmp9, %tmp10
%tmp12 = srem i32 %tmp11, 65536
%tmp13 = add nsw i32 %tmp12, %tmp9
%tmp14 = trunc i32 %tmp13 to i16
%tmp15 = trunc i64 %tmp8 to i32
%tmp16 = add i32 %arg, %tmp15
%tmp17 = zext i32 %tmp16 to i64
%tmp18 = getelementptr inbounds i16, i16* %tmp6, i64 %tmp17
store i16 %tmp14, i16* %tmp18, align 2
%tmp19 = add i32 %tmp13, %tmp9
%tmp20 = trunc i32 %tmp19 to i16
%tmp21 = and i16 %tmp20, 255
%tmp22 = getelementptr inbounds i16, i16* %arg3, i64 %tmp17
store i16 %tmp21, i16* %tmp22, align 2
%tmp23 = add nsw i32 %tmp9, 1
%tmp24 = add nuw nsw i64 %tmp8, 1
%tmp25 = icmp eq i64 %tmp24, %arg2
store i32 %tmp12, i32* %tmp
br i1 %tmp25, label %bb26, label %bb7
bb26:
ret void
}</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>