2013-04-26 17:19:19 +08:00
|
|
|
; RUN: llc < %s -march=x86-64 -mcpu=x86-64 | FileCheck %s -check-prefix=SSE2
|
2013-04-26 20:05:21 +08:00
|
|
|
; RUN: llc < %s -march=x86-64 -mcpu=corei7 | FileCheck %s -check-prefix=SSSE3
|
|
|
|
; RUN: llc < %s -march=x86-64 -mcpu=core-avx2 | FileCheck %s -check-prefix=AVX2
|
2013-04-26 17:19:19 +08:00
|
|
|
|
|
|
|
define <4 x i32> @test1(<4 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSE2-LABEL: test1:
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2: movdqa
|
2013-04-27 05:04:21 +08:00
|
|
|
; SSE2: psrad $31
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2-NEXT: padd
|
|
|
|
; SSE2-NEXT: pxor
|
|
|
|
; SSE2-NEXT: ret
|
2013-04-26 20:05:21 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test1:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test1:
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2: vpabsd
|
|
|
|
; AVX2-NEXT: ret
|
2013-04-26 17:19:19 +08:00
|
|
|
%tmp1neg = sub <4 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sgt <4 x i32> %a, <i32 -1, i32 -1, i32 -1, i32 -1>
|
|
|
|
%abs = select <4 x i1> %b, <4 x i32> %a, <4 x i32> %tmp1neg
|
|
|
|
ret <4 x i32> %abs
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @test2(<4 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSE2-LABEL: test2:
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2: movdqa
|
2013-04-27 05:04:21 +08:00
|
|
|
; SSE2: psrad $31
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2-NEXT: padd
|
|
|
|
; SSE2-NEXT: pxor
|
|
|
|
; SSE2-NEXT: ret
|
2013-04-26 20:05:21 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test2:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test2:
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2: vpabsd
|
|
|
|
; AVX2-NEXT: ret
|
2013-04-26 17:19:19 +08:00
|
|
|
%tmp1neg = sub <4 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sge <4 x i32> %a, zeroinitializer
|
|
|
|
%abs = select <4 x i1> %b, <4 x i32> %a, <4 x i32> %tmp1neg
|
|
|
|
ret <4 x i32> %abs
|
|
|
|
}
|
|
|
|
|
2013-04-26 20:05:21 +08:00
|
|
|
define <8 x i16> @test3(<8 x i16> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSE2-LABEL: test3:
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2: movdqa
|
2013-04-27 05:04:21 +08:00
|
|
|
; SSE2: psraw $15
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2-NEXT: padd
|
|
|
|
; SSE2-NEXT: pxor
|
|
|
|
; SSE2-NEXT: ret
|
2013-04-26 20:05:21 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test3:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsw
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test3:
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2: vpabsw
|
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <8 x i16> zeroinitializer, %a
|
|
|
|
%b = icmp sgt <8 x i16> %a, zeroinitializer
|
|
|
|
%abs = select <8 x i1> %b, <8 x i16> %a, <8 x i16> %tmp1neg
|
|
|
|
ret <8 x i16> %abs
|
2013-04-26 17:19:19 +08:00
|
|
|
}
|
|
|
|
|
2013-04-26 20:05:21 +08:00
|
|
|
define <16 x i8> @test4(<16 x i8> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSE2-LABEL: test4:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSE2: pxor
|
2013-04-27 05:04:21 +08:00
|
|
|
; SSE2: pcmpgtb
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2-NEXT: padd
|
|
|
|
; SSE2-NEXT: pxor
|
|
|
|
; SSE2-NEXT: ret
|
2013-04-26 20:05:21 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test4:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsb
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test4:
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2: vpabsb
|
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <16 x i8> zeroinitializer, %a
|
|
|
|
%b = icmp slt <16 x i8> %a, zeroinitializer
|
|
|
|
%abs = select <16 x i1> %b, <16 x i8> %tmp1neg, <16 x i8> %a
|
|
|
|
ret <16 x i8> %abs
|
2013-04-26 17:19:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x i32> @test5(<4 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSE2-LABEL: test5:
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2: movdqa
|
2013-04-27 05:04:21 +08:00
|
|
|
; SSE2: psrad $31
|
2013-04-26 17:19:19 +08:00
|
|
|
; SSE2-NEXT: padd
|
|
|
|
; SSE2-NEXT: pxor
|
|
|
|
; SSE2-NEXT: ret
|
2013-04-26 20:05:21 +08:00
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test5:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test5:
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2: vpabsd
|
|
|
|
; AVX2-NEXT: ret
|
2013-04-26 17:19:19 +08:00
|
|
|
%tmp1neg = sub <4 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sle <4 x i32> %a, zeroinitializer
|
|
|
|
%abs = select <4 x i1> %b, <4 x i32> %tmp1neg, <4 x i32> %a
|
|
|
|
ret <4 x i32> %abs
|
|
|
|
}
|
2013-04-26 20:05:21 +08:00
|
|
|
|
|
|
|
define <8 x i32> @test6(<8 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test6:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test6:
|
2013-04-27 05:04:21 +08:00
|
|
|
; AVX2: vpabsd {{.*}}%ymm
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <8 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sgt <8 x i32> %a, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
|
|
|
|
%abs = select <8 x i1> %b, <8 x i32> %a, <8 x i32> %tmp1neg
|
|
|
|
ret <8 x i32> %abs
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i32> @test7(<8 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test7:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test7:
|
2013-04-27 05:04:21 +08:00
|
|
|
; AVX2: vpabsd {{.*}}%ymm
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <8 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sge <8 x i32> %a, zeroinitializer
|
|
|
|
%abs = select <8 x i1> %b, <8 x i32> %a, <8 x i32> %tmp1neg
|
|
|
|
ret <8 x i32> %abs
|
|
|
|
}
|
|
|
|
|
|
|
|
define <16 x i16> @test8(<16 x i16> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test8:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsw
|
|
|
|
; SSSE3: pabsw
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test8:
|
2013-04-27 05:04:21 +08:00
|
|
|
; AVX2: vpabsw {{.*}}%ymm
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <16 x i16> zeroinitializer, %a
|
|
|
|
%b = icmp sgt <16 x i16> %a, zeroinitializer
|
|
|
|
%abs = select <16 x i1> %b, <16 x i16> %a, <16 x i16> %tmp1neg
|
|
|
|
ret <16 x i16> %abs
|
|
|
|
}
|
|
|
|
|
|
|
|
define <32 x i8> @test9(<32 x i8> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test9:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsb
|
|
|
|
; SSSE3: pabsb
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test9:
|
2013-04-27 05:04:21 +08:00
|
|
|
; AVX2: vpabsb {{.*}}%ymm
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <32 x i8> zeroinitializer, %a
|
|
|
|
%b = icmp slt <32 x i8> %a, zeroinitializer
|
|
|
|
%abs = select <32 x i1> %b, <32 x i8> %tmp1neg, <32 x i8> %a
|
|
|
|
ret <32 x i8> %abs
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i32> @test10(<8 x i32> %a) nounwind {
|
2013-07-14 04:38:47 +08:00
|
|
|
; SSSE3-LABEL: test10:
|
2013-04-26 20:05:21 +08:00
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3: pabsd
|
|
|
|
; SSSE3-NEXT: ret
|
|
|
|
|
2013-07-14 04:38:47 +08:00
|
|
|
; AVX2-LABEL: test10:
|
2013-04-27 05:04:21 +08:00
|
|
|
; AVX2: vpabsd {{.*}}%ymm
|
2013-04-26 20:05:21 +08:00
|
|
|
; AVX2-NEXT: ret
|
|
|
|
%tmp1neg = sub <8 x i32> zeroinitializer, %a
|
|
|
|
%b = icmp sle <8 x i32> %a, zeroinitializer
|
|
|
|
%abs = select <8 x i1> %b, <8 x i32> %tmp1neg, <8 x i32> %a
|
|
|
|
ret <8 x i32> %abs
|
|
|
|
}
|