2015-02-09 03:50:55 +08:00
|
|
|
; RUN: llc < %s -march=x86-64 -mattr=sse2 | FileCheck %s
|
2011-05-11 16:12:09 +08:00
|
|
|
|
|
|
|
; Splat patterns below
|
|
|
|
|
|
|
|
|
|
|
|
define <4 x i32> @shl4(<4 x i32> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shl4
|
2013-06-25 10:48:58 +08:00
|
|
|
; CHECK: pslld
|
2013-10-16 07:33:07 +08:00
|
|
|
; CHECK: padd
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = shl <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
|
|
|
|
%C = shl <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
|
|
|
|
%K = xor <4 x i32> %B, %C
|
|
|
|
ret <4 x i32> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @shr4(<4 x i32> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shr4
|
|
|
|
; CHECK: psrld
|
|
|
|
; CHECK-NEXT: psrld
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = lshr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
|
|
|
|
%C = lshr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
|
|
|
|
%K = xor <4 x i32> %B, %C
|
|
|
|
ret <4 x i32> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @sra4(<4 x i32> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: sra4
|
|
|
|
; CHECK: psrad
|
|
|
|
; CHECK-NEXT: psrad
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = ashr <4 x i32> %A, < i32 2, i32 2, i32 2, i32 2>
|
|
|
|
%C = ashr <4 x i32> %A, < i32 1, i32 1, i32 1, i32 1>
|
|
|
|
%K = xor <4 x i32> %B, %C
|
|
|
|
ret <4 x i32> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @shl2(<2 x i64> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shl2
|
|
|
|
; CHECK: psllq
|
|
|
|
; CHECK-NEXT: psllq
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = shl <2 x i64> %A, < i64 2, i64 2>
|
|
|
|
%C = shl <2 x i64> %A, < i64 9, i64 9>
|
|
|
|
%K = xor <2 x i64> %B, %C
|
|
|
|
ret <2 x i64> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i64> @shr2(<2 x i64> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shr2
|
|
|
|
; CHECK: psrlq
|
|
|
|
; CHECK-NEXT: psrlq
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = lshr <2 x i64> %A, < i64 8, i64 8>
|
|
|
|
%C = lshr <2 x i64> %A, < i64 1, i64 1>
|
|
|
|
%K = xor <2 x i64> %B, %C
|
|
|
|
ret <2 x i64> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define <8 x i16> @shl8(<8 x i16> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shl8
|
2013-06-25 10:48:58 +08:00
|
|
|
; CHECK: psllw
|
2013-10-16 07:33:07 +08:00
|
|
|
; CHECK: padd
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = shl <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
|
|
|
|
%C = shl <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
|
|
|
|
%K = xor <8 x i16> %B, %C
|
|
|
|
ret <8 x i16> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @shr8(<8 x i16> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shr8
|
|
|
|
; CHECK: psrlw
|
|
|
|
; CHECK-NEXT: psrlw
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = lshr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
|
|
|
|
%C = lshr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
|
|
|
|
%K = xor <8 x i16> %B, %C
|
|
|
|
ret <8 x i16> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @sra8(<8 x i16> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: sra8
|
|
|
|
; CHECK: psraw
|
|
|
|
; CHECK-NEXT: psraw
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = ashr <8 x i16> %A, < i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>
|
|
|
|
%C = ashr <8 x i16> %A, < i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
|
|
|
|
%K = xor <8 x i16> %B, %C
|
|
|
|
ret <8 x i16> %K
|
|
|
|
}
|
|
|
|
|
2013-12-05 13:44:44 +08:00
|
|
|
; non-splat test
|
2011-05-11 16:12:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
define <8 x i16> @sll8_nosplat(<8 x i16> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: sll8_nosplat
|
|
|
|
; CHECK-NOT: psll
|
|
|
|
; CHECK-NOT: psll
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = shl <8 x i16> %A, < i16 1, i16 2, i16 3, i16 6, i16 2, i16 2, i16 2, i16 2>
|
|
|
|
%C = shl <8 x i16> %A, < i16 9, i16 7, i16 5, i16 1, i16 4, i16 1, i16 1, i16 1>
|
|
|
|
%K = xor <8 x i16> %B, %C
|
|
|
|
ret <8 x i16> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define <2 x i64> @shr2_nosplat(<2 x i64> %A) nounwind {
|
|
|
|
entry:
|
2015-03-19 06:18:51 +08:00
|
|
|
; CHECK-LABEL: shr2_nosplat
|
|
|
|
; CHECK: movdqa %xmm1, %xmm2
|
|
|
|
; CHECK-NEXT: psrlq $8, %xmm2
|
|
|
|
; CHECK-NEXT: movdqa %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: psrlq $1, %xmm0
|
|
|
|
; CHECK-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
|
|
|
|
; CHECK-NEXT: movsd {{.*#+}} xmm0 = xmm2[0],xmm0[1]
|
|
|
|
; CHECK-NEXT: xorpd %xmm1, %xmm0
|
|
|
|
; CHECK-NEXT: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = lshr <2 x i64> %A, < i64 8, i64 1>
|
|
|
|
%C = lshr <2 x i64> %A, < i64 1, i64 0>
|
|
|
|
%K = xor <2 x i64> %B, %C
|
|
|
|
ret <2 x i64> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; Other shifts
|
|
|
|
|
|
|
|
define <2 x i32> @shl2_other(<2 x i32> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shl2_other
|
2011-10-17 04:31:33 +08:00
|
|
|
; CHECK: psllq
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = shl <2 x i32> %A, < i32 2, i32 2>
|
|
|
|
%C = shl <2 x i32> %A, < i32 9, i32 9>
|
|
|
|
%K = xor <2 x i32> %B, %C
|
|
|
|
ret <2 x i32> %K
|
|
|
|
}
|
|
|
|
|
|
|
|
define <2 x i32> @shr2_other(<2 x i32> %A) nounwind {
|
|
|
|
entry:
|
|
|
|
; CHECK: shr2_other
|
2011-10-17 04:31:33 +08:00
|
|
|
; CHECK: psrlq
|
2011-10-30 21:24:22 +08:00
|
|
|
; CHECK: ret
|
2011-05-11 16:12:09 +08:00
|
|
|
%B = lshr <2 x i32> %A, < i32 8, i32 8>
|
|
|
|
%C = lshr <2 x i32> %A, < i32 1, i32 1>
|
|
|
|
%K = xor <2 x i32> %B, %C
|
|
|
|
ret <2 x i32> %K
|
|
|
|
}
|
2011-10-31 01:31:21 +08:00
|
|
|
|
|
|
|
define <16 x i8> @shl9(<16 x i8> %A) nounwind {
|
|
|
|
%B = shl <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
|
|
|
|
ret <16 x i8> %B
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: shl9:
|
2011-10-31 01:31:21 +08:00
|
|
|
; CHECK: psllw $3
|
|
|
|
; CHECK: pand
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define <16 x i8> @shr9(<16 x i8> %A) nounwind {
|
|
|
|
%B = lshr <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
|
|
|
|
ret <16 x i8> %B
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: shr9:
|
2011-10-31 01:31:21 +08:00
|
|
|
; CHECK: psrlw $3
|
|
|
|
; CHECK: pand
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
2011-11-02 05:18:39 +08:00
|
|
|
|
|
|
|
define <16 x i8> @sra_v16i8_7(<16 x i8> %A) nounwind {
|
|
|
|
%B = ashr <16 x i8> %A, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
|
|
|
|
ret <16 x i8> %B
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: sra_v16i8_7:
|
2011-11-02 05:18:39 +08:00
|
|
|
; CHECK: pxor
|
|
|
|
; CHECK: pcmpgtb
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define <16 x i8> @sra_v16i8(<16 x i8> %A) nounwind {
|
|
|
|
%B = ashr <16 x i8> %A, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
|
|
|
|
ret <16 x i8> %B
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: sra_v16i8:
|
2011-11-02 05:18:39 +08:00
|
|
|
; CHECK: psrlw $3
|
|
|
|
; CHECK: pand
|
|
|
|
; CHECK: pxor
|
|
|
|
; CHECK: psubb
|
|
|
|
; CHECK: ret
|
|
|
|
}
|