2011-07-25 23:05:25 +00:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -mattr=+avx | FileCheck %s
|
2010-08-12 02:06:36 +00:00
|
|
|
|
|
|
|
@x = common global <8 x float> zeroinitializer, align 32
|
|
|
|
@y = common global <4 x double> zeroinitializer, align 32
|
2011-08-09 03:04:23 +00:00
|
|
|
@z = common global <4 x float> zeroinitializer, align 16
|
2010-08-12 02:06:36 +00:00
|
|
|
|
2011-08-09 03:04:23 +00:00
|
|
|
define void @zero128() nounwind ssp {
|
|
|
|
entry:
|
2011-11-07 19:15:58 +00:00
|
|
|
; CHECK: vxorps
|
2011-08-09 03:04:23 +00:00
|
|
|
; CHECK: vmovaps
|
|
|
|
store <4 x float> zeroinitializer, <4 x float>* @z, align 16
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @zero256() nounwind ssp {
|
2010-08-12 02:06:36 +00:00
|
|
|
entry:
|
|
|
|
; CHECK: vxorps
|
|
|
|
; CHECK: vmovaps
|
|
|
|
; CHECK: vmovaps
|
|
|
|
store <8 x float> zeroinitializer, <8 x float>* @x, align 32
|
|
|
|
store <4 x double> zeroinitializer, <4 x double>* @y, align 32
|
|
|
|
ret void
|
|
|
|
}
|
2011-07-25 23:05:32 +00:00
|
|
|
|
|
|
|
; CHECK: vpcmpeqd
|
|
|
|
; CHECK: vinsertf128 $1
|
|
|
|
define void @ones([0 x float]* nocapture %RET, [0 x float]* nocapture %aFOO) nounwind {
|
|
|
|
allocas:
|
|
|
|
%ptr2vec615 = bitcast [0 x float]* %RET to <8 x float>*
|
|
|
|
store <8 x float> <float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float
|
|
|
|
0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float
|
|
|
|
0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000>, <8 x
|
|
|
|
float>* %ptr2vec615, align 32
|
|
|
|
ret void
|
|
|
|
}
|
2011-08-01 19:51:53 +00:00
|
|
|
|
|
|
|
; CHECK: vpcmpeqd
|
|
|
|
; CHECK: vinsertf128 $1
|
|
|
|
define void @ones2([0 x i32]* nocapture %RET, [0 x i32]* nocapture %aFOO) nounwind {
|
|
|
|
allocas:
|
|
|
|
%ptr2vec615 = bitcast [0 x i32]* %RET to <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>* %ptr2vec615, align 32
|
|
|
|
ret void
|
|
|
|
}
|
2011-08-11 18:59:13 +00:00
|
|
|
|
|
|
|
;;; Just make sure this doesn't crash
|
|
|
|
; CHECK: _ISelCrash
|
|
|
|
define <4 x i64> @ISelCrash(<4 x i64> %a) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%shuffle = shufflevector <4 x i64> %a, <4 x i64> undef, <4 x i32> <i32 2, i32 3, i32 4, i32 4>
|
|
|
|
ret <4 x i64> %shuffle
|
|
|
|
}
|
Instead of always leaving the work to the generic legalizer when
there is no support for native 256-bit shuffles, be more smart in some
cases, for example, when you can extract specific 128-bit parts and use
regular 128-bit shuffles for them. Example:
For this shuffle:
shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32>
<i32 1, i32 0, i32 7, i32 6>
This was expanded to:
vextractf128 $1, %ymm1, %xmm2
vpextrq $0, %xmm2, %rax
vmovd %rax, %xmm1
vpextrq $1, %xmm2, %rax
vmovd %rax, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1
vpextrq $0, %xmm0, %rax
vmovd %rax, %xmm2
vpextrq $1, %xmm0, %rax
vmovd %rax, %xmm0
vpunpcklqdq %xmm2, %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
Now we get:
vshufpd $1, %xmm0, %xmm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vshufpd $1, %xmm1, %xmm1, %xmm1
vinsertf128 $1, %xmm1, %ymm0, %ymm0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 18:21:54 +00:00
|
|
|
|
|
|
|
;;;
|
|
|
|
;;; Check that some 256-bit vectors are xformed into 128 ops
|
|
|
|
; CHECK: _A
|
|
|
|
; CHECK: vshufpd $1
|
|
|
|
; CHECK-NEXT: vextractf128 $1
|
|
|
|
; CHECK-NEXT: vshufpd $1
|
|
|
|
; CHECK-NEXT: vinsertf128 $1
|
|
|
|
define <4 x i64> @A(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 0, i32 7, i32 6>
|
|
|
|
ret <4 x i64> %shuffle
|
|
|
|
}
|
|
|
|
|
2011-08-25 02:58:26 +00:00
|
|
|
; CHECK: _B
|
|
|
|
; CHECK: vshufpd $1, %ymm
|
Instead of always leaving the work to the generic legalizer when
there is no support for native 256-bit shuffles, be more smart in some
cases, for example, when you can extract specific 128-bit parts and use
regular 128-bit shuffles for them. Example:
For this shuffle:
shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32>
<i32 1, i32 0, i32 7, i32 6>
This was expanded to:
vextractf128 $1, %ymm1, %xmm2
vpextrq $0, %xmm2, %rax
vmovd %rax, %xmm1
vpextrq $1, %xmm2, %rax
vmovd %rax, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1
vpextrq $0, %xmm0, %rax
vmovd %rax, %xmm2
vpextrq $1, %xmm0, %rax
vmovd %rax, %xmm0
vpunpcklqdq %xmm2, %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
Now we get:
vshufpd $1, %xmm0, %xmm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vshufpd $1, %xmm1, %xmm1, %xmm1
vinsertf128 $1, %xmm1, %ymm0, %ymm0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 18:21:54 +00:00
|
|
|
define <4 x i64> @B(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 undef, i32 undef, i32 6>
|
|
|
|
ret <4 x i64> %shuffle
|
|
|
|
}
|
|
|
|
|
[x86] Teach the target shuffle mask extraction to recognize unary forms
of normally binary shuffle instructions like PUNPCKL and MOVLHPS.
This detects cases where a single register is used for both operands
making the shuffle behave in a unary way. We detect this and adjust the
mask to use the unary form which allows the existing DAG combine for
shuffle instructions to actually work at all.
As a consequence, this uncovered a number of obvious bugs in the
existing DAG combine which are fixed. It also now canonicalizes several
shuffles even with the existing lowering. These typically are trying to
match the shuffle to the domain of the input where before we only really
modeled them with the floating point variants. All of the cases which
change to an integer shuffle here have something in the integer domain, so
there are no more or fewer domain crosses here AFAICT. Technically, it
might be better to go from a GPR directly to the floating point domain,
but detecting floating point *outputs* despite integer inputs is a lot
more code and seems unlikely to be worthwhile in practice. If folks are
seeing domain-crossing regressions here though, let me know and I can
hack something up to fix it.
Also as a consequence, a bunch of missed opportunities to form pshufb
now can be formed. Notably, splats of i8s now form pshufb.
Interestingly, this improves the existing splat lowering too. We go from
3 instructions to 1. Yes, we may tie up a register, but it seems very
likely to be worth it, especially if splatting the 0th byte (the
common case) as then we can use a zeroed register as the mask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-02 10:27:38 +00:00
|
|
|
; CHECK: vpunpcklqdq
|
Instead of always leaving the work to the generic legalizer when
there is no support for native 256-bit shuffles, be more smart in some
cases, for example, when you can extract specific 128-bit parts and use
regular 128-bit shuffles for them. Example:
For this shuffle:
shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32>
<i32 1, i32 0, i32 7, i32 6>
This was expanded to:
vextractf128 $1, %ymm1, %xmm2
vpextrq $0, %xmm2, %rax
vmovd %rax, %xmm1
vpextrq $1, %xmm2, %rax
vmovd %rax, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1
vpextrq $0, %xmm0, %rax
vmovd %rax, %xmm2
vpextrq $1, %xmm0, %rax
vmovd %rax, %xmm0
vpunpcklqdq %xmm2, %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
Now we get:
vshufpd $1, %xmm0, %xmm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vshufpd $1, %xmm1, %xmm1, %xmm1
vinsertf128 $1, %xmm1, %ymm0, %ymm0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 18:21:54 +00:00
|
|
|
; CHECK-NEXT: vextractf128 $1
|
[x86] Teach the target shuffle mask extraction to recognize unary forms
of normally binary shuffle instructions like PUNPCKL and MOVLHPS.
This detects cases where a single register is used for both operands
making the shuffle behave in a unary way. We detect this and adjust the
mask to use the unary form which allows the existing DAG combine for
shuffle instructions to actually work at all.
As a consequence, this uncovered a number of obvious bugs in the
existing DAG combine which are fixed. It also now canonicalizes several
shuffles even with the existing lowering. These typically are trying to
match the shuffle to the domain of the input where before we only really
modeled them with the floating point variants. All of the cases which
change to an integer shuffle here have something in the integer domain, so
there are no more or fewer domain crosses here AFAICT. Technically, it
might be better to go from a GPR directly to the floating point domain,
but detecting floating point *outputs* despite integer inputs is a lot
more code and seems unlikely to be worthwhile in practice. If folks are
seeing domain-crossing regressions here though, let me know and I can
hack something up to fix it.
Also as a consequence, a bunch of missed opportunities to form pshufb
now can be formed. Notably, splats of i8s now form pshufb.
Interestingly, this improves the existing splat lowering too. We go from
3 instructions to 1. Yes, we may tie up a register, but it seems very
likely to be worth it, especially if splatting the 0th byte (the
common case) as then we can use a zeroed register as the mask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-02 10:27:38 +00:00
|
|
|
; CHECK-NEXT: vpunpcklqdq
|
Instead of always leaving the work to the generic legalizer when
there is no support for native 256-bit shuffles, be more smart in some
cases, for example, when you can extract specific 128-bit parts and use
regular 128-bit shuffles for them. Example:
For this shuffle:
shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32>
<i32 1, i32 0, i32 7, i32 6>
This was expanded to:
vextractf128 $1, %ymm1, %xmm2
vpextrq $0, %xmm2, %rax
vmovd %rax, %xmm1
vpextrq $1, %xmm2, %rax
vmovd %rax, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1
vpextrq $0, %xmm0, %rax
vmovd %rax, %xmm2
vpextrq $1, %xmm0, %rax
vmovd %rax, %xmm0
vpunpcklqdq %xmm2, %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
Now we get:
vshufpd $1, %xmm0, %xmm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vshufpd $1, %xmm1, %xmm1, %xmm1
vinsertf128 $1, %xmm1, %ymm0, %ymm0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 18:21:54 +00:00
|
|
|
; CHECK-NEXT: vinsertf128 $1
|
|
|
|
define <4 x i64> @C(<4 x i64> %a, <4 x i64> %b) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%shuffle = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 undef, i32 0, i32 undef, i32 6>
|
|
|
|
ret <4 x i64> %shuffle
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: vpshufd $-96
|
2014-07-27 01:15:58 +00:00
|
|
|
; CHECK: vpunpckhdq
|
Instead of always leaving the work to the generic legalizer when
there is no support for native 256-bit shuffles, be more smart in some
cases, for example, when you can extract specific 128-bit parts and use
regular 128-bit shuffles for them. Example:
For this shuffle:
shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32>
<i32 1, i32 0, i32 7, i32 6>
This was expanded to:
vextractf128 $1, %ymm1, %xmm2
vpextrq $0, %xmm2, %rax
vmovd %rax, %xmm1
vpextrq $1, %xmm2, %rax
vmovd %rax, %xmm2
vpunpcklqdq %xmm1, %xmm2, %xmm1
vpextrq $0, %xmm0, %rax
vmovd %rax, %xmm2
vpextrq $1, %xmm0, %rax
vmovd %rax, %xmm0
vpunpcklqdq %xmm2, %xmm0, %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
ret
Now we get:
vshufpd $1, %xmm0, %xmm0, %xmm0
vextractf128 $1, %ymm1, %xmm1
vshufpd $1, %xmm1, %xmm1, %xmm1
vinsertf128 $1, %xmm1, %ymm0, %ymm0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 18:21:54 +00:00
|
|
|
; CHECK: vinsertf128 $1
|
|
|
|
define <8 x i32> @D(<8 x i32> %a, <8 x i32> %b) nounwind uwtable readnone ssp {
|
|
|
|
entry:
|
|
|
|
%shuffle = shufflevector <8 x i32> %a, <8 x i32> %b, <8 x i32> <i32 0, i32 0, i32 2, i32 2, i32 10, i32 10, i32 11, i32 11>
|
|
|
|
ret <8 x i32> %shuffle
|
|
|
|
}
|
|
|
|
|
2011-09-12 22:59:23 +00:00
|
|
|
;;; Don't crash on movd
|
|
|
|
; CHECK: _VMOVZQI2PQI
|
|
|
|
; CHECK: vmovd (%
|
|
|
|
define <8 x i32> @VMOVZQI2PQI([0 x float]* nocapture %aFOO) nounwind {
|
|
|
|
allocas:
|
|
|
|
%ptrcast.i33.i = bitcast [0 x float]* %aFOO to i32*
|
|
|
|
%val.i34.i = load i32* %ptrcast.i33.i, align 4
|
|
|
|
%ptroffset.i22.i992 = getelementptr [0 x float]* %aFOO, i64 0, i64 1
|
|
|
|
%ptrcast.i23.i = bitcast float* %ptroffset.i22.i992 to i32*
|
|
|
|
%val.i24.i = load i32* %ptrcast.i23.i, align 4
|
|
|
|
%updatedret.i30.i = insertelement <8 x i32> undef, i32 %val.i34.i, i32 1
|
|
|
|
ret <8 x i32> %updatedret.i30.i
|
|
|
|
}
|
|
|
|
|
2011-12-15 01:02:25 +00:00
|
|
|
;;;; Don't crash on fneg
|
|
|
|
; rdar://10566486
|
|
|
|
; CHECK: fneg
|
|
|
|
; CHECK: vxorps
|
2012-09-09 22:58:45 +00:00
|
|
|
define <16 x float> @fneg(<16 x float> %a) nounwind {
|
|
|
|
%1 = fsub <16 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %a
|
2011-12-15 01:02:25 +00:00
|
|
|
ret <16 x float> %1
|
|
|
|
}
|
2011-12-15 21:34:44 +00:00
|
|
|
|
|
|
|
;;; Don't crash on build vector
|
|
|
|
; CHECK: @build_vec_16x16
|
|
|
|
; CHECK: vmovd
|
|
|
|
define <16 x i16> @build_vec_16x16(i16 %a) nounwind readonly {
|
|
|
|
%res = insertelement <16 x i16> <i16 undef, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>, i16 %a, i32 0
|
|
|
|
ret <16 x i16> %res
|
|
|
|
}
|
2013-05-01 13:00:16 +00:00
|
|
|
|
2013-10-08 05:53:50 +00:00
|
|
|
;;; Check that VMOVPQIto64rr generates the assembly string "vmovq". Previously
|
2013-05-01 13:00:16 +00:00
|
|
|
;;; an incorrect mnemonic of "movd" was printed for this instruction.
|
|
|
|
; CHECK: VMOVPQIto64rr
|
2013-10-08 05:53:50 +00:00
|
|
|
; CHECK: vmovq
|
2013-05-01 13:00:16 +00:00
|
|
|
define i64 @VMOVPQIto64rr(<2 x i64> %a) {
|
|
|
|
entry:
|
|
|
|
%vecext.i = extractelement <2 x i64> %a, i32 0
|
|
|
|
ret i64 %vecext.i
|
|
|
|
}
|