[PATCH] D87912: [X86] Use shuffle to widen truncate of 128-bit and smaller vectors
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 09:17:22 PDT 2020
foad added inline comments.
================
Comment at: llvm/test/CodeGen/X86/avx512-vec-cmp.ll:1489
; AVX512BW-NEXT: vpmovm2w %k0, %zmm0 ## encoding: [0x62,0xf2,0xfe,0x48,0x28,0xc0]
-; AVX512BW-NEXT: vpacksswb %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xf9,0x63,0xc0]
+; AVX512BW-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,u,u,u,u,u,u,u,u,u,u,u,u,u,u]
+; AVX512BW-NEXT: ## encoding: [0xc4,0xe2,0x79,0x00,0x05,A,A,A,A]
----------------
Is this a regression? It's the same number of instructions but it looks like longer encoding, and it uses the constant pool. There are some similar cases in `bitcast-and-setcc-512.ll` where it uses shufps instead of packssdw. I haven't looked into them yet.
================
Comment at: llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll:383
; SSE2-SSSE3-NEXT: pand %xmm6, %xmm8
+; SSE2-SSSE3-NEXT: psllw $15, %xmm8
; SSE2-SSSE3-NEXT: packsswb %xmm8, %xmm8
----------------
This regression (and similar ones below in this file and in `bitcast-and-setcc-512.ll`) are due to the recursion depth limit in ComputeNumSignBits, and the fact that the unoptimized DAG that we generate is now deeper but narrower. By contrast, scalarizing with EXTRACT_VECTOR_ELT tends to generate wide shallow DAGs.
I did try a couple of things to mitigate this, but I'm really not sure how much effort it's worth putting in to work around the arbitrary depth limit:
1. I tried adding a special case to generate PACKSS directly instead of BITCAST+VECTOR_SHUFFLE, if the types are appropriate and enough sign bits are known
2. I tried changing `DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS` to generate a VECTOR_SHUFFLE instead of "a nasty build vector" in the common case where exactly two vectors are concatenated.
Together these fixed some but not all of the psllw regressions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87912/new/
https://reviews.llvm.org/D87912
More information about the llvm-commits
mailing list