From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43235 invoked by alias); 18 Dec 2017 13:34:25 -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 43220 invoked by uid 89); 18 Dec 2017 13:34:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=1746 X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Dec 2017 13:34:22 +0000 Received: by mail-wm0-f49.google.com with SMTP id 64so29378574wme.3 for ; Mon, 18 Dec 2017 05:34:22 -0800 (PST) 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; bh=v0ZZu1uH3OUc+d0PEflJkh6tACitq59k/+PZD1lPKAE=; b=FPyrRTs9d9MWQEwxE+1A0jX/BTpEPT95/RFSkWRcBjqp7dhLlpRxG9euyMdRTXSqxq yZ2OEpqxPwrJNx07y5eIsY8gYXYZA2zh5kJHgLdSg/alteM6RTTvggOIVW9Kvn57fjs2 lzkDYTZ9ysIKmor5dtr0Z/vTbTc/PP2UXStKjsJ1aYiRYYPnh2wJ2Tk07/M0lzcnarO5 z3I253jA6RZwUPDFUWGsVtI2qFhsunj3a6YHsFAHFbNA/qwT7hOhlX/NPX1YmPsrJaQM tc69Gj76uVbCRmRn85VdZFZHnrJK921UOkolw1NlNP9svv+JSaqXAZiqB5+i3OxMYZe6 usrw== X-Gm-Message-State: AKGB3mJKdTFAcq+OIlZlztP+2BiJJs8zaYiJUFkI/4N3rmKv6DEfw12/ ZHyvPUj4dmHdywKQRzV+P6MrhXGgVANQGAUH3kHXOA== X-Google-Smtp-Source: ACJfBouu7Axa93kaURMHB8Y4cA9fv+0h/QXR19z3PaoE7KkiwI6DV+gtW9Ya34fZUBxhUNpUjAybHyk7K2C+bp28UTo= X-Received: by 10.80.175.161 with SMTP id h30mr30107001edd.292.1513604060656; Mon, 18 Dec 2017 05:34:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.167.196 with HTTP; Mon, 18 Dec 2017 05:34:20 -0800 (PST) In-Reply-To: <87efo3mrds.fsf@linaro.org> References: <87indfmrgt.fsf@linaro.org> <87efo3mrds.fsf@linaro.org> From: Richard Biener Date: Mon, 18 Dec 2017 13:34:00 -0000 Message-ID: Subject: Re: [01/13] Add a qimode_for_vec_perm helper function To: GCC Patches , Richard Sandiford Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg01163.txt.bz2 On Sun, Dec 10, 2017 at 12:08 AM, Richard Sandiford wrote: > The vec_perm code falls back to doing byte-level permutes if > element-level permutes aren't supported. There were two copies > of the code to calculate the mode, and later patches add another, > so this patch splits it out into a helper function. > Ok. > 2017-12-09 Richard Sandiford > > gcc/ > * optabs-query.h (qimode_for_vec_perm): Declare. > * optabs-query.c (can_vec_perm_p): Split out qimode search to... > (qimode_for_vec_perm): ...this new function. > * optabs.c (expand_vec_perm): Use qimode_for_vec_perm. > > Index: gcc/optabs-query.h > =================================================================== > --- gcc/optabs-query.h 2017-12-09 22:47:12.476364764 +0000 > +++ gcc/optabs-query.h 2017-12-09 22:47:14.730310076 +0000 > @@ -174,6 +174,7 @@ enum insn_code can_extend_p (machine_mod > enum insn_code can_float_p (machine_mode, machine_mode, int); > enum insn_code can_fix_p (machine_mode, machine_mode, int, bool *); > bool can_conditionally_move_p (machine_mode mode); > +opt_machine_mode qimode_for_vec_perm (machine_mode); > bool can_vec_perm_p (machine_mode, bool, vec_perm_indices *); > /* Find a widening optab even if it doesn't widen as much as we want. */ > #define find_widening_optab_handler(A, B, C) \ > Index: gcc/optabs-query.c > =================================================================== > --- gcc/optabs-query.c 2017-12-09 22:47:12.476364764 +0000 > +++ gcc/optabs-query.c 2017-12-09 22:47:14.729310075 +0000 > @@ -345,6 +345,22 @@ can_conditionally_move_p (machine_mode m > return direct_optab_handler (movcc_optab, mode) != CODE_FOR_nothing; > } > > +/* If a target doesn't implement a permute on a vector with multibyte > + elements, we can try to do the same permute on byte elements. > + If this makes sense for vector mode MODE then return the appropriate > + byte vector mode. */ > + > +opt_machine_mode > +qimode_for_vec_perm (machine_mode mode) > +{ > + machine_mode qimode; > + if (GET_MODE_INNER (mode) != QImode > + && mode_for_vector (QImode, GET_MODE_SIZE (mode)).exists (&qimode) > + && VECTOR_MODE_P (qimode)) > + return qimode; > + return opt_machine_mode (); > +} > + > /* Return true if VEC_PERM_EXPR of arbitrary input vectors can be > expanded using SIMD extensions of the CPU. SEL may be NULL, which > stands for an unknown constant. Note that additional permutations > @@ -375,9 +391,7 @@ can_vec_perm_p (machine_mode mode, bool > return true; > > /* We allow fallback to a QI vector mode, and adjust the mask. */ > - if (GET_MODE_INNER (mode) == QImode > - || !mode_for_vector (QImode, GET_MODE_SIZE (mode)).exists (&qimode) > - || !VECTOR_MODE_P (qimode)) > + if (!qimode_for_vec_perm (mode).exists (&qimode)) > return false; > > /* ??? For completeness, we ought to check the QImode version of > Index: gcc/optabs.c > =================================================================== > --- gcc/optabs.c 2017-12-09 22:47:12.476364764 +0000 > +++ gcc/optabs.c 2017-12-09 22:47:14.731310077 +0000 > @@ -5452,9 +5452,7 @@ expand_vec_perm (machine_mode mode, rtx > > /* Set QIMODE to a different vector mode with byte elements. > If no such mode, or if MODE already has byte elements, use VOIDmode. */ > - if (GET_MODE_INNER (mode) == QImode > - || !mode_for_vector (QImode, w).exists (&qimode) > - || !VECTOR_MODE_P (qimode)) > + if (!qimode_for_vec_perm (mode).exists (&qimode)) > qimode = VOIDmode; > > /* If the input is a constant, expand it specially. */