2019-01-14 05:21:46 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE2
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefixes=CHECK,SSE,SSE41
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE42
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX,AVX1
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX,AVX2
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s --check-prefixes=CHECK,AVX,AVX512,AVX512F
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw | FileCheck %s --check-prefixes=CHECK,AVX,AVX512,AVX512BW
|
|
|
|
|
|
|
|
declare i32 @llvm.uadd.sat.i32 (i32, i32)
|
|
|
|
declare i64 @llvm.uadd.sat.i64 (i64, i64)
|
|
|
|
declare <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16>, <8 x i16>)
|
|
|
|
|
2019-01-14 21:47:07 +08:00
|
|
|
; fold (uadd_sat x, undef) -> -1
|
|
|
|
define i32 @combine_undef_i32(i32 %a0) {
|
|
|
|
; CHECK-LABEL: combine_undef_i32:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movl $-1, %eax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%res = call i32 @llvm.uadd.sat.i32(i32 %a0, i32 undef)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @combine_undef_v8i16(<8 x i16> %a0) {
|
|
|
|
; SSE-LABEL: combine_undef_v8i16:
|
|
|
|
; SSE: # %bb.0:
|
2019-01-14 22:16:24 +08:00
|
|
|
; SSE-NEXT: pcmpeqd %xmm0, %xmm0
|
2019-01-14 21:47:07 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: combine_undef_v8i16:
|
|
|
|
; AVX: # %bb.0:
|
2019-01-14 22:16:24 +08:00
|
|
|
; AVX-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
|
2019-01-14 21:47:07 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%res = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> undef, <8 x i16> %a0)
|
|
|
|
ret <8 x i16> %res
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:12:42 +08:00
|
|
|
; fold (uadd_sat c1, c2) -> c3
|
|
|
|
define i32 @combine_constfold_i32() {
|
|
|
|
; CHECK-LABEL: combine_constfold_i32:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movl $-1, %eax
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%res = call i32 @llvm.uadd.sat.i32(i32 4294967295, i32 100)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @combine_constfold_v8i16() {
|
|
|
|
; SSE-LABEL: combine_constfold_v8i16:
|
|
|
|
; SSE: # %bb.0:
|
2019-01-14 20:34:31 +08:00
|
|
|
; SSE-NEXT: movaps {{.*#+}} xmm0 = [1,65535,256,65535,65535,65535,2,65535]
|
2019-01-14 20:12:42 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: combine_constfold_v8i16:
|
|
|
|
; AVX: # %bb.0:
|
2019-01-14 20:34:31 +08:00
|
|
|
; AVX-NEXT: vmovaps {{.*#+}} xmm0 = [1,65535,256,65535,65535,65535,2,65535]
|
2019-01-14 20:12:42 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%res = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> <i16 0, i16 1, i16 255, i16 65535, i16 -1, i16 -255, i16 -65535, i16 1>, <8 x i16> <i16 1, i16 65535, i16 1, i16 65535, i16 1, i16 65535, i16 1, i16 65535>)
|
|
|
|
ret <8 x i16> %res
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:34:31 +08:00
|
|
|
define <8 x i16> @combine_constfold_undef_v8i16() {
|
|
|
|
; SSE-LABEL: combine_constfold_undef_v8i16:
|
|
|
|
; SSE: # %bb.0:
|
2019-01-14 22:16:24 +08:00
|
|
|
; SSE-NEXT: movaps {{.*#+}} xmm0 = [65535,65535,65535,65535,65535,65535,2,65535]
|
2019-01-14 20:34:31 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: combine_constfold_undef_v8i16:
|
|
|
|
; AVX: # %bb.0:
|
2019-01-14 22:16:24 +08:00
|
|
|
; AVX-NEXT: vmovaps {{.*#+}} xmm0 = [65535,65535,65535,65535,65535,65535,2,65535]
|
2019-01-14 20:34:31 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%res = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> <i16 undef, i16 1, i16 undef, i16 65535, i16 -1, i16 -255, i16 -65535, i16 1>, <8 x i16> <i16 1, i16 undef, i16 undef, i16 65535, i16 1, i16 65535, i16 1, i16 65535>)
|
|
|
|
ret <8 x i16> %res
|
|
|
|
}
|
|
|
|
|
2019-01-14 05:21:46 +08:00
|
|
|
; fold (uadd_sat c, x) -> (add_ssat x, c)
|
|
|
|
define i32 @combine_constant_i32(i32 %a0) {
|
|
|
|
; CHECK-LABEL: combine_constant_i32:
|
|
|
|
; CHECK: # %bb.0:
|
2019-02-03 15:25:06 +08:00
|
|
|
; CHECK-NEXT: incl %edi
|
2019-01-14 05:21:46 +08:00
|
|
|
; CHECK-NEXT: movl $-1, %eax
|
2019-02-03 15:25:06 +08:00
|
|
|
; CHECK-NEXT: cmovnel %edi, %eax
|
2019-01-14 05:21:46 +08:00
|
|
|
; CHECK-NEXT: retq
|
2019-01-14 20:12:42 +08:00
|
|
|
%1 = call i32 @llvm.uadd.sat.i32(i32 1, i32 %a0)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret i32 %1
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @combine_constant_v8i16(<8 x i16> %a0) {
|
|
|
|
; SSE-LABEL: combine_constant_v8i16:
|
|
|
|
; SSE: # %bb.0:
|
|
|
|
; SSE-NEXT: paddusw {{.*}}(%rip), %xmm0
|
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: combine_constant_v8i16:
|
|
|
|
; AVX: # %bb.0:
|
|
|
|
; AVX-NEXT: vpaddusw {{.*}}(%rip), %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: retq
|
2019-01-14 20:12:42 +08:00
|
|
|
%1 = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> %a0)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret <8 x i16> %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; fold (uadd_sat c, 0) -> x
|
|
|
|
define i32 @combine_zero_i32(i32 %a0) {
|
|
|
|
; CHECK-LABEL: combine_zero_i32:
|
|
|
|
; CHECK: # %bb.0:
|
2019-01-14 05:50:24 +08:00
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2019-01-14 05:21:46 +08:00
|
|
|
; CHECK-NEXT: retq
|
2019-01-14 20:12:42 +08:00
|
|
|
%1 = call i32 @llvm.uadd.sat.i32(i32 %a0, i32 0)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret i32 %1
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @combine_zero_v8i16(<8 x i16> %a0) {
|
2019-01-14 05:50:24 +08:00
|
|
|
; CHECK-LABEL: combine_zero_v8i16:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: retq
|
2019-01-14 20:12:42 +08:00
|
|
|
%1 = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> %a0, <8 x i16> zeroinitializer)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret <8 x i16> %1
|
|
|
|
}
|
|
|
|
|
|
|
|
; fold (uadd_sat x, y) -> (add x, y) iff no overflow
|
|
|
|
define i32 @combine_no_overflow_i32(i32 %a0, i32 %a1) {
|
|
|
|
; CHECK-LABEL: combine_no_overflow_i32:
|
|
|
|
; CHECK: # %bb.0:
|
2019-01-14 06:08:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
|
2019-01-14 05:21:46 +08:00
|
|
|
; CHECK-NEXT: shrl $16, %edi
|
|
|
|
; CHECK-NEXT: shrl $16, %esi
|
2019-01-14 06:08:26 +08:00
|
|
|
; CHECK-NEXT: leal (%rsi,%rdi), %eax
|
2019-01-14 05:21:46 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%1 = lshr i32 %a0, 16
|
|
|
|
%2 = lshr i32 %a1, 16
|
2019-01-14 20:12:42 +08:00
|
|
|
%3 = call i32 @llvm.uadd.sat.i32(i32 %1, i32 %2)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret i32 %3
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i16> @combine_no_overflow_v8i16(<8 x i16> %a0, <8 x i16> %a1) {
|
|
|
|
; SSE-LABEL: combine_no_overflow_v8i16:
|
|
|
|
; SSE: # %bb.0:
|
|
|
|
; SSE-NEXT: psrlw $10, %xmm0
|
|
|
|
; SSE-NEXT: psrlw $10, %xmm1
|
2019-01-14 06:08:26 +08:00
|
|
|
; SSE-NEXT: paddw %xmm1, %xmm0
|
2019-01-14 05:21:46 +08:00
|
|
|
; SSE-NEXT: retq
|
|
|
|
;
|
|
|
|
; AVX-LABEL: combine_no_overflow_v8i16:
|
|
|
|
; AVX: # %bb.0:
|
|
|
|
; AVX-NEXT: vpsrlw $10, %xmm0, %xmm0
|
|
|
|
; AVX-NEXT: vpsrlw $10, %xmm1, %xmm1
|
2019-01-14 06:08:26 +08:00
|
|
|
; AVX-NEXT: vpaddw %xmm1, %xmm0, %xmm0
|
2019-01-14 05:21:46 +08:00
|
|
|
; AVX-NEXT: retq
|
|
|
|
%1 = lshr <8 x i16> %a0, <i16 10, i16 10, i16 10, i16 10, i16 10, i16 10, i16 10, i16 10>
|
|
|
|
%2 = lshr <8 x i16> %a1, <i16 10, i16 10, i16 10, i16 10, i16 10, i16 10, i16 10, i16 10>
|
2019-01-14 20:12:42 +08:00
|
|
|
%3 = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> %1, <8 x i16> %2)
|
2019-01-14 05:21:46 +08:00
|
|
|
ret <8 x i16> %3
|
|
|
|
}
|