[LLVMbugs] [Bug 17631] New: llc inserts vzeroupper before a call and spoils avx registers, which lives across the call
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Oct 21 03:26:54 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17631
Bug ID: 17631
Summary: llc inserts vzeroupper before a call and spoils avx
registers, which lives across the call
Product: tools
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: llc
Assignee: unassignedbugs at nondot.org
Reporter: ili.filippov at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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:
> llc a.ll -o a.s -mcpu=corei7-avx
> cat a.s
_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).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131021/923ff07b/attachment.html>
More information about the llvm-bugs
mailing list