From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37851 invoked by alias); 24 Apr 2017 07:51:33 -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 36770 invoked by uid 89); 24 Apr 2017 07:51:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f194.google.com Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Apr 2017 07:51:31 +0000 Received: by mail-wr0-f194.google.com with SMTP id w50so15110897wrc.0 for ; Mon, 24 Apr 2017 00:51:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:user-agent:cc :references:in-reply-to:mime-version:content-transfer-encoding :message-id; bh=iYBf3F0eNlTxwnWN12caGztEyR4D+SGS+tN5TBi9nEs=; b=I1Ufm5YsYZfgHcL2Es222haZ4s3HxYyYt68R1g3uURc/eCJa7YH49wU2AsYuNJljpY fY5njzyAirkkpI0ga1T1zDkNXChWPjdWZBYWUiZ5GcGKW/xyAff56S2w0E28BL21shAm MPrMsyYIh4V7LxrTevsQXz+NEaXtbmpfrhHzFLH2u0uGIwAbKPCZm08fbFEXKI4odGjt mGTnFa0NTLJ3IYAHZ3tKoSzA9puZ1jAFuyba4bElZi+33QdK9KZywJuWKSe9VH+hFDex +boqiYbFbnUes/qSi12WbA/HA44B2SerkgaGrtFm/VeNcRj23GOppwBlD9FUtH6+ATCu AMzA== X-Gm-Message-State: AN3rC/6wKrdWuPDumrCAHFFkShpkEtMM3W2WHLFynT9poA1rZTpGWqj9 EHJH32ORbsrtlQ== X-Received: by 10.223.135.130 with SMTP id b2mr4738706wrb.48.1493020291321; Mon, 24 Apr 2017 00:51:31 -0700 (PDT) Received: from princessluna.localnet (p4FE41D98.dip0.t-ipconnect.de. [79.228.29.152]) by smtp.gmail.com with ESMTPSA id q130sm12053329wmd.29.2017.04.24.00.51.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 00:51:30 -0700 (PDT) From: Allan Sandfeld Jensen To: Jakub Jelinek Subject: Re: [PATCH] [x86] Avoid builtins for SSE/AVX2 immidiate logical shifts Date: Mon, 24 Apr 2017 08:02:00 -0000 User-Agent: KMail/1.13.7 (Linux/4.9.0-2-amd64; KDE/4.14.27; x86_64; ; ) Cc: Uros Bizjak , gcc-patches@gcc.gnu.org References: <201704221338.46300.linux@carewolf.com> <201704240933.09704.linux@carewolf.com> <20170424074349.GG1809@tucnak> In-Reply-To: <20170424074349.GG1809@tucnak> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201704240951.29932.linux@carewolf.com> X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg01001.txt.bz2 On Monday 24 April 2017, Jakub Jelinek wrote: > On Mon, Apr 24, 2017 at 09:33:09AM +0200, Allan Sandfeld Jensen wrote: > > --- a/gcc/config/i386/avx2intrin.h > > +++ b/gcc/config/i386/avx2intrin.h > > @@ -667,7 +667,7 @@ extern __inline __m256i > > > > __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) > > _mm256_slli_epi16 (__m256i __A, int __B) > > { > > > > - return (__m256i)__builtin_ia32_psllwi256 ((__v16hi)__A, __B); > > + return ((__B & 0xff) < 16) ? (__m256i)((__v16hi)__A << (__B & 0xff)) : > > _mm256_setzero_si256(); > > > > } > > What is the advantage of doing that when you replace one operation with > several (&, <, ?:, <<)? > I'd say instead we should fold the builtins if in the gimple fold target > hook we see the shift count constant and can decide based on that. > Or we could use __builtin_constant_p (__B) to decide whether to use > the generic vector shifts or builtin, but that means larger IL. The advantage is that in this builtin, the __B is always a literal (or constexpr), so the if statement is resolved at compile time. `Allan