From patchwork Fri Oct 18 19:48:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard Earnshaw \(lists\)" X-Patchwork-Id: 176954 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp1293572ocf; Fri, 18 Oct 2019 12:56:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWsOQYVfc5JRlN1pXWSplQSECCzU//+xGdzJzOzAIFvsc66ayu+uWmSJL5HgyLh5Xo/oiq X-Received: by 2002:a50:f742:: with SMTP id j2mr11493206edn.253.1571428618229; Fri, 18 Oct 2019 12:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571428618; cv=none; d=google.com; s=arc-20160816; b=XXmbY+DymfUinjn8P07vQjNEDqpGco2+T3dIDVYrLLILU0kUUnrZCXVcaUFq9tlWwS kqw0LaIg4XBypLWwi4kSjVIab6jx/NjLlOZbyG4Soi4Ej1xuqX3lWLQ0Jv3YGVywGsno WXqWKAuZU1lE2031oyd9oMH270tbUNzIIAQXW598J0XrnSEQOm87b2xzU44KC7AK8UCd b/UWbZXghDJP5GaBDhCQfg64vLArl8yRWOWRQl8MCkeOWdVq5tnLU1D18DR/kdaHPJqY hMxhUhXHlTofI+HUE/AsAYXtWGLF+YAkGjkx+IlbLIo0xuIcf+eODQlUyx6QJn1KwvGL TDSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=moNGgKFbkM+NkLHpBk8yQ68lhgBqXwXAnY0iayWIOPQ=; b=IvaGDK852aIL1Xt+sbY8K+NfGh0V2OIhUGxm1fC5lq+9vkUYg6p9YOgP6VcHqV/Exe JUC989BfGVcDmynZJt7V2SxRfgqm8ZtMVR+RVmfJsBdZPuDZV8hVylrgLPJr2PAokrHn k8G8Tz5LIkl5SX+f/6axDGGbkoBAZya2xDfe1XJyk5q3MK5Ux5fvhJgKxsydtRb3495n QIYINqpXEfuKbqJQ8a7H3t8FeVYM/APgKGRdH/wTIsFeMxsnqMgIYcDQqA5VUsDq3ZyK 05LR6xmSYcEgc44yV4vuBQn8ucVtBvX+86IkUehFFge8gVjSZSWOQP30ayYlhgDl286n axnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ErbRwjuv; spf=pass (google.com: domain of gcc-patches-return-511320-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-511320-patch=linaro.org@gcc.gnu.org" Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id pv13si4178672ejb.79.2019.10.18.12.56.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2019 12:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-511320-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=ErbRwjuv; spf=pass (google.com: domain of gcc-patches-return-511320-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-511320-patch=linaro.org@gcc.gnu.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:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=X83PW8dawPNXKqyl XBlwv+OeSwOspF/SPXlcg+7jshmRtHSy4xMdzTfq9d3B/cyL/H+hZOL81LmVdwSQ HrsZKZ4V1NR4nlX87DRhf7Q3AILOEe1yzUkaEHZ5ZwLmRzkLPMaNWON5AbiYv/23 AZXuotRTnQhu1RSJw4JmQh2rGn0= 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:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=x86ysXMDqtO1+oPbsbRlZh hRHpc=; b=ErbRwjuvxe9qjEX8vIPmmKxBrpp+Q1pnAeKGSgjDjqxxXw2sQHrP5K 466C4PeD7Xcruc7a3BX67rCXsDVeKQpvs2W/EmTC7p4Zd/hl3IvMR//0nof7ttaU rcmqFlihPz0ogCtJ7muGy/f78jtRkmLLmXmS5zu3agClO0Im3ZOvo= Received: (qmail 113029 invoked by alias); 18 Oct 2019 19:55:41 -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 110801 invoked by uid 89); 18 Oct 2019 19:55:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT autolearn=ham version=3.3.1 spammy=SIGNED X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 19:55:34 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLYLR-00054D-L4 for gcc-patches@gcc.gnu.org; Fri, 18 Oct 2019 15:55:31 -0400 Received: from [217.140.110.172] (port=42740 helo=foss.arm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iLYLR-00053X-Dk for gcc-patches@gcc.gnu.org; Fri, 18 Oct 2019 15:55:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 05A8E15A1; Fri, 18 Oct 2019 12:49:31 -0700 (PDT) Received: from eagle.buzzard.freeserve.co.uk (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8724A3F6C4; Fri, 18 Oct 2019 12:49:30 -0700 (PDT) From: Richard Earnshaw To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw Subject: [PATCH 27/29] [arm] Early expansion of subvdi4 Date: Fri, 18 Oct 2019 20:48:58 +0100 Message-Id: <20191018194900.34795-28-Richard.Earnshaw@arm.com> In-Reply-To: <20191018194900.34795-1-Richard.Earnshaw@arm.com> References: <20191018194900.34795-1-Richard.Earnshaw@arm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.140.110.172 This patch adds early expansion of subvdi4. The expansion sequence is broadly based on the expansion of usubvdi4. * config/arm/arm.md (subvdi4): Decompose calculation into 32-bit operations. (subdi3_compare1): Delete pattern. (subvsi3_borrow): New insn pattern. (subvsi3_borrow_imm): Likewise. --- gcc/config/arm/arm.md | 131 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 114 insertions(+), 17 deletions(-) diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 05b735cfccd..5a8175ff8b0 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -1395,12 +1395,79 @@ (define_expand "subvsi4" (define_expand "subvdi4" [(match_operand:DI 0 "s_register_operand") - (match_operand:DI 1 "s_register_operand") - (match_operand:DI 2 "s_register_operand") + (match_operand:DI 1 "reg_or_int_operand") + (match_operand:DI 2 "reg_or_int_operand") (match_operand 3 "")] "TARGET_32BIT" { - emit_insn (gen_subdi3_compare1 (operands[0], operands[1], operands[2])); + rtx lo_result, hi_result; + rtx lo_op1, hi_op1, lo_op2, hi_op2; + lo_result = gen_lowpart (SImode, operands[0]); + hi_result = gen_highpart (SImode, operands[0]); + machine_mode mode = CCmode; + + if (CONST_INT_P (operands[1]) && CONST_INT_P (operands[2])) + { + /* If both operands are constants we can decide the result statically. */ + wi::overflow_type overflow; + wide_int val = wi::sub (rtx_mode_t (operands[1], DImode), + rtx_mode_t (operands[2], DImode), + SIGNED, &overflow); + emit_move_insn (operands[0], GEN_INT (val.to_shwi ())); + if (overflow != wi::OVF_NONE) + emit_jump_insn (gen_jump (operands[3])); + DONE; + } + else if (CONST_INT_P (operands[1])) + { + arm_decompose_di_binop (operands[2], operands[1], &lo_op2, &hi_op2, + &lo_op1, &hi_op1); + if (const_ok_for_arm (INTVAL (lo_op1))) + { + emit_insn (gen_rsb_imm_compare (lo_result, lo_op1, lo_op2, + GEN_INT (~UINTVAL (lo_op1)))); + /* We could potentially use RSC here in Arm state, but not + in Thumb, so it's probably not worth the effort of handling + this. */ + hi_op1 = force_reg (SImode, hi_op1); + mode = CC_RSBmode; + goto highpart; + } + operands[1] = force_reg (DImode, operands[1]); + } + + arm_decompose_di_binop (operands[1], operands[2], &lo_op1, &hi_op1, + &lo_op2, &hi_op2); + if (lo_op2 == const0_rtx) + { + emit_move_insn (lo_result, lo_op1); + if (!arm_add_operand (hi_op2, SImode)) + hi_op2 = force_reg (SImode, hi_op2); + emit_insn (gen_subvsi4 (hi_result, hi_op1, hi_op2, operands[3])); + DONE; + } + + if (CONST_INT_P (lo_op2) && !arm_addimm_operand (lo_op2, SImode)) + lo_op2 = force_reg (SImode, lo_op2); + if (CONST_INT_P (lo_op2)) + emit_insn (gen_cmpsi2_addneg (lo_result, lo_op1, lo_op2, + GEN_INT (-INTVAL (lo_op2)))); + else + emit_insn (gen_subsi3_compare1 (lo_result, lo_op1, lo_op2)); + + highpart: + if (!arm_not_operand (hi_op2, SImode)) + hi_op2 = force_reg (SImode, hi_op2); + rtx ccreg = gen_rtx_REG (mode, CC_REGNUM); + if (CONST_INT_P (hi_op2)) + emit_insn (gen_subvsi3_borrow_imm (hi_result, hi_op1, hi_op2, + gen_rtx_LTU (SImode, ccreg, const0_rtx), + gen_rtx_LTU (DImode, ccreg, + const0_rtx))); + else + emit_insn (gen_subvsi3_borrow (hi_result, hi_op1, hi_op2, + gen_rtx_LTU (SImode, ccreg, const0_rtx), + gen_rtx_LTU (DImode, ccreg, const0_rtx))); arm_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]); DONE; @@ -1523,20 +1590,6 @@ (define_expand "usubvdi4" DONE; }) -(define_insn "subdi3_compare1" - [(set (reg:CC CC_REGNUM) - (compare:CC - (match_operand:DI 1 "s_register_operand" "r") - (match_operand:DI 2 "s_register_operand" "r"))) - (set (match_operand:DI 0 "s_register_operand" "=&r") - (minus:DI (match_dup 1) (match_dup 2)))] - "TARGET_32BIT" - "subs\\t%Q0, %Q1, %Q2;sbcs\\t%R0, %R1, %R2" - [(set_attr "conds" "set") - (set_attr "length" "8") - (set_attr "type" "multiple")] -) - (define_insn "subsi3_compare1" [(set (reg:CC CC_REGNUM) (compare:CC @@ -2016,6 +2069,50 @@ (define_insn "usubvsi3_borrow_imm" (set_attr "type" "alus_imm")] ) +(define_insn "subvsi3_borrow" + [(set (reg:CC_V CC_REGNUM) + (compare:CC_V + (minus:DI + (minus:DI + (sign_extend:DI (match_operand:SI 1 "s_register_operand" "0,r")) + (sign_extend:DI (match_operand:SI 2 "s_register_operand" "l,r"))) + (match_operand:DI 4 "arm_borrow_operation" "")) + (sign_extend:DI + (minus:SI (minus:SI (match_dup 1) (match_dup 2)) + (match_operand:SI 3 "arm_borrow_operation" ""))))) + (set (match_operand:SI 0 "s_register_operand" "=l,r") + (minus:SI (minus:SI (match_dup 1) (match_dup 2)) + (match_dup 3)))] + "TARGET_32BIT" + "sbcs%?\\t%0, %1, %2" + [(set_attr "conds" "set") + (set_attr "arch" "t2,*") + (set_attr "length" "2,4")] +) + +(define_insn "subvsi3_borrow_imm" + [(set (reg:CC_V CC_REGNUM) + (compare:CC_V + (minus:DI + (minus:DI + (sign_extend:DI (match_operand:SI 1 "s_register_operand" "r,r")) + (match_operand 2 "arm_adcimm_operand" "I,K")) + (match_operand:DI 4 "arm_borrow_operation" "")) + (sign_extend:DI + (minus:SI (minus:SI (match_dup 1) (match_dup 2)) + (match_operand:SI 3 "arm_borrow_operation" ""))))) + (set (match_operand:SI 0 "s_register_operand" "=r,r") + (minus:SI (minus:SI (match_dup 1) (match_dup 2)) + (match_dup 3)))] + "TARGET_32BIT + && INTVAL (operands[2]) == ARM_SIGN_EXTEND (INTVAL (operands[2]))" + "@ + sbcs%?\\t%0, %1, %2 + adcs%?\\t%0, %1, #%B2" + [(set_attr "conds" "set") + (set_attr "type" "alus_imm")] +) + (define_expand "subsf3" [(set (match_operand:SF 0 "s_register_operand") (minus:SF (match_operand:SF 1 "s_register_operand")