<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 - LoopIdiom miscompile"
href="https://bugs.llvm.org/show_bug.cgi?id=52104">52104</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LoopIdiom miscompile
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>courbet@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>LoopIdiom turns a loop of stores to a zero-size `llvm.memset`:
```
%struct.S = type { [4 x i32], i32 }
define void @f(%struct.S* nocapture nonnull align 4 dereferenceable(20) %0)
local_unnamed_addr #0 align 32 {
%2 = getelementptr inbounds %struct.S, %struct.S* %0, i64 0, i32 1
%3 = load i32, i32* %2, align 4
br label %4
4: ; preds = %4, %1
%5 = phi i32 [ %9, %4 ], [ %3, %1 ]
%6 = and i32 %5, 3
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds %struct.S, %struct.S* %0, i64 0, i32 0, i64 %7
store i32 0, i32* %8, align 4
%9 = add nsw i32 %5, 1
%10 = and i32 %9, 3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %4
%13 = phi i32 [ %9, %4 ]
store i32 %13, i32* %2, align 4
ret void
}
```
->
```
define void @f(%struct.S* nocapture nonnull align 4 dereferenceable(20) %0)
local_unnamed_addr align 32 {
%2 = getelementptr inbounds %struct.S, %struct.S* %0, i64 0, i32 1
%3 = load i32, i32* %2, align 4
%4 = trunc i32 %3 to i2
%5 = zext i2 %4 to i64
%scevgep = getelementptr %struct.S, %struct.S* %0, i64 0, i32 0, i64 %5
%scevgep1 = bitcast i32* %scevgep to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %scevgep1, i8 0, i64 0, i1 false)
br label %6
6: ; preds = %6, %1
%7 = phi i32 [ %11, %6 ], [ %3, %1 ]
%8 = and i32 %7, 3
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds %struct.S, %struct.S* %0, i64 0, i32 0, i64 %9
%11 = add nsw i32 %7, 1
%12 = and i32 %11, 3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = phi i32 [ %11, %6 ]
store i32 %15, i32* %2, align 4
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>