From patchwork Mon Oct 23 17:14:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116779 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4879909qgn; Mon, 23 Oct 2017 10:14:21 -0700 (PDT) X-Received: by 10.98.133.28 with SMTP id u28mr14082329pfd.241.1508778861923; Mon, 23 Oct 2017 10:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778861; cv=none; d=google.com; s=arc-20160816; b=ARcIttrbXOMPPGFe8rL/ekPYyfb74mULYMDh+/Yu+xMEYzZClaPYOTESy7kqbwrQiM xqHdTMqOlvsm0Cmo4LiOKewCND+P4GWkqfcu3rxhPKqxnOhz4a1SC5/memluiT15tayI dhUt1whwZXsNFXYoeQ5d6FF0Cjov0dI0zDOCJJa01YfTvdRvoOjL/uxbyxvlDaW3JeFX Vxk6miXrUummPMp5vQeP7JIZJBMS1JZuEJpIiJlt8eTyfpFsyVT9icj5vvQfH3RQ8iL2 L17Yo+Wis5Dk9IFCf75yQsjP4WAoY2xYTII/CKlccFurqZmd/1QHQSYfnTR3/bb0uZeI oHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :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=pV3jZDlVj8RGBExgSin0dKVimm191eq/4Dp7JkkmaCk=; b=ZnfLM3AHuP6G6wAxW57LDxAajRKouo39I+jR36xrAPHE6ofyo+Zc8/7TjCGytJxJDm 13I6eVvd4b8WvzoY3Hu1/mzkEQE/T/3g1exPIOOt+blsUkqLWcw7595VwFPJbPEMsZCc lXAqFyyyLA1FWsE8T8Yyo9OAKx6RhqwxHV1G97R7ng6Du5DELWCcn7VCdwgKfL4+cgmA u2GO7bjbKc7jZfyeSRVNceUyzXXNmd7OUKoXDidvkeSoxcQ8Eoj/lW4v3vQR89JVzgD3 PuMPoq5JND/+ePAeLnN7o1y+MjBfW7vIW+VM2kzj2TEgJlp8/bFdvkVlSd61ecmvbNu7 Pf6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dSePptOK; spf=pass (google.com: domain of gcc-patches-return-464811-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464811-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 n10si3092999plk.132.2017.10.23.10.14.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464811-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=dSePptOK; spf=pass (google.com: domain of gcc-patches-return-464811-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464811-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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=u/LmecCyJMsAVOEQKH8JmsClRyRDu eVcz22niUdG2d5kUNFWHytaAgXxRrKolRVqwsLwNRBLm1QHud6xRPs+JAi19HQu8 l+VYxFxw57yDTserTX01ybaWIRQYDayYusMYNjlObJRQSD1Wd1yRnGFGZIArlZuj lWHFCd3HTeynBo= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=NO4w2qSskxV0PjAdorfLz0IRswM=; b=dSe PptOK9lhF4HmUGTHGUVggFQfrMyczzD+MHNtXGNRFVdvvcNlvTlWrmeqUhCBDF8P cJYOC8eLdX/A3KMFc9T3bYfJE4166QLnzjZStOtHeIjhRbXspSov+LwytETP8w/F La0Di69gZwqW4TCtmEI/1QenHSjIFImJ0Da4aUiw= Received: (qmail 26384 invoked by alias); 23 Oct 2017 17:14:07 -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 26354 invoked by uid 89); 23 Oct 2017 17:14:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 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-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:14:04 +0000 Received: by mail-wm0-f50.google.com with SMTP id b189so10842634wmd.4 for ; Mon, 23 Oct 2017 10:14:04 -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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=pV3jZDlVj8RGBExgSin0dKVimm191eq/4Dp7JkkmaCk=; b=dlzzWo0mZHuPvoZY6aD8R0tgmbz4F8/pnHKx/8njEFHm9SkxBZlqP1lrlK3m8UBkoa hpPENbBKwnZfsayQIyRXnT7aee/PFdTzYlDOjKE+uHoJdMdNJBne8ISJ1YBikdTgeAfr 5sK3IBD9n8FYXhk6rlvALxBlP+PGbDmoC/qTIMAUGYpPqOAdA5zC3EcZnbguMg14okH6 cSX0UqtM4a/bKa4oS8CBLZET53GZqqFoJzplR3xIAoR6zNTyLKK+G3x4aevhrgPhRYvy IgejJyFePsJ61Fjqp2Q4kSv1AZpButKHmrWUCpQyvNgr7rXQHPMBmXFSEBci/Rimc2/q TKWQ== X-Gm-Message-State: AMCzsaWmrV7LsygZVc8oObAp3bO13v6JzSBxPvwbxayYmvMaZvY+U4Jh 3cw8kmyrtDzLsF5MOauFmytlt48554g= X-Google-Smtp-Source: ABhQp+Sn1Jqqwy5DzCGS6TLe8mliDK9par2P30ic59ayN91lbESdPG707JozdoNJ/DFBaUrRAnSapw== X-Received: by 10.28.63.68 with SMTP id m65mr5341526wma.55.1508778842536; Mon, 23 Oct 2017 10:14:02 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id a13sm1255207wrf.48.2017.10.23.10.14.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:14:01 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [035/nnn] poly_int: expand_debug_expr References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:14:01 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87o9oxokh2.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes expand_debug_expr track polynomial memory offsets. It simplifies the handling of the case in which the reference is not to the first byte of the base, which seemed non-trivial enough to make it worth splitting out as a separate patch. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (get_inner_reference): Add a version that returns the offset and size as poly_int64_pods rather than HOST_WIDE_INTs. * cfgexpand.c (expand_debug_expr): Track polynomial offsets. Simply the case in which bitpos is not associated with the first byte. Index: gcc/tree.h =================================================================== --- gcc/tree.h 2017-10-23 17:11:40.253962440 +0100 +++ gcc/tree.h 2017-10-23 17:18:40.711668346 +0100 @@ -5610,6 +5610,17 @@ extern bool complete_ctor_at_level_p (co the access position and size. */ extern tree get_inner_reference (tree, HOST_WIDE_INT *, HOST_WIDE_INT *, tree *, machine_mode *, int *, int *, int *); +/* Temporary. */ +inline tree +get_inner_reference (tree exp, poly_int64_pod *pbitsize, + poly_int64_pod *pbitpos, tree *poffset, + machine_mode *pmode, int *punsignedp, + int *preversep, int *pvolatilep) +{ + return get_inner_reference (exp, &pbitsize->coeffs[0], &pbitpos->coeffs[0], + poffset, pmode, punsignedp, preversep, + pvolatilep); +} extern tree build_personality_function (const char *); Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-10-23 17:16:59.700268356 +0100 +++ gcc/cfgexpand.c 2017-10-23 17:18:40.711668346 +0100 @@ -4450,7 +4450,7 @@ expand_debug_expr (tree exp) case VIEW_CONVERT_EXPR: { machine_mode mode1; - HOST_WIDE_INT bitsize, bitpos; + poly_int64 bitsize, bitpos; tree offset; int reversep, volatilep = 0; tree tem @@ -4458,7 +4458,7 @@ expand_debug_expr (tree exp) &unsignedp, &reversep, &volatilep); rtx orig_op0; - if (bitsize == 0) + if (known_zero (bitsize)) return NULL; orig_op0 = op0 = expand_debug_expr (tem); @@ -4501,19 +4501,14 @@ expand_debug_expr (tree exp) if (mode1 == VOIDmode) /* Bitfield. */ mode1 = smallest_int_mode_for_size (bitsize); - if (bitpos >= BITS_PER_UNIT) + poly_int64 bytepos = bits_to_bytes_round_down (bitpos); + if (maybe_nonzero (bytepos)) { - op0 = adjust_address_nv (op0, mode1, bitpos / BITS_PER_UNIT); - bitpos %= BITS_PER_UNIT; + op0 = adjust_address_nv (op0, mode1, bytepos); + bitpos = num_trailing_bits (bitpos); } - else if (bitpos < 0) - { - HOST_WIDE_INT units - = (-bitpos + BITS_PER_UNIT - 1) / BITS_PER_UNIT; - op0 = adjust_address_nv (op0, mode1, -units); - bitpos += units * BITS_PER_UNIT; - } - else if (bitpos == 0 && bitsize == GET_MODE_BITSIZE (mode)) + else if (known_zero (bitpos) + && must_eq (bitsize, GET_MODE_BITSIZE (mode))) op0 = adjust_address_nv (op0, mode, 0); else if (GET_MODE (op0) != mode1) op0 = adjust_address_nv (op0, mode1, 0); @@ -4524,17 +4519,18 @@ expand_debug_expr (tree exp) set_mem_attributes (op0, exp, 0); } - if (bitpos == 0 && mode == GET_MODE (op0)) + if (known_zero (bitpos) && mode == GET_MODE (op0)) return op0; - if (bitpos < 0) + if (may_lt (bitpos, 0)) return NULL; if (GET_MODE (op0) == BLKmode) return NULL; - if ((bitpos % BITS_PER_UNIT) == 0 - && bitsize == GET_MODE_BITSIZE (mode1)) + poly_int64 bytepos; + if (multiple_p (bitpos, BITS_PER_UNIT, &bytepos) + && must_eq (bitsize, GET_MODE_BITSIZE (mode1))) { machine_mode opmode = GET_MODE (op0); @@ -4547,12 +4543,11 @@ expand_debug_expr (tree exp) debug stmts). The gen_subreg below would rightfully crash, and the address doesn't really exist, so just drop it. */ - if (bitpos >= GET_MODE_BITSIZE (opmode)) + if (must_ge (bitpos, GET_MODE_BITSIZE (opmode))) return NULL; - if ((bitpos % GET_MODE_BITSIZE (mode)) == 0) - return simplify_gen_subreg (mode, op0, opmode, - bitpos / BITS_PER_UNIT); + if (multiple_p (bitpos, GET_MODE_BITSIZE (mode))) + return simplify_gen_subreg (mode, op0, opmode, bytepos); } return simplify_gen_ternary (SCALAR_INT_MODE_P (GET_MODE (op0)) @@ -4562,7 +4557,8 @@ expand_debug_expr (tree exp) GET_MODE (op0) != VOIDmode ? GET_MODE (op0) : TYPE_MODE (TREE_TYPE (tem)), - op0, GEN_INT (bitsize), GEN_INT (bitpos)); + op0, gen_int_mode (bitsize, word_mode), + gen_int_mode (bitpos, word_mode)); } case ABS_EXPR: