From patchwork Mon Oct 23 17:12:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116774 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4878406qgn; Mon, 23 Oct 2017 10:12:41 -0700 (PDT) X-Received: by 10.99.149.15 with SMTP id p15mr12394435pgd.406.1508778761905; Mon, 23 Oct 2017 10:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778761; cv=none; d=google.com; s=arc-20160816; b=y7GCbxakFRviDP1WO9HqIDkejMHcIixvk219rJziRWR/TaB/RG/EHmNerF3Ffv1yAH 4Z/rcoyZ0CuD5W1B9eqizURN2dvymVmfiSdRLVweOPJOvmerLRRUTwcSL3B2I8eMU635 dxXj3jtTxPCRJeCVCNz6MOkcLE71l7WoFvagXA1ahsGTjM/QcIgOMNFuFG+aA7fm1Qx7 nTKwWq+5VnJ5kSZOW6eg9RxzkcieC5DBiY8R22i8aBkbTnJ7uVaidyZoKm7rGkM5x3IP y7ils/qUcEBP/Hquv4TE8dldqLoihuK9gmCm+AaSXR1sKOYEeaxV6bdVhkpXOLdm/IgL 5nXw== 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=sHZe4YIryUjOYityHS56Nxb9tgMGEUxxK8C/s18WqgQ=; b=bVP6R34m5UtOd+3yq7qZrVrKjCSAt/07E77uBjBMQ/lasW+xWHuYcB8nVGyxdxwgww OOkUdv5EpvVIcj2HBg4W9GhC4EfExQucX8vScnYiTYKcN/iVG/jqJOXxF9cccykX1XVt TlGZ6yEb2uheEnSYYcnqzDr5XzbYk6hCN0i5E7dB6VpLuz3oxcv+fI58lEAQ4S3Fa0+M vFgVQ81IG31bVKWoKwFhnhOiLCa3CjXg00VShjXk1StGzdzYaWiUzEZanV4BsH7yoKbE 5Hum2whRhCEHT6taeo9fhsQ+5MwHlwpHl860xBhj7/dpCEQO2l6yHxAsh2JbE+PseOtI ILwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vdeSazqY; spf=pass (google.com: domain of gcc-patches-return-464806-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464806-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 x32si4274720pld.216.2017.10.23.10.12.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464806-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=vdeSazqY; spf=pass (google.com: domain of gcc-patches-return-464806-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464806-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=tK74exJ3DWd/ca6hGE/v0FOFhPBQ7 rgf92k361shCbxkRgsq5UJ1iHVGJ0RK6EEUWwoGycxd6+ALvZqbo3HJ4grdUw9wd xE2tur+JpxzcANMCv4RtwLH1b2Ux7A5O8VoArmBWqjL26JYv/hCMH3iG42YrCPtD t/PnIXx/T+zkLo= 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=ae9iLYWA6CbvCrnhZBYTyJIjswA=; b=vde SazqYR/5SU1QbbsYBnu0YfxHDLXKLH8MQrMvEQLSW8mPArL8i3Hl3fgWIuoR3+ml GJoBvl7dsqhrTcL9KDBntsfMFI7PSyAsGSD4qfzI6JWzMhxQDm9npE4jkGjfqyNt +0iEBGfS0ZWNnCjgIbMYT5LbK0yig4fNaQ9G1bvs= Received: (qmail 17439 invoked by alias); 23 Oct 2017 17:12: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 17387 invoked by uid 89); 23 Oct 2017 17:12:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f53.google.com Received: from mail-wm0-f53.google.com (HELO mail-wm0-f53.google.com) (74.125.82.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:12:17 +0000 Received: by mail-wm0-f53.google.com with SMTP id b189so10833925wmd.4 for ; Mon, 23 Oct 2017 10:12:17 -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=sHZe4YIryUjOYityHS56Nxb9tgMGEUxxK8C/s18WqgQ=; b=pd5l76IBdAw99iTi1QfP8Okw2V0gCBFv4Bg3kdizevqAaLsV2ZwVOdLEAto9W+Tb8A CEOMngZ5DGTDVuRZqXx+lOXipUxll00m8GXtFYf4qgpNMwPmsyNcok6m/y/lm7wzow8O e2gKLVUwkCAb4UVjH0Wz+WWMaek0N/5EqDQJZoSAIrwQhrVANZrbxcpZDyzXhaKaWfAI zpvcANHyNfuIxBGeZc926p1naPtl0oDL9VC7DXfNl4YEUDV/q/ZxREF1MNYj82zhbCqa fMH4dWfx3txxOkbHvxuLvpk8edNsuskud9nHiW24RiuzRSumkbWehAR9xJ3JKsxaNN3y v77Q== X-Gm-Message-State: AMCzsaVUkdn/rhKaUGmvV4YHYkoB9Cb+HRxzmmoG2YAlQKBdsWbNcjTe AbfbcNLN5jHNRo77b47gApb8EDdz7L8= X-Google-Smtp-Source: ABhQp+QvP0f4GegYalukB9xs60j5C/EoRoIbLwnvx9UwZ6bwSudDDM0K7/nKrJLFYTFt0aP+zkpLEA== X-Received: by 10.28.92.136 with SMTP id q130mr5928254wmb.104.1508778734765; Mon, 23 Oct 2017 10:12:14 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id v5sm3171123wme.5.2017.10.23.10.12.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:12:14 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [030/nnn] poly_int: get_addr_unit_base_and_extent References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:12:12 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87a80hpz4j.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch changes the values returned by get_addr_unit_base_and_extent from HOST_WIDE_INT to poly_int64. maxsize in gimple_fold_builtin_memory_op goes from HOST_WIDE_INT to poly_uint64 (rather than poly_int) to match the previous use of tree_fits_uhwi_p. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-dfa.h (get_addr_base_and_unit_offset_1): Return the offset as a poly_int64_pod rather than a HOST_WIDE_INT. (get_addr_base_and_unit_offset): Likewise. * tree-dfa.c (get_addr_base_and_unit_offset_1): Likewise. (get_addr_base_and_unit_offset): Likewise. * doc/match-and-simplify.texi: Change off from HOST_WIDE_INT to poly_int64 in example. * fold-const.c (fold_binary_loc): Update call to get_addr_base_and_unit_offset. * gimple-fold.c (gimple_fold_builtin_memory_op): Likewise. (maybe_canonicalize_mem_ref_addr): Likewise. (gimple_fold_stmt_to_constant_1): Likewise. * ipa-prop.c (ipa_modify_call_arguments): Likewise. * match.pd: Likewise. * omp-low.c (lower_omp_target): Likewise. * tree-sra.c (build_ref_for_offset): Likewise. (build_debug_ref_for_model): Likewise. * tree-ssa-address.c (maybe_fold_tmr): Likewise. * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Likewise. * tree-ssa-ccp.c (optimize_memcpy): Likewise. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Likewise. (constant_pointer_difference): Likewise. * tree-ssa-loop-niter.c (expand_simple_operations): Likewise. * tree-ssa-phiopt.c (jump_function_from_stmt): Likewise. * tree-ssa-pre.c (create_component_ref_by_pieces_1): Likewise. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Likewise. (vn_reference_maybe_forwprop_address, vn_reference_lookup_3): Likewise. (set_ssa_val_to): Likewise. * tree-ssa-strlen.c (get_addr_stridx, addr_stridxptr): Likewise. * tree.c (build_simple_mem_ref_loc): Likewise. Index: gcc/tree-dfa.h =================================================================== --- gcc/tree-dfa.h 2017-10-23 17:16:59.705267681 +0100 +++ gcc/tree-dfa.h 2017-10-23 17:17:01.432034493 +0100 @@ -33,9 +33,9 @@ extern tree get_ref_base_and_extent (tre poly_int64_pod *, bool *); extern tree get_ref_base_and_extent_hwi (tree, HOST_WIDE_INT *, HOST_WIDE_INT *, bool *); -extern tree get_addr_base_and_unit_offset_1 (tree, HOST_WIDE_INT *, +extern tree get_addr_base_and_unit_offset_1 (tree, poly_int64_pod *, tree (*) (tree)); -extern tree get_addr_base_and_unit_offset (tree, HOST_WIDE_INT *); +extern tree get_addr_base_and_unit_offset (tree, poly_int64_pod *); extern bool stmt_references_abnormal_ssa_name (gimple *); extern void replace_abnormal_ssa_names (gimple *); extern void dump_enumerated_decls (FILE *, dump_flags_t); Index: gcc/tree-dfa.c =================================================================== --- gcc/tree-dfa.c 2017-10-23 17:16:59.705267681 +0100 +++ gcc/tree-dfa.c 2017-10-23 17:17:01.432034493 +0100 @@ -705,10 +705,10 @@ get_ref_base_and_extent_hwi (tree exp, H its argument or a constant if the argument is known to be constant. */ tree -get_addr_base_and_unit_offset_1 (tree exp, HOST_WIDE_INT *poffset, +get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset, tree (*valueize) (tree)) { - HOST_WIDE_INT byte_offset = 0; + poly_int64 byte_offset = 0; /* Compute cumulative byte-offset for nested component-refs and array-refs, and find the ultimate containing object. */ @@ -718,10 +718,13 @@ get_addr_base_and_unit_offset_1 (tree ex { case BIT_FIELD_REF: { - HOST_WIDE_INT this_off = TREE_INT_CST_LOW (TREE_OPERAND (exp, 2)); - if (this_off % BITS_PER_UNIT) + poly_int64 this_byte_offset; + poly_uint64 this_bit_offset; + if (!poly_int_tree_p (TREE_OPERAND (exp, 2), &this_bit_offset) + || !multiple_p (this_bit_offset, BITS_PER_UNIT, + &this_byte_offset)) return NULL_TREE; - byte_offset += this_off / BITS_PER_UNIT; + byte_offset += this_byte_offset; } break; @@ -729,15 +732,14 @@ get_addr_base_and_unit_offset_1 (tree ex { tree field = TREE_OPERAND (exp, 1); tree this_offset = component_ref_field_offset (exp); - HOST_WIDE_INT hthis_offset; + poly_int64 hthis_offset; if (!this_offset - || TREE_CODE (this_offset) != INTEGER_CST + || !poly_int_tree_p (this_offset, &hthis_offset) || (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)) % BITS_PER_UNIT)) return NULL_TREE; - hthis_offset = TREE_INT_CST_LOW (this_offset); hthis_offset += (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)) / BITS_PER_UNIT); byte_offset += hthis_offset; @@ -755,17 +757,18 @@ get_addr_base_and_unit_offset_1 (tree ex index = (*valueize) (index); /* If the resulting bit-offset is constant, track it. */ - if (TREE_CODE (index) == INTEGER_CST + if (poly_int_tree_p (index) && (low_bound = array_ref_low_bound (exp), - TREE_CODE (low_bound) == INTEGER_CST) + poly_int_tree_p (low_bound)) && (unit_size = array_ref_element_size (exp), TREE_CODE (unit_size) == INTEGER_CST)) { - offset_int woffset - = wi::sext (wi::to_offset (index) - wi::to_offset (low_bound), + poly_offset_int woffset + = wi::sext (wi::to_poly_offset (index) + - wi::to_poly_offset (low_bound), TYPE_PRECISION (TREE_TYPE (index))); woffset *= wi::to_offset (unit_size); - byte_offset += woffset.to_shwi (); + byte_offset += woffset.force_shwi (); } else return NULL_TREE; @@ -842,7 +845,7 @@ get_addr_base_and_unit_offset_1 (tree ex is not BITS_PER_UNIT-aligned. */ tree -get_addr_base_and_unit_offset (tree exp, HOST_WIDE_INT *poffset) +get_addr_base_and_unit_offset (tree exp, poly_int64_pod *poffset) { return get_addr_base_and_unit_offset_1 (exp, poffset, NULL); } Index: gcc/doc/match-and-simplify.texi =================================================================== --- gcc/doc/match-and-simplify.texi 2017-10-23 17:07:40.843798706 +0100 +++ gcc/doc/match-and-simplify.texi 2017-10-23 17:17:01.428035033 +0100 @@ -205,7 +205,7 @@ Captures can also be used for capturing (pointer_plus (addr@@2 @@0) INTEGER_CST_P@@1) (if (is_gimple_min_invariant (@@2))) @{ - HOST_WIDE_INT off; + poly_int64 off; tree base = get_addr_base_and_unit_offset (@@0, &off); off += tree_to_uhwi (@@1); /* Now with that we should be able to simply write Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-10-23 17:11:40.244945208 +0100 +++ gcc/fold-const.c 2017-10-23 17:17:01.429034898 +0100 @@ -9455,7 +9455,7 @@ fold_binary_loc (location_t loc, && handled_component_p (TREE_OPERAND (arg0, 0))) { tree base; - HOST_WIDE_INT coffset; + poly_int64 coffset; base = get_addr_base_and_unit_offset (TREE_OPERAND (arg0, 0), &coffset); if (!base) Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c 2017-10-23 17:16:59.703267951 +0100 +++ gcc/gimple-fold.c 2017-10-23 17:17:01.430034763 +0100 @@ -838,8 +838,8 @@ gimple_fold_builtin_memory_op (gimple_st && TREE_CODE (dest) == ADDR_EXPR) { tree src_base, dest_base, fn; - HOST_WIDE_INT src_offset = 0, dest_offset = 0; - HOST_WIDE_INT maxsize; + poly_int64 src_offset = 0, dest_offset = 0; + poly_uint64 maxsize; srcvar = TREE_OPERAND (src, 0); src_base = get_addr_base_and_unit_offset (srcvar, &src_offset); @@ -850,16 +850,14 @@ gimple_fold_builtin_memory_op (gimple_st &dest_offset); if (dest_base == NULL) dest_base = destvar; - if (tree_fits_uhwi_p (len)) - maxsize = tree_to_uhwi (len); - else + if (!poly_int_tree_p (len, &maxsize)) maxsize = -1; if (SSA_VAR_P (src_base) && SSA_VAR_P (dest_base)) { if (operand_equal_p (src_base, dest_base, 0) - && ranges_overlap_p (src_offset, maxsize, - dest_offset, maxsize)) + && ranges_may_overlap_p (src_offset, maxsize, + dest_offset, maxsize)) return false; } else if (TREE_CODE (src_base) == MEM_REF @@ -868,17 +866,12 @@ gimple_fold_builtin_memory_op (gimple_st if (! operand_equal_p (TREE_OPERAND (src_base, 0), TREE_OPERAND (dest_base, 0), 0)) return false; - offset_int off = mem_ref_offset (src_base) + src_offset; - if (!wi::fits_shwi_p (off)) - return false; - src_offset = off.to_shwi (); - - off = mem_ref_offset (dest_base) + dest_offset; - if (!wi::fits_shwi_p (off)) - return false; - dest_offset = off.to_shwi (); - if (ranges_overlap_p (src_offset, maxsize, - dest_offset, maxsize)) + poly_offset_int full_src_offset + = mem_ref_offset (src_base) + src_offset; + poly_offset_int full_dest_offset + = mem_ref_offset (dest_base) + dest_offset; + if (ranges_may_overlap_p (full_src_offset, maxsize, + full_dest_offset, maxsize)) return false; } else @@ -4317,7 +4310,7 @@ maybe_canonicalize_mem_ref_addr (tree *t || handled_component_p (TREE_OPERAND (addr, 0)))) { tree base; - HOST_WIDE_INT coffset; + poly_int64 coffset; base = get_addr_base_and_unit_offset (TREE_OPERAND (addr, 0), &coffset); if (!base) @@ -5903,7 +5896,7 @@ gimple_fold_stmt_to_constant_1 (gimple * else if (TREE_CODE (rhs) == ADDR_EXPR && !is_gimple_min_invariant (rhs)) { - HOST_WIDE_INT offset = 0; + poly_int64 offset = 0; tree base; base = get_addr_base_and_unit_offset_1 (TREE_OPERAND (rhs, 0), &offset, Index: gcc/ipa-prop.c =================================================================== --- gcc/ipa-prop.c 2017-10-23 17:16:59.704267816 +0100 +++ gcc/ipa-prop.c 2017-10-23 17:17:01.431034628 +0100 @@ -4297,7 +4297,7 @@ ipa_modify_call_arguments (struct cgraph off = build_int_cst (adj->alias_ptr_type, byte_offset); else { - HOST_WIDE_INT base_offset; + poly_int64 base_offset; tree prev_base; bool addrof; Index: gcc/match.pd =================================================================== --- gcc/match.pd 2017-10-23 17:11:39.914313353 +0100 +++ gcc/match.pd 2017-10-23 17:17:01.431034628 +0100 @@ -3345,7 +3345,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cmp (convert1?@2 addr@0) (convert2? addr@1)) (with { - HOST_WIDE_INT off0, off1; + poly_int64 off0, off1; tree base0 = get_addr_base_and_unit_offset (TREE_OPERAND (@0, 0), &off0); tree base1 = get_addr_base_and_unit_offset (TREE_OPERAND (@1, 0), &off1); if (base0 && TREE_CODE (base0) == MEM_REF) @@ -3384,23 +3384,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) } (if (equal == 1) (switch - (if (cmp == EQ_EXPR) - { constant_boolean_node (off0 == off1, type); }) - (if (cmp == NE_EXPR) - { constant_boolean_node (off0 != off1, type); }) - (if (cmp == LT_EXPR) - { constant_boolean_node (off0 < off1, type); }) - (if (cmp == LE_EXPR) - { constant_boolean_node (off0 <= off1, type); }) - (if (cmp == GE_EXPR) - { constant_boolean_node (off0 >= off1, type); }) - (if (cmp == GT_EXPR) - { constant_boolean_node (off0 > off1, type); })) + (if (cmp == EQ_EXPR && (must_eq (off0, off1) || must_ne (off0, off1))) + { constant_boolean_node (must_eq (off0, off1), type); }) + (if (cmp == NE_EXPR && (must_eq (off0, off1) || must_ne (off0, off1))) + { constant_boolean_node (must_ne (off0, off1), type); }) + (if (cmp == LT_EXPR && (must_lt (off0, off1) || must_ge (off0, off1))) + { constant_boolean_node (must_lt (off0, off1), type); }) + (if (cmp == LE_EXPR && (must_le (off0, off1) || must_gt (off0, off1))) + { constant_boolean_node (must_le (off0, off1), type); }) + (if (cmp == GE_EXPR && (must_ge (off0, off1) || must_lt (off0, off1))) + { constant_boolean_node (must_ge (off0, off1), type); }) + (if (cmp == GT_EXPR && (must_gt (off0, off1) || must_le (off0, off1))) + { constant_boolean_node (must_gt (off0, off1), type); })) (if (equal == 0 && DECL_P (base0) && DECL_P (base1) /* If we compare this as integers require equal offset. */ && (!INTEGRAL_TYPE_P (TREE_TYPE (@2)) - || off0 == off1)) + || must_eq (off0, off1))) (switch (if (cmp == EQ_EXPR) { constant_boolean_node (false, type); }) Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c 2017-10-23 17:11:39.972424406 +0100 +++ gcc/omp-low.c 2017-10-23 17:17:01.432034493 +0100 @@ -8397,7 +8397,7 @@ lower_omp_target (gimple_stmt_iterator * || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_REFERENCE) { location_t clause_loc = OMP_CLAUSE_LOCATION (c); - HOST_WIDE_INT offset = 0; + poly_int64 offset = 0; gcc_assert (prev); var = OMP_CLAUSE_DECL (c); if (DECL_P (var) Index: gcc/tree-sra.c =================================================================== --- gcc/tree-sra.c 2017-10-23 17:16:59.705267681 +0100 +++ gcc/tree-sra.c 2017-10-23 17:17:01.433034358 +0100 @@ -1678,7 +1678,7 @@ build_ref_for_offset (location_t loc, tr tree prev_base = base; tree off; tree mem_ref; - HOST_WIDE_INT base_offset; + poly_int64 base_offset; unsigned HOST_WIDE_INT misalign; unsigned int align; @@ -1786,7 +1786,7 @@ build_ref_for_model (location_t loc, tre build_debug_ref_for_model (location_t loc, tree base, HOST_WIDE_INT offset, struct access *model) { - HOST_WIDE_INT base_offset; + poly_int64 base_offset; tree off; if (TREE_CODE (model->expr) == COMPONENT_REF Index: gcc/tree-ssa-address.c =================================================================== --- gcc/tree-ssa-address.c 2017-10-23 17:11:40.248952867 +0100 +++ gcc/tree-ssa-address.c 2017-10-23 17:17:01.433034358 +0100 @@ -1061,7 +1061,7 @@ maybe_fold_tmr (tree ref) else if (addr.symbol && handled_component_p (TREE_OPERAND (addr.symbol, 0))) { - HOST_WIDE_INT offset; + poly_int64 offset; addr.symbol = build_fold_addr_expr (get_addr_base_and_unit_offset (TREE_OPERAND (addr.symbol, 0), &offset)); Index: gcc/tree-ssa-alias.c =================================================================== --- gcc/tree-ssa-alias.c 2017-10-23 17:16:59.705267681 +0100 +++ gcc/tree-ssa-alias.c 2017-10-23 17:17:01.433034358 +0100 @@ -683,8 +683,7 @@ ao_ref_alias_set (ao_ref *ref) void ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) { - HOST_WIDE_INT t; - poly_int64 size_hwi, extra_offset = 0; + poly_int64 t, size_hwi, extra_offset = 0; ref->ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { Index: gcc/tree-ssa-ccp.c =================================================================== --- gcc/tree-ssa-ccp.c 2017-10-23 17:07:40.843798706 +0100 +++ gcc/tree-ssa-ccp.c 2017-10-23 17:17:01.433034358 +0100 @@ -3003,7 +3003,7 @@ optimize_memcpy (gimple_stmt_iterator *g gimple *defstmt = SSA_NAME_DEF_STMT (vuse); tree src2 = NULL_TREE, len2 = NULL_TREE; - HOST_WIDE_INT offset, offset2; + poly_int64 offset, offset2; tree val = integer_zero_node; if (gimple_store_p (defstmt) && gimple_assign_single_p (defstmt) @@ -3035,16 +3035,16 @@ optimize_memcpy (gimple_stmt_iterator *g ? DECL_SIZE_UNIT (TREE_OPERAND (src2, 1)) : TYPE_SIZE_UNIT (TREE_TYPE (src2))); if (len == NULL_TREE - || TREE_CODE (len) != INTEGER_CST + || !poly_int_tree_p (len) || len2 == NULL_TREE - || TREE_CODE (len2) != INTEGER_CST) + || !poly_int_tree_p (len2)) return; src = get_addr_base_and_unit_offset (src, &offset); src2 = get_addr_base_and_unit_offset (src2, &offset2); if (src == NULL_TREE || src2 == NULL_TREE - || offset < offset2) + || may_lt (offset, offset2)) return; if (!operand_equal_p (src, src2, 0)) @@ -3053,7 +3053,8 @@ optimize_memcpy (gimple_stmt_iterator *g /* [ src + offset2, src + offset2 + len2 - 1 ] is set to val. Make sure that [ src + offset, src + offset + len - 1 ] is a subset of that. */ - if (wi::to_offset (len) + (offset - offset2) > wi::to_offset (len2)) + if (may_gt (wi::to_poly_offset (len) + (offset - offset2), + wi::to_poly_offset (len2))) return; if (dump_file && (dump_flags & TDF_DETAILS)) Index: gcc/tree-ssa-forwprop.c =================================================================== --- gcc/tree-ssa-forwprop.c 2017-10-23 17:07:40.843798706 +0100 +++ gcc/tree-ssa-forwprop.c 2017-10-23 17:17:01.434034223 +0100 @@ -758,12 +758,12 @@ forward_propagate_addr_expr_1 (tree name && TREE_OPERAND (lhs, 0) == name) { tree def_rhs_base; - HOST_WIDE_INT def_rhs_offset; + poly_int64 def_rhs_offset; /* If the address is invariant we can always fold it. */ if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0), &def_rhs_offset))) { - offset_int off = mem_ref_offset (lhs); + poly_offset_int off = mem_ref_offset (lhs); tree new_ptr; off += def_rhs_offset; if (TREE_CODE (def_rhs_base) == MEM_REF) @@ -850,11 +850,11 @@ forward_propagate_addr_expr_1 (tree name && TREE_OPERAND (rhs, 0) == name) { tree def_rhs_base; - HOST_WIDE_INT def_rhs_offset; + poly_int64 def_rhs_offset; if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0), &def_rhs_offset))) { - offset_int off = mem_ref_offset (rhs); + poly_offset_int off = mem_ref_offset (rhs); tree new_ptr; off += def_rhs_offset; if (TREE_CODE (def_rhs_base) == MEM_REF) @@ -1169,12 +1169,12 @@ #define CPD_ITERATIONS 5 if (TREE_CODE (p) == ADDR_EXPR) { tree q = TREE_OPERAND (p, 0); - HOST_WIDE_INT offset; + poly_int64 offset; tree base = get_addr_base_and_unit_offset (q, &offset); if (base) { q = base; - if (offset) + if (maybe_nonzero (offset)) off = size_binop (PLUS_EXPR, off, size_int (offset)); } if (TREE_CODE (q) == MEM_REF Index: gcc/tree-ssa-loop-niter.c =================================================================== --- gcc/tree-ssa-loop-niter.c 2017-10-23 17:07:40.843798706 +0100 +++ gcc/tree-ssa-loop-niter.c 2017-10-23 17:17:01.434034223 +0100 @@ -1987,7 +1987,7 @@ expand_simple_operations (tree expr, tre return expand_simple_operations (e, stop); else if (code == ADDR_EXPR) { - HOST_WIDE_INT offset; + poly_int64 offset; tree base = get_addr_base_and_unit_offset (TREE_OPERAND (e, 0), &offset); if (base Index: gcc/tree-ssa-phiopt.c =================================================================== --- gcc/tree-ssa-phiopt.c 2017-10-23 17:07:40.843798706 +0100 +++ gcc/tree-ssa-phiopt.c 2017-10-23 17:17:01.434034223 +0100 @@ -692,12 +692,12 @@ jump_function_from_stmt (tree *arg, gimp { /* For arg = &p->i transform it to p, if possible. */ tree rhs1 = gimple_assign_rhs1 (stmt); - HOST_WIDE_INT offset; + poly_int64 offset; tree tem = get_addr_base_and_unit_offset (TREE_OPERAND (rhs1, 0), &offset); if (tem && TREE_CODE (tem) == MEM_REF - && (mem_ref_offset (tem) + offset) == 0) + && known_zero (mem_ref_offset (tem) + offset)) { *arg = TREE_OPERAND (tem, 0); return true; Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c 2017-10-23 17:11:39.943368879 +0100 +++ gcc/tree-ssa-pre.c 2017-10-23 17:17:01.435034088 +0100 @@ -2504,7 +2504,7 @@ create_component_ref_by_pieces_1 (basic_ if (TREE_CODE (baseop) == ADDR_EXPR && handled_component_p (TREE_OPERAND (baseop, 0))) { - HOST_WIDE_INT off; + poly_int64 off; tree base; base = get_addr_base_and_unit_offset (TREE_OPERAND (baseop, 0), &off); Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c 2017-10-23 17:16:59.706267546 +0100 +++ gcc/tree-ssa-sccvn.c 2017-10-23 17:17:01.435034088 +0100 @@ -1154,7 +1154,7 @@ vn_reference_fold_indirect (vecop0, 0)) { - offset_int off = offset_int::from (wi::to_wide (mem_op->op0), SIGNED); - off += addr_offset; + poly_offset_int off + = (poly_offset_int::from (wi::to_poly_wide (mem_op->op0), + SIGNED) + + addr_offset); mem_op->op0 = wide_int_to_tree (TREE_TYPE (mem_op->op0), off); op->op0 = build_fold_addr_expr (addr_base); if (tree_fits_shwi_p (mem_op->op0)) @@ -1188,7 +1190,7 @@ vn_reference_maybe_forwprop_address (vec vn_reference_op_t mem_op = &(*ops)[i - 1]; gimple *def_stmt; enum tree_code code; - offset_int off; + poly_offset_int off; def_stmt = SSA_NAME_DEF_STMT (op->op0); if (!is_gimple_assign (def_stmt)) @@ -1199,7 +1201,7 @@ vn_reference_maybe_forwprop_address (vec && code != POINTER_PLUS_EXPR) return false; - off = offset_int::from (wi::to_wide (mem_op->op0), SIGNED); + off = poly_offset_int::from (wi::to_poly_wide (mem_op->op0), SIGNED); /* The only thing we have to do is from &OBJ.foo.bar add the offset from .foo.bar to the preceding MEM_REF offset and replace the @@ -1207,7 +1209,7 @@ vn_reference_maybe_forwprop_address (vec if (code == ADDR_EXPR) { tree addr, addr_base; - HOST_WIDE_INT addr_offset; + poly_int64 addr_offset; addr = gimple_assign_rhs1 (def_stmt); addr_base = get_addr_base_and_unit_offset (TREE_OPERAND (addr, 0), @@ -1217,7 +1219,7 @@ vn_reference_maybe_forwprop_address (vec dereference isn't offsetted. */ if (!addr_base && *i_p == ops->length () - 1 - && off == 0 + && known_zero (off) /* This makes us disable this transform for PRE where the reference ops might be also used for code insertion which is invalid. */ @@ -1234,7 +1236,7 @@ vn_reference_maybe_forwprop_address (vec vn_reference_op_t new_mem_op = &tem[tem.length () - 2]; new_mem_op->op0 = wide_int_to_tree (TREE_TYPE (mem_op->op0), - wi::to_wide (new_mem_op->op0)); + wi::to_poly_wide (new_mem_op->op0)); } else gcc_assert (tem.last ().opcode == STRING_CST); @@ -2242,10 +2244,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree } if (TREE_CODE (lhs) == ADDR_EXPR) { - HOST_WIDE_INT tmp_lhs_offset; tree tem = get_addr_base_and_unit_offset (TREE_OPERAND (lhs, 0), - &tmp_lhs_offset); - lhs_offset = tmp_lhs_offset; + &lhs_offset); if (!tem) return (void *)-1; if (TREE_CODE (tem) == MEM_REF @@ -2272,10 +2272,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree rhs = SSA_VAL (rhs); if (TREE_CODE (rhs) == ADDR_EXPR) { - HOST_WIDE_INT tmp_rhs_offset; tree tem = get_addr_base_and_unit_offset (TREE_OPERAND (rhs, 0), - &tmp_rhs_offset); - rhs_offset = tmp_rhs_offset; + &rhs_offset); if (!tem) return (void *)-1; if (TREE_CODE (tem) == MEM_REF @@ -3282,7 +3280,7 @@ dominated_by_p_w_unex (basic_block bb1, set_ssa_val_to (tree from, tree to) { tree currval = SSA_VAL (from); - HOST_WIDE_INT toff, coff; + poly_int64 toff, coff; /* The only thing we allow as value numbers are ssa_names and invariants. So assert that here. We don't allow VN_TOP @@ -3364,7 +3362,7 @@ set_ssa_val_to (tree from, tree to) && TREE_CODE (to) == ADDR_EXPR && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff) == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff)) - && coff == toff)) + && must_eq (coff, toff))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " (changed)\n"); Index: gcc/tree-ssa-strlen.c =================================================================== --- gcc/tree-ssa-strlen.c 2017-10-23 17:07:40.843798706 +0100 +++ gcc/tree-ssa-strlen.c 2017-10-23 17:17:01.436033953 +0100 @@ -227,8 +227,9 @@ get_addr_stridx (tree exp, tree ptr, uns if (!decl_to_stridxlist_htab) return 0; - base = get_addr_base_and_unit_offset (exp, &off); - if (base == NULL || !DECL_P (base)) + poly_int64 poff; + base = get_addr_base_and_unit_offset (exp, &poff); + if (base == NULL || !DECL_P (base) || !poff.is_constant (&off)) return 0; list = decl_to_stridxlist_htab->get (base); @@ -368,8 +369,9 @@ addr_stridxptr (tree exp) { HOST_WIDE_INT off; - tree base = get_addr_base_and_unit_offset (exp, &off); - if (base == NULL_TREE || !DECL_P (base)) + poly_int64 poff; + tree base = get_addr_base_and_unit_offset (exp, &poff); + if (base == NULL_TREE || !DECL_P (base) || !poff.is_constant (&off)) return NULL; if (!decl_to_stridxlist_htab) Index: gcc/tree.c =================================================================== --- gcc/tree.c 2017-10-23 17:11:40.252960525 +0100 +++ gcc/tree.c 2017-10-23 17:17:01.436033953 +0100 @@ -4903,7 +4903,7 @@ build5 (enum tree_code code, tree tt, tr tree build_simple_mem_ref_loc (location_t loc, tree ptr) { - HOST_WIDE_INT offset = 0; + poly_int64 offset = 0; tree ptype = TREE_TYPE (ptr); tree tem; /* For convenience allow addresses that collapse to a simple base