From patchwork Fri Oct 2 14:11:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 525556 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 BCC6C1402B2 for ; Sat, 3 Oct 2015 00:11:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EAketIcg; 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=SZj39uRgNU+GU6XnHhF4CCrEFFK7e+yzoMjNr/il9t+RJsARHvpuc qeDNiaQlqnI5LRly7gnfZsfLdus3oiM7id41OsrW4r1IleG7Qlhk8L25qM8WNm5e uesM9m1Y1cFg1wlEOPjlOkXummQB+h74yJ5kf98bsYDJbmZuKHVyDg= 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=6Hu5R+4qTOSMZ/BKRxSFCgChZUA=; b=EAketIcgnp74OqKCHNeL dOOKSCBKtMEWIkDkEMn6LbkewSqtUC9vOSrIWK5ZqCTFNCMtfSxMwlbqkAi0vZrW AmXjfRJ7pk8HoBFsKhlhHJjrmVMhB3tvgX//JcOSyv1OkxynFimlTGi587FfOQHH EYcIuvn6S19+8HRAcpvr+mA= Received: (qmail 51043 invoked by alias); 2 Oct 2015 14:11:29 -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 51032 invoked by uid 89); 2 Oct 2015 14:11:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 02 Oct 2015 14:11:27 +0000 Received: by qkcf65 with SMTP id f65so43093243qkc.3 for ; Fri, 02 Oct 2015 07:11:25 -0700 (PDT) X-Received: by 10.55.195.198 with SMTP id r67mr9949366qkl.10.1443795085333; Fri, 02 Oct 2015 07:11:25 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id c36sm4696415qge.49.2015.10.02.07.11.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 07:11:24 -0700 (PDT) Date: Fri, 2 Oct 2015 17:11:02 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [[Boolean Vector, patch 5/5] Support boolean vectors in vector lowering Message-ID: <20151002141102.GI26618@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 supports boolean vectors in vector lowering. Main change is to lower vector comparison into comparisons, not cond_exprs. Thanks, Ilya --- 2015-10-02 Ilya Enkovich * tree-vect-generic.c (elem_op_func): Add new operand to hold vector type. (do_unop): Adjust to modified function type. (do_binop): Likewise. (do_plus_minus): Likewise. (do_negate); Likewise. (expand_vector_piecewise): Likewise. (do_cond): Likewise. (do_compare): Use comparison instead of condition. (expand_vector_divmod): Use boolean vector type for comparison. (expand_vector_operations_1): Skip scalar mask operations. diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index dad38a2..a20b9af 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -105,14 +105,27 @@ build_word_mode_vector_type (int nunits) } typedef tree (*elem_op_func) (gimple_stmt_iterator *, - tree, tree, tree, tree, tree, enum tree_code); + tree, tree, tree, tree, tree, enum tree_code, + tree); static inline tree tree_vec_extract (gimple_stmt_iterator *gsi, tree type, tree t, tree bitsize, tree bitpos) { if (bitpos) - return gimplify_build3 (gsi, BIT_FIELD_REF, type, t, bitsize, bitpos); + { + if (TREE_CODE (type) == BOOLEAN_TYPE) + { + tree itype + = build_nonstandard_integer_type (tree_to_uhwi (bitsize), 0); + tree field = gimplify_build3 (gsi, BIT_FIELD_REF, itype, t, + bitsize, bitpos); + return gimplify_build2 (gsi, NE_EXPR, type, field, + build_zero_cst (itype)); + } + else + return gimplify_build3 (gsi, BIT_FIELD_REF, type, t, bitsize, bitpos); + } else return gimplify_build1 (gsi, VIEW_CONVERT_EXPR, type, t); } @@ -120,7 +133,7 @@ tree_vec_extract (gimple_stmt_iterator *gsi, tree type, static tree do_unop (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b ATTRIBUTE_UNUSED, tree bitpos, tree bitsize, - enum tree_code code) + enum tree_code code, tree type ATTRIBUTE_UNUSED) { a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos); return gimplify_build1 (gsi, code, inner_type, a); @@ -128,7 +141,8 @@ do_unop (gimple_stmt_iterator *gsi, tree inner_type, tree a, static tree do_binop (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, - tree bitpos, tree bitsize, enum tree_code code) + tree bitpos, tree bitsize, enum tree_code code, + tree type ATTRIBUTE_UNUSED) { if (TREE_CODE (TREE_TYPE (a)) == VECTOR_TYPE) a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos); @@ -145,20 +159,12 @@ do_binop (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, size equal to the size of INNER_TYPE. */ static tree do_compare (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, - tree bitpos, tree bitsize, enum tree_code code) + tree bitpos, tree bitsize, enum tree_code code, tree type) { - tree comp_type; - a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos); b = tree_vec_extract (gsi, inner_type, b, bitsize, bitpos); - comp_type = build_nonstandard_integer_type - (GET_MODE_BITSIZE (TYPE_MODE (inner_type)), 0); - - return gimplify_build3 (gsi, COND_EXPR, comp_type, - fold_build2 (code, boolean_type_node, a, b), - build_int_cst (comp_type, -1), - build_int_cst (comp_type, 0)); + return gimplify_build2 (gsi, code, TREE_TYPE (type), a, b); } /* Expand vector addition to scalars. This does bit twiddling @@ -177,7 +183,7 @@ do_compare (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, static tree do_plus_minus (gimple_stmt_iterator *gsi, tree word_type, tree a, tree b, tree bitpos ATTRIBUTE_UNUSED, tree bitsize ATTRIBUTE_UNUSED, - enum tree_code code) + enum tree_code code, tree type ATTRIBUTE_UNUSED) { tree inner_type = TREE_TYPE (TREE_TYPE (a)); unsigned HOST_WIDE_INT max; @@ -209,7 +215,8 @@ static tree do_negate (gimple_stmt_iterator *gsi, tree word_type, tree b, tree unused ATTRIBUTE_UNUSED, tree bitpos ATTRIBUTE_UNUSED, tree bitsize ATTRIBUTE_UNUSED, - enum tree_code code ATTRIBUTE_UNUSED) + enum tree_code code ATTRIBUTE_UNUSED, + tree type ATTRIBUTE_UNUSED) { tree inner_type = TREE_TYPE (TREE_TYPE (b)); HOST_WIDE_INT max; @@ -255,7 +262,7 @@ expand_vector_piecewise (gimple_stmt_iterator *gsi, elem_op_func f, for (i = 0; i < nunits; i += delta, index = int_const_binop (PLUS_EXPR, index, part_width)) { - tree result = f (gsi, inner_type, a, b, index, part_width, code); + tree result = f (gsi, inner_type, a, b, index, part_width, code, type); constructor_elt ce = {NULL_TREE, result}; v->quick_push (ce); } @@ -298,7 +305,7 @@ expand_vector_parallel (gimple_stmt_iterator *gsi, elem_op_func f, tree type, /* Use a single scalar operation with a mode no wider than word_mode. */ mode = mode_for_size (tree_to_uhwi (TYPE_SIZE (type)), MODE_INT, 0); compute_type = lang_hooks.types.type_for_mode (mode, 1); - result = f (gsi, compute_type, a, b, NULL_TREE, NULL_TREE, code); + result = f (gsi, compute_type, a, b, NULL_TREE, NULL_TREE, code, type); warning_at (loc, OPT_Wvector_operation_performance, "vector operation will be expanded with a " "single scalar operation"); @@ -615,11 +622,12 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, if (addend == NULL_TREE && expand_vec_cond_expr_p (type, type)) { - tree zero, cst, cond; + tree zero, cst, cond, mask_type; gimple *stmt; + mask_type = build_same_sized_truth_vector_type (type); zero = build_zero_cst (type); - cond = build2 (LT_EXPR, type, op0, zero); + cond = build2 (LT_EXPR, mask_type, op0, zero); for (i = 0; i < nunits; i++) vec[i] = build_int_cst (TREE_TYPE (type), ((unsigned HOST_WIDE_INT) 1 @@ -1386,7 +1394,8 @@ count_type_subparts (tree type) static tree do_cond (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b, - tree bitpos, tree bitsize, enum tree_code code) + tree bitpos, tree bitsize, enum tree_code code, + tree type ATTRIBUTE_UNUSED) { if (TREE_CODE (TREE_TYPE (a)) == VECTOR_TYPE) a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos); @@ -1496,6 +1505,12 @@ expand_vector_operations_1 (gimple_stmt_iterator *gsi) if (TREE_CODE (type) != VECTOR_TYPE) return; + /* A scalar operation pretending to be a vector one. */ + if (VECTOR_BOOLEAN_TYPE_P (type) + && !VECTOR_MODE_P (TYPE_MODE (type)) + && TYPE_MODE (type) != BLKmode) + return; + if (CONVERT_EXPR_CODE_P (code) || code == FLOAT_EXPR || code == FIX_TRUNC_EXPR