From patchwork Wed Nov 14 13:07:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997730 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490054-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T2F+gjRt"; dkim-atps=neutral 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 42w4Zw5FQlz9sB5 for ; Thu, 15 Nov 2018 00:09:28 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=TOCPAL9OQTEe5zDH+u07/pbnwTDIeaZDhX1wacDEwatKPgkvTT7iw mtskqP7KzveUi6fBLCtUn8mphWtR720aVv+4K2e7EPhGFtdH86q3pzOhXJ7AQWrb sZc3c7WejnIeMvC1rpfJxPFHg2juHDgCHVwGbxCxmyrN07vTva2TIA= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=6uEPTlWjvEAZn5iV3vvpFUxxk+I=; b=T2F+gjRt5edIliRxQlRy sWThTBrCoGuZ9lTyh9IIpaZpxojWtVChOenGBID3K/YR4lIIJB1fkfnqwEq7NugN NWpVkY0uLWnz1lzUzJvDNHTFWbBRgZYIuxQiUo5Jzk5yUF8Wfz4sANk2cwR2U8YP Z4biYA7LdiDij4WeYxpM0eY= Received: (qmail 86538 invoked by alias); 14 Nov 2018 13:08:18 -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 86332 invoked by uid 89); 14 Nov 2018 13:08:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:15 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4TTY126162 for ; Wed, 14 Nov 2018 08:08:13 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nrhe5h4cb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:00 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:07:58 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:07:55 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED7sXC61603862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:07:54 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D9BF4C04E; Wed, 14 Nov 2018 13:07:54 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0608A4C046; Wed, 14 Nov 2018 13:07:54 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:07:53 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 1/6] ifcvt: Store the number of created cmovs. Date: Wed, 14 Nov 2018 14:07:47 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0008-0000-0000-00000292B22E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0009-0000-0000-000021FCC75E Message-Id: <20181114130752.5057-2-rdapp@linux.ibm.com> This patch saves the number of created conditional moves by noce_convert_multiple_sets in the IF_INFO struct. This may be used by the backend to easier decide whether to accept a generated sequence or not. --- gcc/ChangeLog: 2018-11-14 Robin Dapp * ifcvt.c (noce_convert_multiple_sets): Set cmov count. (noce_find_if_block): Set cmov count. * ifcvt.h (struct noce_if_info): Add cmov count. --- gcc/ifcvt.c | 10 ++++++++-- gcc/ifcvt.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 8b3907618e7..ddf077fa051 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3247,9 +3247,14 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) /* Actually emit the sequence if it isn't too expensive. */ rtx_insn *seq = get_insns (); + if_info->transform_name = "noce_convert_multiple_sets"; + if_info->created_cmovs = count; + if (!targetm.noce_conversion_profitable_p (seq, if_info)) { end_sequence (); + if_info->transform_name = ""; + if_info->created_cmovs = 0; return FALSE; } @@ -3296,7 +3301,7 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) } num_updated_if_blocks++; - if_info->transform_name = "noce_convert_multiple_sets"; + return TRUE; } @@ -4060,7 +4065,8 @@ noce_find_if_block (basic_block test_bb, edge then_edge, edge else_edge, and jump_insns are always given a cost of 1 by seq_cost, so treat both instructions as having cost COSTS_N_INSNS (1). */ if_info.original_cost = COSTS_N_INSNS (2); - + if_info.transform_name = ""; + if_info.created_cmovs = 0; /* Do the real work. */ diff --git a/gcc/ifcvt.h b/gcc/ifcvt.h index a18ba94b8df..50f40bbd1e5 100644 --- a/gcc/ifcvt.h +++ b/gcc/ifcvt.h @@ -108,6 +108,10 @@ struct noce_if_info /* The name of the noce transform that succeeded in if-converting this structure. Used for debugging. */ const char *transform_name; + + /* The number of created conditional moves in case we convert multiple + sets. */ + unsigned int created_cmovs; }; #endif /* GCC_IFCVT_H */ From patchwork Wed Nov 14 13:07:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490049-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NcWuV9rj"; dkim-atps=neutral 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 42w4Yh15ftz9s8J for ; Thu, 15 Nov 2018 00:08:23 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=PN2CcS5feVl0Bx3cIANhhlWWmhTo5zpAY8njZ7BWEFM6o/6ZNSnoA WfBVpe2XwKNJ22Dkh5tB2NdkmQHyP1hZ+xtXT/lPtcS35EEwUp+WovCtfmwKVAjN Ux9hojzGBmvdw2P40mwwDzCspW4rO4YeplYPh11aE6TvCLTv1kvAYU= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=e4DskSaBqt8miqfqtpMKzlX66fk=; b=NcWuV9rjWhRC4ZwE41vM pC5jUbXzahIGu29hRXYOqt6WjsD0HzuHXqo4+8P9Onis50HjC41jgDFJ/4yL1qy0 zbmB9v1oa4/6DZ/bimeH+yNPtlIs8Pnpjt2jlrmU3sVe5n5C7oa9lnIs3pso9hBS g1OqLeiELm0uy0lm25qM5SQ= Received: (qmail 83657 invoked by alias); 14 Nov 2018 13:08:06 -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 83413 invoked by uid 89); 14 Nov 2018 13:08:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=temp, rdapp@linux.ibm.com, sk:rdappl, U*rdapp X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:03 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4JAa084300 for ; Wed, 14 Nov 2018 08:08:02 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nrjh0dmtq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:01 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:07:59 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:07:57 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED7tBL60424418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:07:55 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F0964C040; Wed, 14 Nov 2018 13:07:55 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 388B74C04E; Wed, 14 Nov 2018 13:07:55 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:07:55 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 2/6] ifcvt: Allow constants operands in noce_convert_multiple_sets. Date: Wed, 14 Nov 2018 14:07:48 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0008-0000-0000-00000292B230 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0009-0000-0000-000021FCC75F Message-Id: <20181114130752.5057-3-rdapp@linux.ibm.com> This patch checks whether the current target supports conditional moves with immediate then/else operands and allows noce_convert_multiple_sets to deal with constants subsequently. Also, minor refactoring is performed. --- gcc/ChangeLog: 2018-11-14 Robin Dapp * ifcvt.c (have_const_cmov): New function. (noce_convert_multiple_sets): Allow constants if supported. (bb_ok_for_noce_convert_multiple_sets): Likewise. (check_cond_move_block): Refactor. --- gcc/ifcvt.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index ddf077fa051..660bb46eb1c 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3077,6 +3077,27 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx cond, return false; } +/* Check if we have a movcc pattern that accepts constants as then/else + operand (op 2/3). */ +static bool +have_const_cmov (machine_mode mode) +{ + enum insn_code icode; + if ((icode = direct_optab_handler (movcc_optab, mode)) + != CODE_FOR_nothing) + { + if (insn_data[(int) icode].operand[2].predicate + && (insn_data[(int) icode].operand[2].predicate + (const1_rtx, insn_data[(int) icode].operand[2].mode))) + if (insn_data[(int) icode].operand[3].predicate + && (insn_data[(int) icode].operand[3].predicate + (const1_rtx, insn_data[(int) icode].operand[3].mode))) + return true; + } + + return false; +} + /* We have something like: if (x > y) @@ -3194,7 +3215,12 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) we'll end up trying to emit r4:HI = cond ? (r1:SI) : (r3:HI). Wrap the two cmove operands into subregs if appropriate to prevent that. */ - if (GET_MODE (new_val) != GET_MODE (temp)) + + /* Check if we can emit a cmove with constant operands. */ + bool allow_constants = have_const_cmov (GET_MODE (target)); + + if (!(allow_constants && CONST_INT_P (new_val)) + && GET_MODE (new_val) != GET_MODE (temp)) { machine_mode src_mode = GET_MODE (new_val); machine_mode dst_mode = GET_MODE (temp); @@ -3205,7 +3231,8 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) } new_val = lowpart_subreg (dst_mode, new_val, src_mode); } - if (GET_MODE (old_val) != GET_MODE (temp)) + if (!(allow_constants && CONST_INT_P (old_val)) + && GET_MODE (old_val) != GET_MODE (temp)) { machine_mode src_mode = GET_MODE (old_val); machine_mode dst_mode = GET_MODE (temp); @@ -3339,9 +3366,10 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb) if (!REG_P (dest)) return false; - if (!(REG_P (src) - || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src)) - && subreg_lowpart_p (src)))) + if (!((REG_P (src) + || (have_const_cmov (GET_MODE (dest)) && CONST_INT_P (src))) + || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src)) + && subreg_lowpart_p (src)))) return false; /* Destination must be appropriate for a conditional write. */ @@ -3689,7 +3717,7 @@ check_cond_move_block (basic_block bb, { rtx set, dest, src; - if (!NONDEBUG_INSN_P (insn) || JUMP_P (insn)) + if (!active_insn_p (insn)) continue; set = single_set (insn); if (!set) @@ -3705,10 +3733,8 @@ check_cond_move_block (basic_block bb, if (!CONSTANT_P (src) && !register_operand (src, VOIDmode)) return FALSE; - if (side_effects_p (src) || side_effects_p (dest)) - return FALSE; - - if (may_trap_p (src) || may_trap_p (dest)) + /* Check for side effects and trapping. */ + if (!noce_operand_ok (src) || !noce_operand_ok (dest)) return FALSE; /* Don't try to handle this if the source register was From patchwork Wed Nov 14 13:07:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490051-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="flSFYHrv"; dkim-atps=neutral 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 42w4Z95PCSz9s8J for ; Thu, 15 Nov 2018 00:08:49 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=mfV46GA9hom0GSIXYaahF0kDb7U4A8RYm14ixyL9ZkbyzaurhFsEx Ob3ZTnMjSFTnMztm/ARMoSfhZ5w9GzjImsfukOzg0xSImlHSPf28geRjfgpvD2AA 47rTc6r/KcjDbjJh6fXfydhnbLW83+jSDYgpI8GzWPpRPrHHiHEpg8= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=8PchZmHrING1TxBL/bpG6UTHXI0=; b=flSFYHrvIDbqhx1mhpZG GWjNodxbLy3jzkFLrwtoY+QDclwgFFilP3j+ndPIGTm9XdFmpPta/bYSw5s0MaZM XJqEFl94nKMRaR+83MVXjnVX/G/M2Pk73nnWq4eKlUQ2bnwaf8HUKj79Hiu0YL3o sDmoZtsTydezhDQsw94QlTA= Received: (qmail 84397 invoked by alias); 14 Nov 2018 13:08:09 -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 84189 invoked by uid 89); 14 Nov 2018 13:08:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=queried X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:05 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4Juf109749 for ; Wed, 14 Nov 2018 08:08:03 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nrjvvcms0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:02 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:08:00 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:07:58 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED7uSC60424434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:07:56 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97A0E4C04A; Wed, 14 Nov 2018 13:07:56 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 69C434C044; Wed, 14 Nov 2018 13:07:56 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:07:56 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 3/6] ifcvt: Use enum instead of transform_name string. Date: Wed, 14 Nov 2018 14:07:49 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0016-0000-0000-00000226DBCD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0017-0000-0000-0000327EF811 Message-Id: <20181114130752.5057-4-rdapp@linux.ibm.com> This patch introduces an enum for ifcvt's various noce transformations. As the transformation might be queried by the backend, I find it nicer to allow checking for a proper type instead of a string comparison. --- gcc/ChangeLog: 2018-11-14 Robin Dapp * ifcvt.c (noce_try_move): Use new function. (noce_try_ifelse_collapse): Likewise. (noce_try_store_flag): Likewise. (noce_try_inverse_constants): Likewise. (noce_try_store_flag_constants): Likewise. (noce_try_addcc): Likewise. (noce_try_store_flag_mask): Likewise. (noce_try_cmove): Likewise. (noce_try_cmove_arith): Likewise. (noce_try_minmax): Likewise. (noce_try_abs): Likewise. (noce_try_sign_mask): Likewise. (noce_try_bitop): Likewise. (noce_convert_multiple_sets): Likewise. (noce_process_if_block): Likewise. (noce_find_if_block): Likewise. * ifcvt.h (enum ifcvt_transform): Introduce enum. (ifcvt_get_transform_name): New function. (struct noce_if_info): Use enum instead of string. --- gcc/ifcvt.c | 46 ++++++++++++++++++------------------ gcc/ifcvt.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 25 deletions(-) diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 660bb46eb1c..94822c583fe 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -1105,7 +1105,7 @@ noce_try_move (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); } - if_info->transform_name = "noce_try_move"; + if_info->transform = ifcvt_transform_noce_try_move; return TRUE; } return FALSE; @@ -1139,7 +1139,7 @@ noce_try_ifelse_collapse (struct noce_if_info * if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_ifelse_collapse"; + if_info->transform = ifcvt_transform_noce_try_ifelse_collapse; return TRUE; } @@ -1186,7 +1186,7 @@ noce_try_store_flag (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_store_flag"; + if_info->transform = ifcvt_transform_noce_try_store_flag; return TRUE; } else @@ -1265,7 +1265,7 @@ noce_try_inverse_constants (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_inverse_constants"; + if_info->transform = ifcvt_transform_noce_try_inverse_constants; return true; } @@ -1485,7 +1485,7 @@ noce_try_store_flag_constants (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_store_flag_constants"; + if_info->transform = ifcvt_transform_noce_try_store_flag_constants; return TRUE; } @@ -1546,7 +1546,7 @@ noce_try_addcc (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_addcc"; + if_info->transform = ifcvt_transform_noce_try_addcc; return TRUE; } @@ -1588,7 +1588,7 @@ noce_try_addcc (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_addcc"; + if_info->transform = ifcvt_transform_noce_try_addcc; return TRUE; } end_sequence (); @@ -1639,7 +1639,7 @@ noce_try_store_flag_mask (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_store_flag_mask"; + if_info->transform = ifcvt_transform_noce_try_store_flag_mask; return TRUE; } @@ -1791,7 +1791,7 @@ noce_try_cmove (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_cmove"; + if_info->transform = ifcvt_transform_noce_try_cmove; return TRUE; } @@ -1844,7 +1844,7 @@ noce_try_cmove (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_cmove"; + if_info->transform = ifcvt_transform_noce_try_cmove; return TRUE; } else @@ -2286,7 +2286,7 @@ noce_try_cmove_arith (struct noce_if_info *if_info) emit_insn_before_setloc (ifcvt_seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_cmove_arith"; + if_info->transform = ifcvt_transform_noce_try_cmove_arith; return TRUE; end_seq_and_fail: @@ -2544,7 +2544,7 @@ noce_try_minmax (struct noce_if_info *if_info) if_info->cond = cond; if_info->cond_earliest = earliest; if_info->rev_cond = NULL_RTX; - if_info->transform_name = "noce_try_minmax"; + if_info->transform = ifcvt_transform_noce_try_minmax; return TRUE; } @@ -2712,7 +2712,7 @@ noce_try_abs (struct noce_if_info *if_info) if_info->cond = cond; if_info->cond_earliest = earliest; if_info->rev_cond = NULL_RTX; - if_info->transform_name = "noce_try_abs"; + if_info->transform = ifcvt_transform_noce_try_abs; return TRUE; } @@ -2794,7 +2794,7 @@ noce_try_sign_mask (struct noce_if_info *if_info) return FALSE; emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); - if_info->transform_name = "noce_try_sign_mask"; + if_info->transform = ifcvt_transform_noce_try_sign_mask; return TRUE; } @@ -2904,7 +2904,7 @@ noce_try_bitop (struct noce_if_info *if_info) emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); } - if_info->transform_name = "noce_try_bitop"; + if_info->transform = ifcvt_transform_noce_try_bitop; return TRUE; } @@ -3271,16 +3271,17 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) for (int i = 0; i < count; i++) noce_emit_move_insn (targets[i], temporaries[i]); + /* Actually emit the sequence if it isn't too expensive. */ rtx_insn *seq = get_insns (); - if_info->transform_name = "noce_convert_multiple_sets"; + if_info->transform = ifcvt_transform_noce_convert_multiple_sets; if_info->created_cmovs = count; if (!targetm.noce_conversion_profitable_p (seq, if_info)) { end_sequence (); - if_info->transform_name = ""; + if_info->transform = ifcvt_transform_none; if_info->created_cmovs = 0; return FALSE; } @@ -3428,15 +3429,16 @@ noce_process_if_block (struct noce_if_info *if_info) { if (noce_convert_multiple_sets (if_info)) { - if (dump_file && if_info->transform_name) + if (dump_file && if_info->transform) fprintf (dump_file, "if-conversion succeeded through %s\n", - if_info->transform_name); + ifcvt_get_transform_name (if_info->transform)); return TRUE; } } bool speed_p = optimize_bb_for_speed_p (test_bb); unsigned int then_cost = 0, else_cost = 0; + if (!bb_valid_for_noce_process_p (then_bb, cond, &then_cost, &if_info->then_simple)) return false; @@ -3647,9 +3649,9 @@ noce_process_if_block (struct noce_if_info *if_info) return FALSE; success: - if (dump_file && if_info->transform_name) + if (dump_file && if_info->transform) fprintf (dump_file, "if-conversion succeeded through %s\n", - if_info->transform_name); + ifcvt_get_transform_name (if_info->transform)); /* If we used a temporary, fix it up now. */ if (orig_x != x) @@ -4091,7 +4093,7 @@ noce_find_if_block (basic_block test_bb, edge then_edge, edge else_edge, and jump_insns are always given a cost of 1 by seq_cost, so treat both instructions as having cost COSTS_N_INSNS (1). */ if_info.original_cost = COSTS_N_INSNS (2); - if_info.transform_name = ""; + if_info.transform = ifcvt_transform_none; if_info.created_cmovs = 0; /* Do the real work. */ diff --git a/gcc/ifcvt.h b/gcc/ifcvt.h index 50f40bbd1e5..8b4116668a1 100644 --- a/gcc/ifcvt.h +++ b/gcc/ifcvt.h @@ -40,6 +40,66 @@ struct ce_if_block int pass; /* Pass number. */ }; +enum ifcvt_transform +{ + ifcvt_transform_none = 0, + ifcvt_transform_noce_try_move, + ifcvt_transform_noce_try_ifelse_collapse, + ifcvt_transform_noce_try_store_flag, + ifcvt_transform_noce_try_inverse_constants, + ifcvt_transform_noce_try_store_flag_constants, + ifcvt_transform_noce_try_addcc, + ifcvt_transform_noce_try_store_flag_mask, + ifcvt_transform_noce_try_cmove, + ifcvt_transform_noce_try_cmove_arith, + ifcvt_transform_noce_try_minmax, + ifcvt_transform_noce_try_abs, + ifcvt_transform_noce_try_sign_mask, + ifcvt_transform_noce_try_bitop, + ifcvt_transform_noce_convert_multiple_sets +}; + +inline const char * +ifcvt_get_transform_name (enum ifcvt_transform transform) +{ + switch (transform) + { + case ifcvt_transform_none: + return ""; + case ifcvt_transform_noce_try_move: + return "noce_try_move"; + case ifcvt_transform_noce_try_ifelse_collapse: + return "noce_try_ifelse_collapse"; + case ifcvt_transform_noce_try_store_flag: + return "noce_try_store_flag"; + case ifcvt_transform_noce_try_inverse_constants: + return "noce_try_inverse_constants"; + case ifcvt_transform_noce_try_store_flag_constants: + return "noce_try_store_flag_constants"; + case ifcvt_transform_noce_try_addcc: + return "noce_try_addcc"; + case ifcvt_transform_noce_try_store_flag_mask: + return "noce_try_store_flag_mask"; + case ifcvt_transform_noce_try_cmove: + return "noce_try_cmove"; + case ifcvt_transform_noce_try_cmove_arith: + return "noce_try_cmove_arith"; + case ifcvt_transform_noce_try_minmax: + return "noce_try_minmax"; + case ifcvt_transform_noce_try_abs: + return "noce_try_abs"; + case ifcvt_transform_noce_try_sign_mask: + return "noce_try_sign_mask"; + case ifcvt_transform_noce_try_bitop: + return "noce_try_bitop"; + case ifcvt_transform_noce_convert_multiple_sets: + return "noce_convert_multiple_sets"; + default: + return "unknown transform"; + } +} + + /* Used by noce_process_if_block to communicate with its subroutines. The subroutines know that A and B may be evaluated freely. They @@ -105,9 +165,10 @@ struct noce_if_info generate to replace this branch. */ unsigned int max_seq_cost; - /* The name of the noce transform that succeeded in if-converting - this structure. Used for debugging. */ - const char *transform_name; + /* The noce transform that succeeded in if-converting this structure. + Used for letting the backend determine which transform succeeded + and for debugging output. */ + enum ifcvt_transform transform; /* The number of created conditional moves in case we convert multiple sets. */ From patchwork Wed Nov 14 13:07:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490055-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dsptRhUT"; dkim-atps=neutral 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 42w4b92h1Wz9sB5 for ; Thu, 15 Nov 2018 00:09:41 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=Dv3gkMgHWB+QT4evR1GafJFL5SS2oJEQCv2X7TCJ5AHzGlSOR4Scg srqaJhvttQSS++T7dgQSXfSQGVTCEy5XWUwtWhW+XD59mWjE996pkaAdvqBo9sUF 8+laMUmQr0PCCe4AasljlKRDl2NKbho5nA9iSi9Dx/nuBVzQR5Q5K0= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=VRRHMueMx98WfPGvtLHyLB+VSow=; b=dsptRhUTEYZO7j1Qj4uc BeCifUl3MZd9naa9MwMqMUjZsDPPOexEo05226z2llXhfcIheJtpTP2iHJdFdwFh 2slCwpm3Hn7NfiGA26F7H4XKwDgSuFPtCOKG1nF7AlxwtPITiEQC53LSgHblTMpH 3c58Eb1frOYMHS9qBczmAQo= Received: (qmail 87178 invoked by alias); 14 Nov 2018 13:08:21 -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 86942 invoked by uid 89); 14 Nov 2018 13:08:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=ipa-prop.h, ipaproph, UD:ipa-prop.h X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:18 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4VbE120224 for ; Wed, 14 Nov 2018 08:08:16 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nrks3sske-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:01 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:08:00 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:07:59 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED7vtH7274756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:07:57 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C929F4C04A; Wed, 14 Nov 2018 13:07:57 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1C8D4C040; Wed, 14 Nov 2018 13:07:57 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:07:57 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 4/6] S/390: Implement noce_conversion_profitable_p. Date: Wed, 14 Nov 2018 14:07:50 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0020-0000-0000-000002E7E936 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0021-0000-0000-00002136FD99 Message-Id: <20181114130752.5057-5-rdapp@linux.ibm.com> This patch implements noce_conversion_profitable_p by checking for the transformation ifcvt used and only return positively if noce_convert_multiple_sets created less than MAX_IFCVT_INSNS insns. --- gcc/ChangeLog: 2018-11-14 Robin Dapp * config/s390/s390.c (MAX_IFCVT_INSNS): Define. (s390_noce_conversion_profitable_p): Implement. (TARGET_NOCE_CONVERSION_PROFITABLE_P): Define. --- gcc/config/s390/s390.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 0f33101d779..1018d9b8057 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -86,6 +86,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-prop.h" #include "ipa-fnsummary.h" #include "sched-int.h" +#include "ifcvt.h" /* This file should be included last. */ #include "target-def.h" @@ -393,6 +394,8 @@ struct s390_address bool literal_pool; }; +#define MAX_IFCVT_INSNS 2 + /* Few accessor macros for struct cfun->machine->s390_frame_layout. */ #define cfun_frame_layout (cfun->machine->frame_layout) @@ -15989,6 +15992,17 @@ s390_case_values_threshold (void) return default_case_values_threshold (); } +static bool +s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info) +{ + if (if_info->transform + && if_info->transform == ifcvt_transform_noce_convert_multiple_sets + && if_info->created_cmovs <= MAX_IFCVT_INSNS) + return true; + + return default_noce_conversion_profitable_p (seq, if_info); +} + /* Initialize GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP @@ -16240,6 +16254,9 @@ s390_case_values_threshold (void) #undef TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT s390_support_vector_misalignment +#undef TARGET_NOCE_CONVERSION_PROFITABLE_P +#define TARGET_NOCE_CONVERSION_PROFITABLE_P s390_noce_conversion_profitable_p + #undef TARGET_VECTOR_ALIGNMENT #define TARGET_VECTOR_ALIGNMENT s390_vector_alignment From patchwork Wed Nov 14 13:07:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490052-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="xt8Ll+Ea"; dkim-atps=neutral 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 42w4ZQ674hz9s8J for ; Thu, 15 Nov 2018 00:09:02 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=S7i6wQWvzqsQD34g7ZZEiAz7+hjaey+yS7iJg8kmfkjQi12VnAVeY mH6L5sgyiNqvHnff1NvznTJ1n7qM5+JerxdfP/DtooYXLq1VTfcv13i+ZJnFka3T 3PCqoqg97l721Gw1DQ1sNBIqx2Ozf6ZoAwYN3RTGMUXIjqkDXKBnts= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=zomBM/ORNrbJEPkUpzJ4ar8P0as=; b=xt8Ll+EaJxju8dNYSnjl gLjBuSzjIPlxPEjSk6J9Uujy5P2uawDAD/lRr1sjayTsmRpDT5IX6LzjT/KxwkOf /fI4t5B1afqbyMR7g+cyFlqfTQbwbrM4GqMx8K0pSfxDUkAcuH8A8brDDiUeAPGT pVjW+eTUUAUOnQz8DYCpF2g= Received: (qmail 84455 invoked by alias); 14 Nov 2018 13:08:09 -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 84156 invoked by uid 89); 14 Nov 2018 13:08:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:06 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4XPr042670 for ; Wed, 14 Nov 2018 08:08:05 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nrgw42rdt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:04 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:08:03 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:08:00 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED7xTm4522304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:07:59 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 063364C040; Wed, 14 Nov 2018 13:07:59 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3B034C046; Wed, 14 Nov 2018 13:07:58 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:07:58 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 5/6] ifcvt: Only created temporaries as needed. Date: Wed, 14 Nov 2018 14:07:51 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0016-0000-0000-00000226DBD0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0017-0000-0000-0000327EF814 Message-Id: <20181114130752.5057-6-rdapp@linux.ibm.com> noce_convert_multiple_sets creates temporaries for the destination of every emitted cmov and expects subsequent passes to get rid of them. This does not happen every time and even if the temporaries are removed, code generation can be affected adversely. In this patch, temporaries are only created if the destination of a set is used in an emitted condition check. --- gcc/ChangeLog: 2018-11-14 Robin Dapp * ifcvt.c (check_need_temps): New function. (noce_convert_multiple_sets): Only created temporaries if needed. --- gcc/ifcvt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 94822c583fe..6d1803ed40d 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -99,6 +99,10 @@ static int dead_or_predicable (basic_block, basic_block, basic_block, edge, int); static void noce_emit_move_insn (rtx, rtx); static rtx_insn *block_has_only_trap (basic_block); +static void check_need_temps (basic_block bb, + hash_map *need_temp, + rtx cond); + /* Count the number of non-jump active insns in BB. */ @@ -3166,6 +3170,12 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) auto_vec unmodified_insns; int count = 0; + hash_map need_temps; + + check_need_temps (then_bb, &need_temps, cond); + + hash_map temps_created; + FOR_BB_INSNS (then_bb, insn) { /* Skip over non-insns. */ @@ -3176,10 +3186,20 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) gcc_checking_assert (set); rtx target = SET_DEST (set); - rtx temp = gen_reg_rtx (GET_MODE (target)); rtx new_val = SET_SRC (set); rtx old_val = target; + rtx dest = SET_DEST (set); + + rtx temp; + if (need_temps.get (dest)) + { + temp = gen_reg_rtx (GET_MODE (target)); + temps_created.put (target, true); + } + else + temp = target; + /* If we were supposed to read from an earlier write in this block, we've changed the register allocation. Rewire the read. While we are looking, also try to catch a swap idiom. */ @@ -3269,8 +3289,8 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) /* Now fixup the assignments. */ for (int i = 0; i < count; i++) - noce_emit_move_insn (targets[i], temporaries[i]); - + if (temps_created.get(targets[i]) && targets[i] != temporaries[i]) + noce_emit_move_insn (targets[i], temporaries[i]); /* Actually emit the sequence if it isn't too expensive. */ rtx_insn *seq = get_insns (); @@ -3775,6 +3795,34 @@ check_cond_move_block (basic_block bb, return TRUE; } +/* Check for which sets we need to emit temporaries to hold the destination of + a conditional move. */ +static void +check_need_temps (basic_block bb, hash_map *need_temp, rtx cond) +{ + rtx_insn *insn; + + FOR_BB_INSNS (bb, insn) + { + rtx set, dest; + + if (!active_insn_p (insn)) + continue; + + set = single_set (insn); + if (set == NULL_RTX) + continue; + + dest = SET_DEST (set); + + /* noce_emit_cmove will emit the condition check every time it is called + so we need a temp register if the destination is modified. */ + if (reg_overlap_mentioned_p (dest, cond)) + need_temp->put (dest, true); + } +} + + /* Given a basic block BB suitable for conditional move conversion, a condition COND, and pointer maps THEN_VALS and ELSE_VALS containing the register values depending on COND, emit the insns in the block as From patchwork Wed Nov 14 13:07:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 997729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-490053-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JUHAUcqB"; dkim-atps=neutral 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 42w4Zg6Zvmz9s8J for ; Thu, 15 Nov 2018 00:09:15 +1100 (AEDT) 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:cc:subject:date:in-reply-to:references:message-id; q=dns; s= default; b=THSWa874UKCgZn1ORNrZ+ZOCJA9YN+fxvLc1z/Se8XY9wVzRCU9FB keaLaVazZ1LGymoqu233a6YK877YaGr3T+GHvY9QoUV6GACqmrIIW1gxUYUWPvvG MpYarFu3/V+y0NYuGgwnMt3UGCd8UQ9EKFXcBHvcSax6qHxv9STOes= 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:cc:subject:date:in-reply-to:references:message-id; s= default; bh=iddw/pfqpPptrMmy4glVx4GS8Ns=; b=JUHAUcqBl9M2rzJCZdnv EM0GlOTLB2XeoNoosNKvGEf1ZIwN5W8SRNEAvfo/zz7fmcT3XLGcO9Gz8EuznUwZ FfkvFN3ucvT086EFeS7vf2D/Z3rgFQkP0QPPaz5mMMpxCrPXcHVqFX1NtSQku8+N 44oRDTkym3osz6EpGmEI2Oc= Received: (qmail 85517 invoked by alias); 14 Nov 2018 13:08:14 -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 85343 invoked by uid 89); 14 Nov 2018 13:08:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Nov 2018 13:08:07 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAED4XZB042634 for ; Wed, 14 Nov 2018 08:08:05 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nrgw42red-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 14 Nov 2018 08:08:05 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Nov 2018 13:08:03 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 14 Nov 2018 13:08:01 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAED80bj2162988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Nov 2018 13:08:00 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40FF54C044; Wed, 14 Nov 2018 13:08:00 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 113C84C040; Wed, 14 Nov 2018 13:08:00 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.152.222.44]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Nov 2018 13:08:00 +0000 (GMT) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.ibm.com, iii@linux.ibm.com Subject: [PATCH 6/6] S/390: Add test for noce_convert_multiple_sets. Date: Wed, 14 Nov 2018 14:07:52 +0100 In-Reply-To: <20181114130752.5057-1-rdapp@linux.ibm.com> References: <20181114130752.5057-1-rdapp@linux.ibm.com> x-cbid: 18111413-0028-0000-0000-00000319CF19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18111413-0029-0000-0000-000023D63A26 Message-Id: <20181114130752.5057-7-rdapp@linux.ibm.com> New test. --- gcc/testsuite/ChangeLog: 2018-11-14 Robin Dapp * gcc.target/s390/ifcvt-two-insns-int.c: New test. --- .../gcc.target/s390/ifcvt-two-insns-int.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.target/s390/ifcvt-two-insns-int.c diff --git a/gcc/testsuite/gcc.target/s390/ifcvt-two-insns-int.c b/gcc/testsuite/gcc.target/s390/ifcvt-two-insns-int.c new file mode 100644 index 00000000000..952c8fd890e --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/ifcvt-two-insns-int.c @@ -0,0 +1,26 @@ +/* Check load on condition for bool. */ + +/* { dg-do compile { target { s390*-*-* } } } */ +/* { dg-options "-O2 -march=z13" } */ + +/* { dg-final { scan-assembler "lochinhe\t%r.?,1" } } */ +/* { dg-final { scan-assembler "locrhe\t.*" } } */ +#include + +int foo (int *a, unsigned int n) +{ + int min = 999999; + int bla = 0; + for (int i = 0; i < n; i++) + { + if (a[i] < min) + { + min = a[i]; + bla = 1; + } + } + + if (bla) + min += 1; + return min; +}