<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - llc inserts vzeroupper before a call and spoils avx registers, which lives across the call"
href="http://llvm.org/bugs/show_bug.cgi?id=17631">17631</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llc inserts vzeroupper before a call and spoils avx registers, which lives across the call
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ili.filippov@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This bug reproduces on 32 bit both Linux and Windows. Though it seems to be
more frequently appears in real life on Windows.
Reproducer:
; ModuleID = 'a.bc'
target datalayout =
"e-p:32:32:32-S32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-win32"
%struct_type = type { [64 x <8 x float>], <8 x float> }
; Function Attrs: nounwind readnone
declare i32 @llvm.x86.avx.movmsk.ps.256(<8 x float>) #0
; Function Attrs: nounwind
define i32 @equal(<8 x i32> %A) #1 {
allocas:
%first_alloc = alloca [64 x <8 x i32>]
%second_alloc = alloca %struct_type
%A1 = bitcast <8 x i32> %A to <8 x float>
%A2 = call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %A1)
ret i32 %A2
}
; Function Attrs: nounwind
define i32 @before_equal() #1 {
allocas:
%A = alloca <8 x i32>
store <8 x i32> <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32
-1>, <8 x i32>* %A
%A1 = load <8 x i32>* %A
%A2 = call i32 @equal(<8 x i32> %A1)
ret i32 %A2
}
attributes #0 = { nounwind readnone }
attributes #1 = { nounwind "target-features"="+avx,+popcnt,+cmov" }
Compilation command:
<span class="quote">> llc a.ll -o a.s -mcpu=corei7-avx
> cat a.s</span >
_equal:
# BB#0: # %allocas
pushl %ebp
movl %esp, %ebp
andl $-32, %esp
movl $4160, %eax # imm = 0x1040
vzeroupper
calll __chkstk
vmovmskps %ymm0, %eax
movl %ebp, %esp
popl %ebp
vzeroupper
ret
.def _before_equal;
.scl 2;
.type 32;
.endef
.globl _before_equal
.align 16, 0x90
_before_equal: # @before_equal
# BB#0: # %allocas
pushl %ebp
movl %esp, %ebp
andl $-32, %esp
subl $64, %esp
vpcmpeqd %xmm0, %xmm0, %xmm0
vinsertf128 $1, %xmm0, %ymm0, %ymm0
vmovaps %ymm0, (%esp)
calll _equal
movl %ebp, %esp
popl %ebp
vzeroupper
ret
ymm0 is initialized by all 1s (vpcmpeqd + vinsertf128). Inside _equal function
it's assumed to be live across __chkstk call, but vzeroupper zeros upper half
of the register. Right after the call ymm0 is used (vmovmskps), which yields
incorrect value in eax (0xf instead of 0xff).</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>