diff options
| author | Craig Topper <craig.topper@intel.com> | 2018-01-26 22:17:40 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2018-01-26 22:17:40 +0000 |
| commit | 8a444ee67ccba1ae6c57ebe76dc1342c6fd2bfff (patch) | |
| tree | a68768bcf431305b9b52ef9f1835a7a499375f14 /llvm/lib | |
| parent | 5bce08ddff5e755f4d90ee0d11864b5bc058ed7d (diff) | |
| download | bcm5719-llvm-8a444ee67ccba1ae6c57ebe76dc1342c6fd2bfff.tar.gz bcm5719-llvm-8a444ee67ccba1ae6c57ebe76dc1342c6fd2bfff.zip | |
[X86] Use vpternlog to implement vector not under AVX512.
Previously we had to materialize all 1s in a register using vpternlog or pcmpeq and then xor with that. By using vpternlog directly we can do it in one operation.
This is implemented using isel patterns, but we should maybe consider creating a generalized vpternlog combiner.
llvm-svn: 323572
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86InstrAVX512.td | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td b/llvm/lib/Target/X86/X86InstrAVX512.td index e1c621fe38d..b7610d49bf4 100644 --- a/llvm/lib/Target/X86/X86InstrAVX512.td +++ b/llvm/lib/Target/X86/X86InstrAVX512.td @@ -10207,6 +10207,42 @@ defm VPTERNLOGD : avx512_common_ternlog<"vpternlogd", SSE_INTALU_ITINS_P, defm VPTERNLOGQ : avx512_common_ternlog<"vpternlogq", SSE_INTALU_ITINS_P, avx512vl_i64_info>, VEX_W; + +// Patterns to implement vnot using vpternlog instead of creating all ones +// using pcmpeq or vpternlog and then xoring with that. The value 15 is chosen +// so that the result is only dependent on src0. But we use the same source +// for all operands to prevent a false dependency. +// TODO: We should maybe have a more generalized algorithm for folding to +// vpternlog. +let Predicates = [HasAVX512] in { + def : Pat<(v8i64 (xor VR512:$src, (bc_v8i64 (v16i32 immAllOnesV)))), + (VPTERNLOGQZrri VR512:$src, VR512:$src, VR512:$src, (i8 15))>; +} + +let Predicates = [HasAVX512, NoVLX] in { + def : Pat<(v2i64 (xor VR128X:$src, (bc_v2i64 (v4i32 immAllOnesV)))), + (EXTRACT_SUBREG + (VPTERNLOGQZrri + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR128X:$src, sub_xmm), + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR128X:$src, sub_xmm), + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR128X:$src, sub_xmm), + (i8 15)), sub_xmm)>; + def : Pat<(v4i64 (xor VR256X:$src, (bc_v4i64 (v8i32 immAllOnesV)))), + (EXTRACT_SUBREG + (VPTERNLOGQZrri + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR256X:$src, sub_ymm), + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR256X:$src, sub_ymm), + (INSERT_SUBREG (v8i64 (IMPLICIT_DEF)), VR256X:$src, sub_ymm), + (i8 15)), sub_ymm)>; +} + +let Predicates = [HasVLX] in { + def : Pat<(v2i64 (xor VR128X:$src, (bc_v2i64 (v4i32 immAllOnesV)))), + (VPTERNLOGQZ128rri VR128X:$src, VR128X:$src, VR128X:$src, (i8 15))>; + def : Pat<(v4i64 (xor VR256X:$src, (bc_v4i64 (v8i32 immAllOnesV)))), + (VPTERNLOGQZ256rri VR256X:$src, VR256X:$src, VR256X:$src, (i8 15))>; +} + //===----------------------------------------------------------------------===// // AVX-512 - FixupImm //===----------------------------------------------------------------------===// |

