2015-03-07 04:58:15 +08:00
|
|
|
; RUN: llc < %s -x86-use-vzeroupper -mtriple=x86_64-apple-darwin -mattr=+avx | FileCheck %s
|
2017-03-03 17:03:24 +08:00
|
|
|
; RUN: llc < %s -x86-use-vzeroupper -mtriple=x86_64-apple-darwin -mattr=+avx512f | FileCheck %s
|
|
|
|
; RUN: llc < %s -x86-use-vzeroupper -mtriple=x86_64-apple-darwin -mattr=+avx,+fast-partial-ymm-or-zmm-write | FileCheck --check-prefix=FAST-YMM-ZMM %s
|
2016-02-13 07:37:57 +08:00
|
|
|
; RUN: llc < %s -x86-use-vzeroupper -mtriple=x86_64-apple-darwin -mcpu=btver2 | FileCheck --check-prefix=BTVER2 %s
|
|
|
|
|
2017-03-03 17:03:24 +08:00
|
|
|
; FAST-YMM-ZMM-NOT: vzeroupper
|
2016-02-13 07:37:57 +08:00
|
|
|
; BTVER2-NOT: vzeroupper
|
2011-08-23 09:14:17 +08:00
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
declare i32 @foo()
|
2011-11-05 07:46:11 +08:00
|
|
|
declare <4 x float> @do_sse(<4 x float>)
|
|
|
|
declare <8 x float> @do_avx(<8 x float>)
|
|
|
|
declare <4 x float> @llvm.x86.avx.vextractf128.ps.256(<8 x float>, i8) nounwind readnone
|
|
|
|
@x = common global <4 x float> zeroinitializer, align 16
|
|
|
|
@g = common global <8 x float> zeroinitializer, align 32
|
|
|
|
|
|
|
|
;; Basic checking - don't emit any vzeroupper instruction
|
2011-08-23 09:14:17 +08:00
|
|
|
|
|
|
|
; CHECK: _test00
|
|
|
|
define <4 x float> @test00(<4 x float> %a, <4 x float> %b) nounwind uwtable ssp {
|
|
|
|
entry:
|
2011-11-05 07:46:11 +08:00
|
|
|
; CHECK-NOT: vzeroupper
|
2011-08-23 09:14:17 +08:00
|
|
|
%add.i = fadd <4 x float> %a, %b
|
2011-11-05 07:46:11 +08:00
|
|
|
%call3 = call <4 x float> @do_sse(<4 x float> %add.i) nounwind
|
|
|
|
; CHECK: ret
|
|
|
|
ret <4 x float> %call3
|
|
|
|
}
|
|
|
|
|
|
|
|
;; Check parameter 256-bit parameter passing
|
|
|
|
|
|
|
|
; CHECK: _test01
|
|
|
|
define <8 x float> @test01(<4 x float> %a, <4 x float> %b, <8 x float> %c) nounwind uwtable ssp {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load <4 x float>, <4 x float>* @x, align 16
|
2011-08-23 09:14:17 +08:00
|
|
|
; CHECK: vzeroupper
|
|
|
|
; CHECK-NEXT: callq _do_sse
|
2011-11-05 07:46:11 +08:00
|
|
|
%call = tail call <4 x float> @do_sse(<4 x float> %tmp) nounwind
|
|
|
|
store <4 x float> %call, <4 x float>* @x, align 16
|
2011-08-23 09:14:17 +08:00
|
|
|
; CHECK-NOT: vzeroupper
|
2011-11-05 07:46:11 +08:00
|
|
|
; CHECK: callq _do_sse
|
|
|
|
%call2 = tail call <4 x float> @do_sse(<4 x float> %call) nounwind
|
|
|
|
store <4 x float> %call2, <4 x float>* @x, align 16
|
|
|
|
; CHECK: ret
|
|
|
|
ret <8 x float> %c
|
|
|
|
}
|
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
;; Check that vzeroupper is emitted for tail calls.
|
|
|
|
|
|
|
|
; CHECK: _test02
|
|
|
|
define <4 x float> @test02(<8 x float> %a, <8 x float> %b) nounwind uwtable ssp {
|
|
|
|
entry:
|
|
|
|
%add.i = fadd <8 x float> %a, %b
|
|
|
|
%add.low = call <4 x float> @llvm.x86.avx.vextractf128.ps.256(<8 x float> %add.i, i8 0)
|
|
|
|
; CHECK: vzeroupper
|
|
|
|
; CHECK: jmp _do_sse
|
|
|
|
%call3 = tail call <4 x float> @do_sse(<4 x float> %add.low) nounwind
|
|
|
|
ret <4 x float> %call3
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:46:11 +08:00
|
|
|
;; Test the pass convergence and also that vzeroupper is only issued when necessary,
|
|
|
|
;; for this function it should be only once
|
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
; CHECK: _test03
|
|
|
|
define <4 x float> @test03(<4 x float> %a, <4 x float> %b) nounwind uwtable ssp {
|
2011-11-05 07:46:11 +08:00
|
|
|
entry:
|
|
|
|
%add.i = fadd <4 x float> %a, %b
|
2014-03-17 09:22:54 +08:00
|
|
|
br label %while.cond
|
2011-11-05 07:46:11 +08:00
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
while.cond:
|
|
|
|
%call = tail call i32 @foo()
|
|
|
|
%tobool = icmp eq i32 %call, 0
|
|
|
|
br i1 %tobool, label %for.body, label %while.cond
|
|
|
|
|
|
|
|
for.body:
|
2011-11-05 07:46:11 +08:00
|
|
|
; CHECK: LBB
|
|
|
|
; CHECK-NOT: vzeroupper
|
2014-03-17 09:22:54 +08:00
|
|
|
%i.018 = phi i32 [ 0, %while.cond ], [ %1, %for.body ]
|
|
|
|
%c.017 = phi <4 x float> [ %add.i, %while.cond ], [ %call14, %for.body ]
|
2011-11-05 07:46:11 +08:00
|
|
|
; CHECK: callq _do_sse
|
|
|
|
%call5 = tail call <4 x float> @do_sse(<4 x float> %c.017) nounwind
|
|
|
|
; CHECK-NEXT: callq _do_sse
|
|
|
|
%call7 = tail call <4 x float> @do_sse(<4 x float> %call5) nounwind
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp11 = load <8 x float>, <8 x float>* @g, align 32
|
2011-11-05 07:46:11 +08:00
|
|
|
%0 = tail call <4 x float> @llvm.x86.avx.vextractf128.ps.256(<8 x float> %tmp11, i8 1) nounwind
|
2011-08-23 09:14:17 +08:00
|
|
|
; CHECK: vzeroupper
|
2011-11-05 07:46:11 +08:00
|
|
|
; CHECK-NEXT: callq _do_sse
|
|
|
|
%call14 = tail call <4 x float> @do_sse(<4 x float> %0) nounwind
|
|
|
|
%1 = add nsw i32 %i.018, 1
|
|
|
|
%exitcond = icmp eq i32 %1, 4
|
|
|
|
br i1 %exitcond, label %for.end, label %for.body
|
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
for.end:
|
2011-11-05 07:46:11 +08:00
|
|
|
ret <4 x float> %call14
|
2011-08-23 09:14:17 +08:00
|
|
|
}
|
|
|
|
|
2011-11-05 07:46:11 +08:00
|
|
|
;; Check that we also perform vzeroupper when we return from a function.
|
|
|
|
|
2014-03-17 09:22:54 +08:00
|
|
|
; CHECK: _test04
|
|
|
|
define <4 x float> @test04(<4 x float> %a, <4 x float> %b) nounwind uwtable ssp {
|
2011-11-05 07:46:11 +08:00
|
|
|
entry:
|
|
|
|
%shuf = shufflevector <4 x float> %a, <4 x float> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
|
|
|
|
; CHECK-NOT: vzeroupper
|
|
|
|
; CHECK: call
|
|
|
|
%call = call <8 x float> @do_avx(<8 x float> %shuf) nounwind
|
|
|
|
%shuf2 = shufflevector <8 x float> %call, <8 x float> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
|
|
|
|
; CHECK: vzeroupper
|
|
|
|
; CHECK: ret
|
|
|
|
ret <4 x float> %shuf2
|
|
|
|
}
|