From patchwork Wed Oct 16 10:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1177782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511096-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uyDaC5sr"; 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 46tTdD6FW0z9sNw for ; Wed, 16 Oct 2019 21:51:58 +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:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=vSloikHKougvSfRYCott8fr+qvcMst7abQGfiP5UxoVyxs4UU5ciD IFP+Q0X/eUvP+3//sjK3uxtJnq7X+hMeqJPonRsULuPs8mXFYlqVwHqruSRaLo5J X0bGUJ3O81fiqfZxWU2bkfNlhRR3ar4ifwDuTNdo2jYtJEJ9zovfRM= 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=9vTex2+q6kCfUeTue3Pt9rWwFdk=; b=uyDaC5srvg8BfLi6ruAL +iQ/CwKwatVeHyDmHOw4rbiD3hsFB/f71P7vmBj+7MQu6+/ONhv9nqDcIMwBI3O+ QJbUYhYti+cOyd+tnWQvdvgOyZhUffsQrcsJVu2/JzsSaGLwKrFrzztu8b+atR8p Bm3jsbcMsaSHXKg4UEbspsQ= Received: (qmail 106366 invoked by alias); 16 Oct 2019 10:51:52 -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 106357 invoked by uid 89); 16 Oct 2019 10:51:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=choosing X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Oct 2019 10:51:50 +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 5DBCA28 for ; Wed, 16 Oct 2019 03:51:48 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F06373F6C4 for ; Wed, 16 Oct 2019 03:51:47 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed][AArch64] Improve poly_int handling in aarch64_layout_frame Date: Wed, 16 Oct 2019 11:51:46 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes I'd used known_lt when converting these conditions to poly_int, but on reflection that was a bad choice. The code isn't just doing a range check; it specifically needs constants that will fit in a certain encoding. Tested on aarch64-linux-gnu and aarch64_be-elf, applied as r277061. Richard 2019-10-16 Richard Sandiford gcc/ * config/aarch64/aarch64.c (aarch64_layout_frame): Use is_constant rather than known_lt when choosing frame layouts. Index: gcc/config/aarch64/aarch64.c =================================================================== --- gcc/config/aarch64/aarch64.c 2019-10-16 11:47:34.727496649 +0100 +++ gcc/config/aarch64/aarch64.c 2019-10-16 11:50:14.386356922 +0100 @@ -5447,7 +5447,7 @@ #define SLOT_REQUIRED (-1) else if (frame.wb_candidate1 != INVALID_REGNUM) max_push_offset = 256; - HOST_WIDE_INT const_size, const_fp_offset; + HOST_WIDE_INT const_size, const_outgoing_args_size, const_fp_offset; if (frame.frame_size.is_constant (&const_size) && const_size < max_push_offset && known_eq (crtl->outgoing_args_size, 0)) @@ -5457,16 +5457,18 @@ #define SLOT_REQUIRED (-1) stp reg3, reg4, [sp, 16] */ frame.callee_adjust = const_size; } - else if (known_lt (crtl->outgoing_args_size + frame.saved_regs_size, 512) + else if (crtl->outgoing_args_size.is_constant (&const_outgoing_args_size) + && const_outgoing_args_size + frame.saved_regs_size < 512 && !(cfun->calls_alloca - && known_lt (frame.hard_fp_offset, max_push_offset))) + && frame.hard_fp_offset.is_constant (&const_fp_offset) + && const_fp_offset < max_push_offset)) { /* Frame with small outgoing arguments: sub sp, sp, frame_size stp reg1, reg2, [sp, outgoing_args_size] stp reg3, reg4, [sp, outgoing_args_size + 16] */ frame.initial_adjust = frame.frame_size; - frame.callee_offset = frame.frame_size - frame.hard_fp_offset; + frame.callee_offset = const_outgoing_args_size; } else if (frame.hard_fp_offset.is_constant (&const_fp_offset) && const_fp_offset < max_push_offset)