From patchwork Fri Aug 18 08:13:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110363 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp595321qge; Fri, 18 Aug 2017 01:13:46 -0700 (PDT) X-Received: by 10.99.171.13 with SMTP id p13mr7727106pgf.109.1503044026839; Fri, 18 Aug 2017 01:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503044026; cv=none; d=google.com; s=arc-20160816; b=w2SbxpLIT6sY4Ex8gbl/nDd51kpbvPxm+ijIUGjkdSP4xfXLCnaKTEmOcFEs8pksm1 SH0MULBLDuRiyCtWDc7LDQMQGCCNvYI1RBku2QKOjVKQlhPuEKDts9HiWrqlLxD2VKQw oOA9Ci7M+qx2vVwFFsqQd4/dFpNkNROpN5Bb09duvCPpUEnSypbc1f0TN3ezaKPcf4qY v6J97fVVO+K91VBhwKMRKHGVMBn9Ggbxq/f8f+vYGA/74UXao/S1+RnSEHvbMZKyM48p notvvQ3tdlNHGJU7ldMOYt+4plhXkSjLN75UH9WQfJHwedHcxWYPxuCXROF5qGQ4mW3c f9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=5t/t1Gkan8NQECrzhXq9F0PzI2OH9PdW25DtQ5On0r4=; b=Lzk4Sq7GzIFf9lNyWMfCLLbFQ1G8PO/3tsD1cflzgV+OSDTmjjEG5muvXq5FO4bI9u mkXNGzQrqG1yNDOXyrmoS+I7GH++GHHSuthUZy7sF7tg7uj+OLdFp6lBxs+909sqN/gN K2rQ2vG7cwCitTzoeL98Lb0BpXaoIaY9Cgccnu9bfNYJF5ow2K3rkNZ8PGRQ//vR2AwR BAkmJpce2l3anylSP+7p/TB+WsI5dnmoyWDdY4WaC2UnGlmfUqFdVCpvROSnDLvl6IjZ 6GURkVeL1mCchPbgwWgC6+XVefjpNaolsjl+e1gLyWUgYrnKRKH5RKEeMrasXrAdFfqv RTJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Dl88XG+o; spf=pass (google.com: domain of gcc-patches-return-460549-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460549-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 38si3694452plc.179.2017.08.18.01.13.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 01:13:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460549-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Dl88XG+o; spf=pass (google.com: domain of gcc-patches-return-460549-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460549-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=l8c71WK+/O9HUUmeWiC8EDm6B73i2xAAiZUZxFrGbVMZJjxFC8bzv H6FcJoKn9rWzXMozy9GEELr44DcyGcovH7szUkRmmGQ+VbaC4GTCOSl6izR+hby+ K09ehGToqj2WE0Ky7l6/QEiaUVlnhXCHXjQJDTzVB6PhASq8LK8STY= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=AdL9C5JUoIjisAVSkPoG87rwarU=; b=Dl88XG+oqaM6G65Nv0l9 PuqWiZNXAPv/YL+MimyuiIuIpDCuCr2XMoDf7Xk7c6Twx/w1VbXEzZDwBNiynPhA 2ra0rfvxTr4vWmJSITNv7pzf6tnzNMd2KDuO8/PYdoVk4nnXp4l7ZLMFOhj052+P 2wlUYoIS2yDvFwKYpqjjuiU= Received: (qmail 115888 invoked by alias); 18 Aug 2017 08:13:31 -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 115864 invoked by uid 89); 18 Aug 2017 08:13:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Aug 2017 08:13:28 +0000 Received: by mail-wr0-f180.google.com with SMTP id 49so54845154wrw.2 for ; Fri, 18 Aug 2017 01:13:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=5t/t1Gkan8NQECrzhXq9F0PzI2OH9PdW25DtQ5On0r4=; b=WEeaIpTc6BK9+4zVinlNiqIW/Y4bqXskTKdJuKBh017BIRg4W0+OaOqoUU9GvlTKdm 3TUO24euojp9iW4jt4o5qwFXALEe3FA1CfceuKtNYon2xQIqYNU35OsoGd73OQc/bKe+ ILu51GivM+cH4fHrrWl1BPOZqZRDiD81h4m7IM1g+PyhCmPAkv0JT1G+eu1EGcMxxz9h zK06MChVCpaBod8ufBcuu3bAFhvAwogFeuc5qCTLHLAPNTI77lkWLx6mTc+ujwyLpKnZ ZmD8biAiyqu2iayS1+bnCI/blj5DpoFtWm83vOS6Xp8SeAZt5edy0IcKtJhIuoE+XDJT UxPQ== X-Gm-Message-State: AHYfb5intSjB32dFKbLLbtaScbWQOG6QQzyVcnYWgTcXqQwkVD8DlD8Y VIUWCYp9S9kM80R0fiUmjQ== X-Received: by 10.28.27.69 with SMTP id b66mr1073289wmb.11.1503044005619; Fri, 18 Aug 2017 01:13:25 -0700 (PDT) Received: from localhost ([2.25.234.123]) by smtp.gmail.com with ESMTPSA id x9sm4191066wrg.81.2017.08.18.01.13.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2017 01:13:24 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Add a partial_integral_type_p helper function Date: Fri, 18 Aug 2017 09:13:24 +0100 Message-ID: <87inhlmgyj.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a partial_integral_type_p function, to go along with the full_integral_type_p added by the previous patch. Of the changes that didn't previously have an INTEGRAL_TYPE_P check: - the convert_to_integer_1 hunks are dominated by a case version of INTEGRAL_TYPE_P. - the merge_ranges hunk is dominated by an ENUMERAL_TYPE case. - vectorizable_reduction has the comment: /* Do not try to vectorize bit-precision reductions. */ and so I think was only concerned with integers. - vectorizable_assignment has the comment: /* We do not handle bit-precision changes. */ and the later: /* But a conversion that does not change the bit-pattern is ok. */ && !((TYPE_PRECISION (TREE_TYPE (scalar_dest)) > TYPE_PRECISION (TREE_TYPE (op))) && TYPE_UNSIGNED (TREE_TYPE (op))) would only make sense if OP is also an integral type. - vectorizable_shift is inherently restricted to integers. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2017-08-17 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (partial_integral_type_p): New function. * convert.c (convert_to_integer_1): Use it. * expr.c (store_fieldexpand_expr_real_2, expand_expr_real_1): Likewise. * fold-const.c (merge_ranges): Likewise. * tree-ssa-math-opts.c (convert_mult_to_fma): Likewise. * tree-tailcall.c (process_assignment): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_assignment, vectorizable_shift): Likewise. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-08-18 08:35:58.031690315 +0100 +++ gcc/tree.h 2017-08-18 08:36:07.208306339 +0100 @@ -5414,4 +5414,13 @@ full_integral_type_p (const_tree t) return INTEGRAL_TYPE_P (t) && scalar_type_is_full_p (t); } +/* Return true if T is an integral type that has fewer bits than + its underlying mode. */ + +inline bool +partial_integral_type_p (const_tree t) +{ + return INTEGRAL_TYPE_P (t) && !scalar_type_is_full_p (t); +} + #endif /* GCC_TREE_H */ Index: gcc/convert.c =================================================================== --- gcc/convert.c 2017-08-10 14:36:09.015436664 +0100 +++ gcc/convert.c 2017-08-18 08:36:07.203306339 +0100 @@ -711,8 +711,7 @@ convert_to_integer_1 (tree type, tree ex the signed-to-unsigned case the high-order bits have to be cleared. */ if (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (TREE_TYPE (expr)) - && (TYPE_PRECISION (TREE_TYPE (expr)) - != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (expr))))) + && partial_integral_type_p (TREE_TYPE (expr))) code = CONVERT_EXPR; else code = NOP_EXPR; @@ -725,7 +724,7 @@ convert_to_integer_1 (tree type, tree ex type corresponding to its mode, then do a nop conversion to TYPE. */ else if (TREE_CODE (type) == ENUMERAL_TYPE - || outprec != GET_MODE_PRECISION (TYPE_MODE (type))) + || partial_integral_type_p (type)) { expr = convert (lang_hooks.types.type_for_mode (TYPE_MODE (type), TYPE_UNSIGNED (type)), expr); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-08-03 10:40:54.807600276 +0100 +++ gcc/expr.c 2017-08-18 08:36:07.204306339 +0100 @@ -6834,8 +6834,7 @@ store_field (rtx target, HOST_WIDE_INT b if (nop_def) { tree type = TREE_TYPE (exp); - if (INTEGRAL_TYPE_P (type) - && TYPE_PRECISION (type) < GET_MODE_BITSIZE (TYPE_MODE (type)) + if (partial_integral_type_p (type) && bitsize == TYPE_PRECISION (type)) { tree op = gimple_assign_rhs1 (nop_def); @@ -8243,8 +8242,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b /* An operation in what may be a bit-field type needs the result to be reduced to the precision of the bit-field type, which is narrower than that of the type's mode. */ - reduce_bit_field = (INTEGRAL_TYPE_P (type) - && GET_MODE_PRECISION (mode) > TYPE_PRECISION (type)); + reduce_bit_field = partial_integral_type_p (type); if (reduce_bit_field && modifier == EXPAND_STACK_PARM) target = 0; @@ -9669,9 +9667,7 @@ expand_expr_real_1 (tree exp, rtx target /* An operation in what may be a bit-field type needs the result to be reduced to the precision of the bit-field type, which is narrower than that of the type's mode. */ - reduce_bit_field = (!ignore - && INTEGRAL_TYPE_P (type) - && GET_MODE_PRECISION (mode) > TYPE_PRECISION (type)); + reduce_bit_field = (!ignore && partial_integral_type_p (type)); /* If we are going to ignore this result, we need only do something if there is a side-effect somewhere in the expression. If there Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-08-18 08:35:58.028990315 +0100 +++ gcc/fold-const.c 2017-08-18 08:36:07.206306339 +0100 @@ -5063,8 +5063,7 @@ merge_ranges (int *pin_p, tree *plow, tr switch (TREE_CODE (TREE_TYPE (low0))) { case ENUMERAL_TYPE: - if (TYPE_PRECISION (TREE_TYPE (low0)) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (low0)))) + if (partial_integral_type_p (TREE_TYPE (low0))) break; /* FALLTHROUGH */ case INTEGER_TYPE: @@ -5086,8 +5085,7 @@ merge_ranges (int *pin_p, tree *plow, tr switch (TREE_CODE (TREE_TYPE (high1))) { case ENUMERAL_TYPE: - if (TYPE_PRECISION (TREE_TYPE (high1)) - != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (high1)))) + if (partial_integral_type_p (TREE_TYPE (high1))) break; /* FALLTHROUGH */ case INTEGER_TYPE: Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-08-10 14:36:07.848478816 +0100 +++ gcc/tree-ssa-math-opts.c 2017-08-18 08:36:07.206306339 +0100 @@ -3563,9 +3563,7 @@ convert_mult_to_fma (gimple *mul_stmt, t return false; /* We don't want to do bitfield reduction ops. */ - if (INTEGRAL_TYPE_P (type) - && (TYPE_PRECISION (type) - != GET_MODE_PRECISION (TYPE_MODE (type)))) + if (partial_integral_type_p (type)) return false; /* If the target doesn't support it, don't generate it. We assume that Index: gcc/tree-tailcall.c =================================================================== --- gcc/tree-tailcall.c 2017-06-30 12:50:37.493697233 +0100 +++ gcc/tree-tailcall.c 2017-08-18 08:36:07.206306339 +0100 @@ -288,9 +288,7 @@ process_assignment (gassign *stmt, /* Even if the type modes are the same, if the precision of the type is smaller than mode's precision, reduce_to_bit_field_precision would generate additional code. */ - if (INTEGRAL_TYPE_P (TREE_TYPE (dest)) - && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (dest))) - > TYPE_PRECISION (TREE_TYPE (dest)))) + if (partial_integral_type_p (TREE_TYPE (dest))) return FAIL; } Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-08-16 08:50:54.198550019 +0100 +++ gcc/tree-vect-loop.c 2017-08-18 08:36:07.207306339 +0100 @@ -5848,8 +5848,7 @@ vectorizable_reduction (gimple *stmt, gi return false; /* Do not try to vectorize bit-precision reductions. */ - if ((TYPE_PRECISION (scalar_type) - != GET_MODE_PRECISION (TYPE_MODE (scalar_type)))) + if (partial_integral_type_p (scalar_type)) return false; /* All uses but the last are expected to be defined in the loop. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-08-17 09:05:42.987968487 +0100 +++ gcc/tree-vect-stmts.c 2017-08-18 08:36:07.208306339 +0100 @@ -4097,12 +4097,8 @@ vectorizable_conversion (gimple *stmt, g return false; if (!VECTOR_BOOLEAN_TYPE_P (vectype_out) - && ((INTEGRAL_TYPE_P (lhs_type) - && (TYPE_PRECISION (lhs_type) - != GET_MODE_PRECISION (TYPE_MODE (lhs_type)))) - || (INTEGRAL_TYPE_P (rhs_type) - && (TYPE_PRECISION (rhs_type) - != GET_MODE_PRECISION (TYPE_MODE (rhs_type)))))) + && (partial_integral_type_p (lhs_type) + || partial_integral_type_p (rhs_type))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -4696,10 +4692,8 @@ vectorizable_assignment (gimple *stmt, g if ((CONVERT_EXPR_CODE_P (code) || code == VIEW_CONVERT_EXPR) && INTEGRAL_TYPE_P (TREE_TYPE (scalar_dest)) - && ((TYPE_PRECISION (TREE_TYPE (scalar_dest)) - != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (scalar_dest)))) - || ((TYPE_PRECISION (TREE_TYPE (op)) - != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (op)))))) + && (partial_integral_type_p (TREE_TYPE (scalar_dest)) + || partial_integral_type_p (TREE_TYPE (op))) /* But a conversion that does not change the bit-pattern is ok. */ && !((TYPE_PRECISION (TREE_TYPE (scalar_dest)) > TYPE_PRECISION (TREE_TYPE (op))) @@ -4875,8 +4869,7 @@ vectorizable_shift (gimple *stmt, gimple scalar_dest = gimple_assign_lhs (stmt); vectype_out = STMT_VINFO_VECTYPE (stmt_info); - if (TYPE_PRECISION (TREE_TYPE (scalar_dest)) - != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (scalar_dest)))) + if (partial_integral_type_p (TREE_TYPE (scalar_dest))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,