From patchwork Fri Oct 18 19:48:31 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: 176943 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp1287230ocf; Fri, 18 Oct 2019 12:49:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz25a6yIMfpBnvV+Zs5FTmKqiMNViM43onRAhWQ1HdkL0LBpeeWUcy+pWnBt/66+hevMjhq X-Received: by 2002:a17:906:480a:: with SMTP id w10mr10449508ejq.212.1571428190266; Fri, 18 Oct 2019 12:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571428190; cv=none; d=google.com; s=arc-20160816; b=a1DFNuQnwdG1qyAcfW0C/krLYFdSjbUPEz5s9fobCFICVkV2s2CFvb54VszCktMmOX wyGed80GGQ345lT16xEoPSbPjMh+/Wa0Usfoa/80xQAZ8nNdPyfLtn7IGxJHnRphOooJ zAKtSY4a6wlhN1nIaZT+3q9zPD+ZB4WRAvmkbrDJzyqay89JhIQwGsCCBkichwp0Kiq4 aPvRd5YdHqLTTMrP6/ypngwp4RySJgAAID6JSXdgDHsY2A0aBRH0Shae9hSV6VYnznWE o3l/sKPRNwVnc2AN/cYf+/skZBbBqcOXnShTCQV2k9N47dWibdzimMxQPHSp9VHsAGLv qKbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version: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=BNfL6Q74xHjSnFhypSd/ufHsIZgB+kCwJGrIlb0ECAM=; b=kBX6tFOf6dzyJXWsNYgBhyvlwPp0Da5SrQh+vfYXJzhnCLwgZTR9Vcu73wtcHMyPW8 dFrY//yPxPgfAg77JBeKGJANxL4ZNXw/XMkRia8x0sY9MTeTrAhhWJiYvDHxzg4ygykh MphH5nWKrXgAOJmd2XZVs2WR5fNI2I9I68eraTKQkhCSvPXiH4NatOpMYA7BhcCcFYWk eOzj4a41XnNcmFKUOQTveSEUB0+kmoMysviha6iCs/1PwtCPlLd6WCxRyGeLFcmJM88N 36ATtdnDHsB65K1MzRDZzAokLOLjifD2Jk6+yEXGerJMU+x7pu7EXU7vX+a6oWVpMzP8 TS2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=riik67I5; spf=pass (google.com: domain of gcc-patches-return-511309-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-511309-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 s20si4092036eja.63.2019.10.18.12.49.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2019 12:49:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-511309-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=riik67I5; spf=pass (google.com: domain of gcc-patches-return-511309-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-511309-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:mime-version:content-type; q=dns; s=default; b=Zkd2+V85HZOK32oGILX4dQ3gKsEgpWfwpFssasqWycvCZ6mjf7 P75H5oRchsEg45c22URAY3xkazUFQqguvWVLx8Eedqvc2CJi3LLL6zDCcxPT3e2v 59FTy6hFNp1kgTvxzHETwh09SMNgXe5k5UNzzZcO3+fDBxB/qu35UPACw= 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:mime-version:content-type; s= default; bh=FnkDaIxFhbigr435XldsaZ2U1Bo=; b=riik67I5Ry/PtuwVZvyL CUEkRTiGDUFrH77WBr/vtVva7JWKm8WWReXgmNeb6FleRLbgQHFLv+N9pz3VHCP6 CodN2qE2wmD4boYgt065VDkE5114NZTB9xjJihsBDdXiwzo0/bphDF8FZcgpdETs KTX4LoJYRNuhZbCs7q74YQ4= Received: (qmail 77749 invoked by alias); 18 Oct 2019 19:49:35 -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 77538 invoked by uid 89); 18 Oct 2019 19:49:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, SPF_PASS autolearn=ham version=3.3.1 spammy=hunting, UD:iterators.md, iterators.md, iteratorsmd X-HELO: foss.arm.com Received: from Unknown (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 19:49:20 +0000 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 4F9F81045; Fri, 18 Oct 2019 12:49:12 -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 CFD123F6C4; Fri, 18 Oct 2019 12:49:11 -0700 (PDT) From: Richard Earnshaw To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw Subject: [PATCH 00/29] [arm] Rewrite DImode arithmetic support Date: Fri, 18 Oct 2019 20:48:31 +0100 Message-Id: <20191018194900.34795-1-Richard.Earnshaw@arm.com> MIME-Version: 1.0 This series of patches rewrites all the DImode arithmetic patterns for the Arm backend when compiling for Arm or Thumb2 to split the operations during expand (the thumb1 code is unchanged and cannot benefit from early splitting as we are unable to expose the carry flag). This has a number of benefits: - register allocation has more freedom to use independent registers for the upper and lower halves of the register - we can make better use of combine for spotting insn merge opportunities without needing many additional patterns that are only used for DImode - we eliminate a number of bugs in the machine description where the carry calculations were not correctly propagated by the split patterns (we mostly got away with this because the splitting previously happened only after most of the important optimization passes had been run). The patch series starts by paring back all the DImode arithmetic support to a very simple form without any splitting at all and then progressively re-implementing the patterns with early split operations. This proved to be the only sane way of untangling the existing code due to a number of latent bugs which would have been exposed if a different approach had been taken. Each patch should produce a working compiler (it did when it was originally written), though since the patch set has been re-ordered slightly there is a possibility that some of the intermediate steps may have missing test updates that are only cleaned up later. However, only the end of the series should be considered complete. I've kept the patch as a series to permit easier regression hunting should that prove necessary. R. Richard Earnshaw (29): [arm] Rip out DImode addition and subtraction splits. [arm] Perform early splitting of adddi3. [arm] Early split zero- and sign-extension [arm] Rewrite addsi3_carryin_shift_ in canonical form [arm] fix constraints on addsi3_carryin_alt2 [arm] Early split subdi3 [arm] Remove redundant DImode subtract patterns [arm] Introduce arm_carry_operation [arm] Correctly cost addition with a carry-in [arm] Correct cost calculations involving borrow for subtracts. [arm] Reduce cost of insns that are simple reg-reg moves. [arm] Implement negscc using SBC when appropriate. [arm] Add alternative canonicalizations for subtract-with-carry + shift [arm] Early split simple DImode equality comparisons [arm] Improve handling of DImode comparisions against constants. [arm] early split most DImode comparison operations. [arm] Handle some constant comparisons using rsbs+rscs [arm] Cleanup dead code - old support for DImode comparisons [arm] Handle immediate values in uaddvsi4 [arm] Early expansion of uaddvdi4. [arm] Improve code generation for addvsi4. [arm] Allow the summation result of signed add-with-overflow to be discarded. [arm] Early split addvdi4 [arm] Improve constant handling for usubvsi4. [arm] Early expansion of usubvdi4. [arm] Improve constant handling for subvsi4. [arm] Early expansion of subvdi4 [arm] Improvements to negvsi4 and negvdi4. [arm] Fix testsuite nit when compiling for thumb2 gcc/config/arm/arm-modes.def | 19 +- gcc/config/arm/arm-protos.h | 1 + gcc/config/arm/arm.c | 598 ++++- gcc/config/arm/arm.md | 2020 ++++++++++------- gcc/config/arm/iterators.md | 15 +- gcc/config/arm/predicates.md | 29 +- gcc/config/arm/thumb2.md | 8 +- .../gcc.dg/builtin-arith-overflow-3.c | 41 + gcc/testsuite/gcc.target/arm/negdi-3.c | 4 +- 9 files changed, 1757 insertions(+), 978 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtin-arith-overflow-3.c