From patchwork Mon Oct 19 11:06:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 532226 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 59071140134 for ; Mon, 19 Oct 2015 22:07:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=MLzlCTX+; 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=Tb03ibTR4Ms5PIdzJhMA2shvLSu9XVZXZ8aIBTYUAHQzxf04r7KPU PyIqTaS7e7WlGDyrrbsmHfFyvcSzPCq23/PIndcpEoKUzhTE9k2YUSkqrXHAwAQI qMIJlOhTMmuf7MuDy0We/LW+SDOs3okKB0HDIPAdP4/BQc+/JpCFCU= 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=0ANVZOm8Ec7vyYJ18Sawgy2rGNA=; b=MLzlCTX+9j0P3rURcnvH WF/DL9gtNA9geId1Qc4WFVUR+ZP9gtEJIx6nm7WrXObWi/0mwjkuvfBshNSX0NPd oP8L+LDTspNO5BMV/D0bFgX5w37tSc8Hr8ygA5dJe75RE6eYzbZLBbMlIwpS7CTb vqGqGTFs2pf7ygbt4S7LL3g= Received: (qmail 88587 invoked by alias); 19 Oct 2015 11:07:24 -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 88577 invoked by uid 89); 19 Oct 2015 11:07:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f173.google.com Received: from mail-wi0-f173.google.com (HELO mail-wi0-f173.google.com) (209.85.212.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 19 Oct 2015 11:07:21 +0000 Received: by wicll6 with SMTP id ll6so42879wic.0 for ; Mon, 19 Oct 2015 04:07:18 -0700 (PDT) X-Received: by 10.194.103.38 with SMTP id ft6mr36658355wjb.15.1445252838006; Mon, 19 Oct 2015 04:07:18 -0700 (PDT) Received: from msticlxl57.ims.intel.com (jfdmzpr02-ext.jf.intel.com. [134.134.137.71]) by smtp.gmail.com with ESMTPSA id bv2sm39467833wjc.11.2015.10.19.04.07.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 04:07:16 -0700 (PDT) Date: Mon, 19 Oct 2015 14:06:49 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [vec-cmp, patch 7/6] Vector comparison enabling in SLP Message-ID: <20151019110649.GA36390@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, It appeared our testsuite doesn't have a test which would require vector comparison support in SLP even after boolean pattern disabling. This patch adds such tests and allow comparison for SLP. Is it OK? Thanks, Ilya --- gcc/ 2015-10-19 Ilya Enkovich * tree-vect-slp.c (vect_build_slp_tree_1): Allow comparison statements. (vect_get_constant_vectors): Support boolean vector constants. gcc/testsuite/ 2015-10-19 Ilya Enkovich * gcc.dg/vect/slp-cond-5.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/slp-cond-5.c b/gcc/testsuite/gcc.dg/vect/slp-cond-5.c new file mode 100644 index 0000000..5ade7d1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-cond-5.c @@ -0,0 +1,81 @@ +/* { dg-require-effective-target vect_condition } */ + +#include "tree-vect.h" + +#define N 128 + +static inline int +foo (int x, int y, int a, int b) +{ + if (x >= y && a > b) + return a; + else + return b; +} + +__attribute__((noinline, noclone)) void +bar (int * __restrict__ a, int * __restrict__ b, + int * __restrict__ c, int * __restrict__ d, + int * __restrict__ e, int w) +{ + int i; + for (i = 0; i < N/16; i++, a += 16, b += 16, c += 16, d += 16, e += 16) + { + e[0] = foo (c[0], d[0], a[0] * w, b[0] * w); + e[1] = foo (c[1], d[1], a[1] * w, b[1] * w); + e[2] = foo (c[2], d[2], a[2] * w, b[2] * w); + e[3] = foo (c[3], d[3], a[3] * w, b[3] * w); + e[4] = foo (c[4], d[4], a[4] * w, b[4] * w); + e[5] = foo (c[5], d[5], a[5] * w, b[5] * w); + e[6] = foo (c[6], d[6], a[6] * w, b[6] * w); + e[7] = foo (c[7], d[7], a[7] * w, b[7] * w); + e[8] = foo (c[8], d[8], a[8] * w, b[8] * w); + e[9] = foo (c[9], d[9], a[9] * w, b[9] * w); + e[10] = foo (c[10], d[10], a[10] * w, b[10] * w); + e[11] = foo (c[11], d[11], a[11] * w, b[11] * w); + e[12] = foo (c[12], d[12], a[12] * w, b[12] * w); + e[13] = foo (c[13], d[13], a[13] * w, b[13] * w); + e[14] = foo (c[14], d[14], a[14] * w, b[14] * w); + e[15] = foo (c[15], d[15], a[15] * w, b[15] * w); + } +} + + +int a[N], b[N], c[N], d[N], e[N]; + +int main () +{ + int i; + + check_vect (); + + for (i = 0; i < N; i++) + { + a[i] = i; + b[i] = 5; + e[i] = 0; + + switch (i % 9) + { + case 0: asm (""); c[i] = i; d[i] = i + 1; break; + case 1: c[i] = 0; d[i] = 0; break; + case 2: c[i] = i + 1; d[i] = i - 1; break; + case 3: c[i] = i; d[i] = i + 7; break; + case 4: c[i] = i; d[i] = i; break; + case 5: c[i] = i + 16; d[i] = i + 3; break; + case 6: c[i] = i - 5; d[i] = i; break; + case 7: c[i] = i; d[i] = i; break; + case 8: c[i] = i; d[i] = i - 7; break; + } + } + + bar (a, b, c, d, e, 2); + for (i = 0; i < N; i++) + if (e[i] != ((i % 3) == 0 || i <= 5 ? 10 : 2 * i)) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { i?86-*-* x86_64-*-* } } } } */ + diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 1424123..fa8291e 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -827,6 +827,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, if (TREE_CODE_CLASS (rhs_code) != tcc_binary && TREE_CODE_CLASS (rhs_code) != tcc_unary && TREE_CODE_CLASS (rhs_code) != tcc_expression + && TREE_CODE_CLASS (rhs_code) != tcc_comparison && rhs_code != CALL_EXPR) { if (dump_enabled_p ()) @@ -2596,7 +2597,14 @@ vect_get_constant_vectors (tree op, slp_tree slp_node, struct loop *loop; gimple_seq ctor_seq = NULL; - vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); + /* Check if vector type is a boolean vector. */ + if (TREE_CODE (TREE_TYPE (op)) == BOOLEAN_TYPE + && (VECTOR_BOOLEAN_TYPE_P (STMT_VINFO_VECTYPE (stmt_vinfo)) + || (code == COND_EXPR && op_num < 2))) + vector_type + = build_same_sized_truth_vector_type (STMT_VINFO_VECTYPE (stmt_vinfo)); + else + vector_type = get_vectype_for_scalar_type (TREE_TYPE (op)); nunits = TYPE_VECTOR_SUBPARTS (vector_type); if (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def @@ -2768,8 +2776,21 @@ vect_get_constant_vectors (tree op, slp_tree slp_node, { if (CONSTANT_CLASS_P (op)) { - op = fold_unary (VIEW_CONVERT_EXPR, - TREE_TYPE (vector_type), op); + if (VECTOR_BOOLEAN_TYPE_P (vector_type)) + { + /* Can't use VIEW_CONVERT_EXPR for booleans because + of possibly different sizes of scalar value and + vector element. */ + if (integer_zerop (op)) + op = build_int_cst (TREE_TYPE (vector_type), 0); + else if (integer_onep (op)) + op = build_int_cst (TREE_TYPE (vector_type), 1); + else + gcc_unreachable (); + } + else + op = fold_unary (VIEW_CONVERT_EXPR, + TREE_TYPE (vector_type), op); gcc_assert (op && CONSTANT_CLASS_P (op)); } else