From patchwork Fri Feb 26 09:22:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 588701 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 7235114029E for ; Fri, 26 Feb 2016 20:23:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=HFmefW2w; 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=h8wKxcoLcBVxz+/8rqDABGcZQf6E4SEBv5GB58wD0PRkH8L4ZHjpO t5miuX5A4lJG/l5VaX0TNZxVffB5RR+4ZH4iQUxdmTIfI1HV48H3TwdBy/H9bxVc S2A+V246cOM2scu6+Bu+D3qsLL0DlGsbUIqmgtumgmwzgIHqGwQpaY= 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=mYaWB3szeRpRm4lilXrUx9Z6rK0=; b=HFmefW2w/XsQ4JzhsdGu XQEaRnbVduNRrdsYieqUc+QPVW0jyExOia1XXmZmBLSV56JvQz/Qf/POA0nLY4X8 2XD4KtdVNAwJxlStoiDtlS/N8dLU67fqoZZqKQ5iczHRlQ8kMVoZawQLrwBvKD1O Ca/nzNpd1iqwlQT1KqAcyZw= Received: (qmail 87119 invoked by alias); 26 Feb 2016 09:23:35 -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 87096 invoked by uid 89); 26 Feb 2016 09:23:33 -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=uns, 20160226, 2016-02-26 X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 26 Feb 2016 09:23:32 +0000 Received: by mail-wm0-f41.google.com with SMTP id g62so64620369wme.0 for ; Fri, 26 Feb 2016 01:23:32 -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=T+yUsT8B1jjHJUCL8qeQA/Loca8cvbw8tfbo5q7oNGo=; b=NDcexj+ZzmMf9Nsnx9VTB8eHsQVTBptuQvUX6fV1lzNDIs3PxxWz5+BMupCUuJ7nu4 YJYycct6BPyhMKN3ahJiXw/vikyQUd4dRIEvG4VeNdZaXCMjd6hTWqN3rJmdJ0SX32nx nqbiE2NyIr6I0Pvf8P3Y4p7peS4tHn3Yh1fzaZw73n+LbBtu9uzSZwhxatgbDfruSslt 72Gm2MUrbngZF8ahyPXrV28yUiJm+3AD9Tqu8YePSOj8LkuCtSK3oJ3pZgjNHzv2jLgw 3Cc9dpgr23FyvxzNyeDnvp9kEQX1EJXJx7OdtNxi2oUWtwMxTyVwdKrakx/QdEuWunM6 jnVw== X-Gm-Message-State: AD7BkJKWpA/u7eCZjQqD+ECUjpVsbpicgqhYXGfxpBK6WPirWVLGhSiStN+PI0aDjfggUA== X-Received: by 10.194.113.130 with SMTP id iy2mr611682wjb.56.1456478609540; Fri, 26 Feb 2016 01:23:29 -0800 (PST) Received: from msticlxl57.ims.intel.com (irdmzpr01-ext.ir.intel.com. [192.198.151.36]) by smtp.gmail.com with ESMTPSA id lc3sm11617747wjb.7.2016.02.26.01.23.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 01:23:28 -0800 (PST) Date: Fri, 26 Feb 2016 12:22:44 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, PR69956] Fix multi-step conversion of boolean vectors Message-ID: <20160226092244.GA48923@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, Currently multi-step vector conversion tries to compute intermediate type from its mode but it doesn't work for boolean vectors. This patch introduces a computation of intermediate vector masks. Bootstrapped and tested on x86_64-pc-linux-gnu. OK for trunk? Thanks, Ilya --- gcc/ 2016-02-26 Ilya Enkovich PR tree-optimization/69956 * tree-vect-stmts.c (supportable_widening_operation): Support multi-step conversion of boolean vectors. (supportable_narrowing_operation): Likewise. gcc/testsuite/ 2016-02-26 Ilya Enkovich PR tree-optimization/69956 * gcc.dg/pr69956.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr69956.c b/gcc/testsuite/gcc.dg/pr69956.c new file mode 100644 index 0000000..37d24d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr69956.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize" } */ +/* { dg-additional-options "-march=skylake-avx512" { target { i?86-*-* x86_64-*-* } } } */ + +void +fn1 (char *b, char *d, int *c, int i) +{ + for (; i; i++, d++) + if (b[i]) + *d = c[i]; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 9678d7c..182b277 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9000,9 +9000,19 @@ supportable_widening_operation (enum tree_code code, gimple *stmt, for (i = 0; i < MAX_INTERM_CVT_STEPS; i++) { intermediate_mode = insn_data[icode1].operand[0].mode; - intermediate_type - = lang_hooks.types.type_for_mode (intermediate_mode, - TYPE_UNSIGNED (prev_type)); + if (VECTOR_BOOLEAN_TYPE_P (prev_type)) + { + intermediate_type + = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) / 2, + current_vector_size); + if (intermediate_mode != TYPE_MODE (intermediate_type)) + return false; + } + else + intermediate_type + = lang_hooks.types.type_for_mode (intermediate_mode, + TYPE_UNSIGNED (prev_type)); + optab3 = optab_for_tree_code (c1, intermediate_type, optab_default); optab4 = optab_for_tree_code (c2, intermediate_type, optab_default); @@ -9065,7 +9075,7 @@ supportable_narrowing_operation (enum tree_code code, tree vectype = vectype_in; tree narrow_vectype = vectype_out; enum tree_code c1; - tree intermediate_type; + tree intermediate_type, prev_type; machine_mode intermediate_mode, prev_mode; int i; bool uns; @@ -9111,6 +9121,7 @@ supportable_narrowing_operation (enum tree_code code, /* Check if it's a multi-step conversion that can be done using intermediate types. */ prev_mode = vec_mode; + prev_type = vectype; if (code == FIX_TRUNC_EXPR) uns = TYPE_UNSIGNED (vectype_out); else @@ -9145,8 +9156,17 @@ supportable_narrowing_operation (enum tree_code code, for (i = 0; i < MAX_INTERM_CVT_STEPS; i++) { intermediate_mode = insn_data[icode1].operand[0].mode; - intermediate_type - = lang_hooks.types.type_for_mode (intermediate_mode, uns); + if (VECTOR_BOOLEAN_TYPE_P (prev_type)) + { + intermediate_type + = build_truth_vector_type (TYPE_VECTOR_SUBPARTS (prev_type) * 2, + current_vector_size); + if (intermediate_mode != TYPE_MODE (intermediate_type)) + return false; + } + else + intermediate_type + = lang_hooks.types.type_for_mode (intermediate_mode, uns); interm_optab = optab_for_tree_code (VEC_PACK_TRUNC_EXPR, intermediate_type, optab_default); @@ -9164,6 +9184,7 @@ supportable_narrowing_operation (enum tree_code code, return true; prev_mode = intermediate_mode; + prev_type = intermediate_type; optab1 = interm_optab; }