From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43460 invoked by alias); 26 Jul 2017 10:42:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 42654 invoked by uid 89); 26 Jul 2017 10:42:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-ua0-f193.google.com Received: from mail-ua0-f193.google.com (HELO mail-ua0-f193.google.com) (209.85.217.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Jul 2017 10:41:57 +0000 Received: by mail-ua0-f193.google.com with SMTP id d29so12706341uai.2 for ; Wed, 26 Jul 2017 03:41:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0D3hCRQNGNnDbkhv+c6GLveVvadJPRD5zZxiMkjI8bs=; b=h4txLeEqlQJEhMUvgHb0AI0QcKwuKkQ83umojycue/VoG/DUVN1JSMxxcNbWfgKttg DO8QBPwNkwXzcYt+R00+jOUjN7M9EkH3JC82UmHsj6VECowO71FM/YiNHdOy1tC1k74O lIUxKbAklcd2PsNc5jeVEwNzJCazMZiL5GKcS8B9VxWMc00tr6HHy8UJ+zVyqMx0CvB5 IVn73H3uucUi/HZdzkdFHSoE8OY6ANs4RyiI9id4tcQyCgMIFaTK+TLWpG2+oCL0T8Kp BUMMXYZwMjrAja8cSApy/glvFJgbPaWWKQFc9OZX4P5NJ+m3oPYjqW/VItdR/U6iPkoU dilA== X-Gm-Message-State: AIVw113kLaURWMMMu5X57NGvmetrhwVLMwYOS0CH6rgUm8AVbVpqyhDL 6Ej+Thonqu8VU5DfOn6jLT1axQz+Ow== X-Received: by 10.176.71.212 with SMTP id w20mr267453uac.158.1501065715869; Wed, 26 Jul 2017 03:41:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.218 with HTTP; Wed, 26 Jul 2017 03:41:55 -0700 (PDT) In-Reply-To: <20170725091432.GQ2123@tucnak> References: <20170725091432.GQ2123@tucnak> From: Uros Bizjak Date: Wed, 26 Jul 2017 10:42:00 -0000 Message-ID: Subject: Re: [PATCH] Switch vec_init and vec_extract optabs to 2 mode optab to allow extraction of vector from vector or initialization of vector from smaller vectors (PR target/80846) To: Jakub Jelinek Cc: Richard Biener , David Edelsohn , Segher Boessenkool , Marcus Shawcroft , Richard Earnshaw , Andreas Krebbel , Matthew Fortune , Eric Botcazou , Andrew Jenner , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017-07/txt/msg01650.txt.bz2 On Tue, Jul 25, 2017 at 11:14 AM, Jakub Jelinek wrote: > Hi! > > The following patch adjusts the vec_init and vec_extract optabs, so that > they don't have in the expander names just the vector mode, but also another > mode, for vec_extract the mode of the result and for vec_init the mode of > the elts of the vector passed as second operand. > > Without this patch, the second mode has been implicit, GET_MODE_INNER of > the vector mode, so one could just extract a single element from a vector > or construct vector from elements. While that is most common, we allow > in GIMPLE e.g. construction of V8DImode from 4 V2DImode elements etc. > and the vectorizer uses them. By having the second mode in the name > it allows the generic code (vectorizer, expansion) to query whether the > backend supports such vector from vector expansions or inits from vector > elts and use them if available. > > For vec_extract, if we say want to extract high V2SImode from V4SImode > the fallback is try to expand it as DImode extraction from V2DImode. > This works well in many cases, but doesn't really work for very large > vectors, say if we want to extract high V8SImode from V16SImode on x86, > we'd need OImode extraction from V2OImode, which is something the backend > doesn't have any support for. > For vec_init, the fallback is usually to go through memory, which is slow in > many cases. > > This patch only adds new vector from vector extract and init patterns to > the i386 backend, but I had to change many other targets too, because > it needs to have the element mode in the vec_extract/vec_init expander > names. Seems most of the backends didn't really have a mode attribute > usable for this or had it only in uppercase, while for the names we need > lowercase. Some backends had a convention on how to name lower case > vs. upper case modes, others didn't have any. So I'm CCing maintainers > of affected backends to seek advice on what mode attributes they want to > use. > > Bootstrapped/regtested on x86_64-linux and i686-linux, where it improves > e.g. the code generation for slp-43.c and slp-45.c testcases. > make cc1 tested in cross-compilers to the remaining targets. > > Ok for trunk? > > 2017-07-25 Jakub Jelinek > > PR target/80846 > * optabs.def (vec_extract_optab, vec_init_optab): Change from > a direct optab to conversion optab. > * optabs.c (expand_vector_broadcast): Use convert_optab_handler > with GET_MODE_INNER as last argument instead of optab_handler. > * expmed.c (extract_bit_field_1): Likewise. Use vector from > vector extraction if possible and optab is available. > * expr.c (store_constructor): Use convert_optab_handler instead > of optab_handler. Use vector initialization from smaller > vectors if possible and optab is available. > * tree-vect-stmts.c (vectorizable_load): Likewise. > * doc/md.texi (vec_extract, vec_init): Document that the optabs > now have two modes. > * config/i386/i386.c (ix86_expand_vector_init): Handle expansion > of vec_init from half-sized vectors with the same element mode. > * config/i386/sse.md (ssehalfvecmode): Add V4TI case. > (ssehalfvecmodelower, ssescalarmodelower): New mode attributes. > (reduc_plus_scal_v8df, reduc_plus_scal_v4df, reduc_plus_scal_v2df, > reduc_plus_scal_v16sf, reduc_plus_scal_v8sf, reduc_plus_scal_v4sf, > reduc__scal_, reduc_umin_scal_v8hi): Add element mode > after mode in gen_vec_extract* calls. > (vec_extract): Renamed to ... > (vec_extract): ... this. > (vec_extract): New expander. > (rotl3, rotr3, 3, ashrv2di3): Add > element mode after mode in gen_vec_init* calls. > (VEC_INIT_HALF_MODE): New mode iterator. > (vec_init): Renamed to ... > (vec_init): ... this. > (vec_init): New expander. > * config/i386/mmx.md (vec_extractv2sf): Renamed to ... > (vec_extractv2sfsf): ... this. > (vec_initv2sf): Renamed to ... > (vec_initv2sfsf): ... this. > (vec_extractv2si): Renamed to ... > (vec_extractv2sisi): ... this. > (vec_initv2si): Renamed to ... > (vec_initv2sisi): ... this. > (vec_extractv4hi): Renamed to ... > (vec_extractv4hihi): ... this. > (vec_initv4hi): Renamed to ... > (vec_initv4hihi): ... this. > (vec_extractv8qi): Renamed to ... > (vec_extractv8qiqi): ... this. > (vec_initv8qi): Renamed to ... > (vec_initv8qiqi): ... this. > * config/rs6000/vector.md (VEC_base_l): New mode attribute. > (vec_init): Renamed to ... > (vec_init): ... this. > (vec_extract): Renamed to ... > (vec_extract): ... this. > * config/rs6000/paired.md (vec_initv2sf): Renamed to ... > (vec_initv2sfsf): ... this. > * config/rs6000/altivec.md (splitter, altivec_copysign_v4sf3, > vec_unpacku_hi_v16qi, vec_unpacku_hi_v8hi, vec_unpacku_lo_v16qi, > vec_unpacku_lo_v8hi, mulv16qi3, altivec_vreve2): Add > element mode after mode in gen_vec_init* calls. > * config/aarch64/aarch64-simd.md (vec_init): Renamed to ... > (vec_init): ... this. > (vec_extract): Renamed to ... > (vec_extract): ... this. > * config/aarch64/iterators.md (Vel): New mode attribute. > * config/s390/s390.c (s390_expand_vec_strlen, s390_expand_vec_movstr): > Add element mode after mode in gen_vec_extract* calls. > * config/s390/vector.md (non_vec_l): New mode attribute. > (vec_extract): Renamed to ... > (vec_extract): ... this. > (vec_init): Renamed to ... > (vec_init): ... this. > * config/s390/s390-builtins.def (s390_vlgvb, s390_vlgvh, s390_vlgvf, > s390_vlgvf_flt, s390_vlgvg, s390_vlgvg_dbl): Add element mode after > vec_extract mode. > * config/arm/iterators.md (V_elem_l): New mode attribute. > * config/arm/neon.md (vec_extract): Renamed to ... > (vec_extract): ... this. > (vec_extractv2di): Renamed to ... > (vec_extractv2didi): ... this. > (vec_init): Renamed to ... > (vec_init): ... this. > (reduc_plus_scal_, reduc_plus_scal_v2di, reduc_smin_scal_, > reduc_smax_scal_, reduc_umin_scal_, > reduc_umax_scal_, neon_vget_lane, neon_vget_laneu): > Add element mode after gen_vec_extract* calls. > * config/mips/mips-msa.md (vec_init): Renamed to ... > (vec_init): ... this. > (vec_extract): Renamed to ... > (vec_extract): ... this. > * config/mips/loongson.md (vec_init): Renamed to ... > (vec_init): ... this. > * config/mips/mips-ps-3d.md (vec_initv2sf): Renamed to ... > (vec_initv2sfsf): ... this. > (vec_extractv2sf): Renamed to ... > (vec_extractv2sfsf): ... this. > (reduc_plus_scal_v2sf, reduc_smin_scal_v2sf, reduc_smax_scal_v2sf): > Add element mode after gen_vec_extract* calls. > * config/mips/mips.md (unitmode): New mode iterator. > * config/spu/spu.c (spu_expand_prologue, spu_allocate_stack, > spu_builtin_extract): Add element mode after gen_vec_extract* calls. > * config/spu/spu.md (inner_l): New mode attribute. > (vec_init): Renamed to ... > (vec_init): ... this. > (vec_extract): Renamed to ... > (vec_extract): ... this. > * config/sparc/sparc.md (veltmode): New mode iterator. > (vec_init): Renamed to ... > (vec_init): ... this. > * config/ia64/vect.md (vec_initv2si): Renamed to ... > (vec_initv2sisi): ... this. > (vec_initv2sf): Renamed to ... > (vec_initv2sfsf): ... this. > (vec_extractv2sf): Renamed to ... > (vec_extractv2sfsf): ... this. > * config/powerpcspe/vector.md (VEC_base_l): New mode attribute. > (vec_init): Renamed to ... > (vec_init): ... this. > (vec_extract): Renamed to ... > (vec_extract): ... this. > * config/powerpcspe/paired.md (vec_initv2sf): Renamed to ... > (vec_initv2sfsf): ... this. > * config/powerpcspe/altivec.md (splitter, altivec_copysign_v4sf3, > vec_unpacku_hi_v16qi, vec_unpacku_hi_v8hi, vec_unpacku_lo_v16qi, > vec_unpacku_lo_v8hi, mulv16qi3): Add element mode after mode in > gen_vec_init* calls. OK for the x86 part. Thanks, Uros.