From patchwork Wed Mar 2 16:14:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 591038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DCBFC1402D8 for ; Thu, 3 Mar 2016 03:15:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JFgiZ9we; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=nRGNhvw1JwB7zfHsI+cbw6vSCGUftjl87R67hWJ20xoXPSVSefNVv pBhtI9vmAMTv2w7RxQW28A2bGYPEzjDMkaVnCcP6KQpLIMPUTRpzVeeo/eQXhGZB BazIWQM4x/kzigRCA4wtvh7u3fBZ4fgQBUNPt6Fosvx/gQ2xP/d3ow= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=oOTQ+nYHsal2fdQd3OiNFmY/fxI=; b=JFgiZ9weAjxIsWsL/s7J D4tGFRSUcF56g68fyHYXmEymH2X4n32TaD8e+hoBrElOr9tDRxZwk/avGlkVN8SJ E0GUrTnSauRdw+nc6q4EmGbqQI9ZQZ+lw3abvMWufeUt9HxQUtaIf8uj2osNmyXh bEmyEc9Qhoqz15zdZAxfqbs= Received: (qmail 95732 invoked by alias); 2 Mar 2016 16:15:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 95714 invoked by uid 89); 2 Mar 2016 16:15:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=enkovich.gnu@gmail.com, enkovichgnugmailcom, Hx-languages-length:1596 X-HELO: mail-qg0-f41.google.com Received: from mail-qg0-f41.google.com (HELO mail-qg0-f41.google.com) (209.85.192.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 02 Mar 2016 16:15:42 +0000 Received: by mail-qg0-f41.google.com with SMTP id t4so16171455qge.0 for ; Wed, 02 Mar 2016 08:15:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=Db7Qk/aBuXJXhSBLd8kPksScX6e+PPL3VTkNfun6TYA=; b=RKlirqQ80IihRx+T/UriPVSaOdyh6xKG86OcszA8l7f5IiDiKfnr7Na5kN6YDl/Zrc HrkJgMFITpcHGf8OEqSaXQ6LJw3B5PvEJtxdvJWSMfkUcXVRK9/cYqnOK4GJDMkMDvLJ NhnBkWD2mWGcK48yO4OyTbqjBIWYv7UUHmITlo5NZieQ/Rkmw9qYxlRP6mgOvtgOmfkG oS0xCN39D+nWUI7VRVKqfN7a590ojI+KiS0uhRoSpSAAdIV87sZ+Mf2yzZsAM8MvSF05 cWKaFstKprmbyB1pwXMgrAf/5QI2P/XDfpOtHZ4Edk0EZRGkEEkJS5xquhDOf3LF4f9P vN/g== X-Gm-Message-State: AD7BkJKWYVObt15DSru+2Qk+tUsAzqE8JcSKD8XQwt95V+8z6YrGEpr4NZPeItyd269eug== X-Received: by 10.140.235.137 with SMTP id g131mr36588498qhc.43.1456935340852; Wed, 02 Mar 2016 08:15:40 -0800 (PST) Received: from msticlxl57.ims.intel.com (irdmzpr02-ext.ir.intel.com. [192.198.151.37]) by smtp.gmail.com with ESMTPSA id x62sm15088857qhc.42.2016.03.02.08.15.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 08:15:40 -0800 (PST) Date: Wed, 2 Mar 2016 19:14:54 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns Message-ID: <20160302160100.GA2588@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, This patch fixes mask type determination for boolean values comparison. That avoid incorrect application of masks conversion pattern. Bootstrapped and tested on x86_64-pc-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/ 2016-03-02 Ilya Enkovich * tree-vect-patterns.c (search_type_for_mask): Handle comparison of booleans. gcc/testsuite/ 2016-03-02 Ilya Enkovich * gcc.dg/pr70026.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr70026.c b/gcc/testsuite/gcc.dg/pr70026.c new file mode 100644 index 0000000..32f59e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70026.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +unsigned int a[64], b[64], c[64], d[64], e[64]; + +void +foo () +{ + int i; + for (i = 0; i < 64; i++) + { + d[i] = a[i]; + e[i] = ((b[i] < e[i]) != !c[i]) && !a[i]; + } +} diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 95ce38d..7037e04 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -3219,6 +3219,15 @@ search_type_for_mask (tree var, vec_info *vinfo) { tree comp_vectype, mask_type; + if (TREE_CODE (TREE_TYPE (rhs1)) == BOOLEAN_TYPE) + { + res = search_type_for_mask (rhs1, vinfo); + res2 = search_type_for_mask (gimple_assign_rhs2 (def_stmt), vinfo); + if (!res || (res2 && TYPE_PRECISION (res) > TYPE_PRECISION (res2))) + res = res2; + break; + } + comp_vectype = get_vectype_for_scalar_type (TREE_TYPE (rhs1)); if (comp_vectype == NULL_TREE) return NULL_TREE;