From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53511 invoked by alias); 18 Nov 2017 15:03:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 53465 invoked by uid 89); 18 Nov 2017 15:03:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 18 Nov 2017 15:03:17 +0000 Received: by mail-wr0-f181.google.com with SMTP id k61so4436128wrc.4 for ; Sat, 18 Nov 2017 07:03:16 -0800 (PST) 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:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version; bh=M7dyAXoentPqFbHYAIUUDuyV0uKXQB4MKsBFIoMOaWc=; b=QeD+k/MnY1zfw8fC1RXPsd2d+/TJtirOd4jjN3yLS0pL+aelkJhYRWt2niHv5fbWRt CRKRTfAYfHtCN/5Lff4TdElGOMMZVnOx8qhil+ybsn1s7y9tvNm35JCMapRWTRDX0Gpf y4zYePSgPTsIjTtYkDyCDdTcfRE8WODT0IVmUI6d1pymlZptXmzA2qNsRVxQo/pQhEId lR1UwOAY7sXavMOa2hGAEUMHYFFMxBFS0cI6S/A2V1TJTdqV+gKOYxa1Ptm+tx9PjwEg df+gw7nzi1I/c+ognJXpjTZrM4PpE3dbYWeu3NHr49uH9gwJZlsZYAV/vuyFiZj3K63X XamQ== X-Gm-Message-State: AJaThX5X/sxKoN2ed0uhLucRM3w/FFuzGzCSbjZ403A/nVAk6cfGu47X VJq0xpPyFmV+Ep55FzbGIGhBjZfLXMY= X-Google-Smtp-Source: AGs4zMbySTEqE4WLkipcamV1uqYptap4D+w0qokt0DJFyN0yBH5wqjWsBpE6w7B3S5YlycAoHHSh1g== X-Received: by 10.223.175.100 with SMTP id z91mr6734979wrc.138.1511017394943; Sat, 18 Nov 2017 07:03:14 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id j21sm4112497wre.86.2017.11.18.07.03.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Nov 2017 07:03:13 -0800 (PST) From: Richard Sandiford To: Jeff Law Mail-Followup-To: Jeff Law ,gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Cc: gcc-patches@gcc.gnu.org Subject: Re: [006/nnn] poly_int: tree constants References: <871sltvm7r.fsf@linaro.org> <878tg1u7cl.fsf@linaro.org> <3d08f0fa-512b-2c47-c204-2827de1cb036@redhat.com> Date: Sat, 18 Nov 2017 15:48:00 -0000 In-Reply-To: <3d08f0fa-512b-2c47-c204-2827de1cb036@redhat.com> (Jeff Law's message of "Thu, 16 Nov 2017 21:11:24 -0700") Message-ID: <87vai7vdcf.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2017-11/txt/msg01633.txt.bz2 Jeff Law writes: > On 10/23/2017 11:00 AM, Richard Sandiford wrote: >> This patch adds a tree representation for poly_ints. Unlike the >> rtx version, the coefficients are INTEGER_CSTs rather than plain >> integers, so that we can easily access them as poly_widest_ints >> and poly_offset_ints. >> >> The patch also adjusts some places that previously >> relied on "constant" meaning "INTEGER_CST". It also makes >> sure that the TYPE_SIZE agrees with the TYPE_SIZE_UNIT for >> vector booleans, given the existing: >> >> /* Several boolean vector elements may fit in a single unit. */ >> if (VECTOR_BOOLEAN_TYPE_P (type) >> && type->type_common.mode != BLKmode) >> TYPE_SIZE_UNIT (type) >> = size_int (GET_MODE_SIZE (type->type_common.mode)); >> else >> TYPE_SIZE_UNIT (type) = int_const_binop (MULT_EXPR, >> TYPE_SIZE_UNIT (innertype), >> size_int (nunits)); >> >> >> 2017-10-23 Richard Sandiford >> Alan Hayward >> David Sherwood >> >> gcc/ >> * doc/generic.texi (POLY_INT_CST): Document. >> * tree.def (POLY_INT_CST): New tree code. >> * treestruct.def (TS_POLY_INT_CST): New tree layout. >> * tree-core.h (tree_poly_int_cst): New struct. >> (tree_node): Add a poly_int_cst field. >> * tree.h (POLY_INT_CST_P, POLY_INT_CST_COEFF): New macros. >> (wide_int_to_tree, force_fit_type): Take a poly_wide_int_ref >> instead of a wide_int_ref. >> (build_int_cst, build_int_cst_type): Take a poly_int64 instead >> of a HOST_WIDE_INT. >> (build_int_cstu, build_array_type_nelts): Take a poly_uint64 >> instead of an unsigned HOST_WIDE_INT. >> (build_poly_int_cst, tree_fits_poly_int64_p, tree_fits_poly_uint64_p) >> (ptrdiff_tree_p): Declare. >> (tree_to_poly_int64, tree_to_poly_uint64): Likewise. Provide >> extern inline implementations if the target doesn't use POLY_INT_CST. >> (poly_int_tree_p): New function. >> (wi::unextended_tree): New class. >> (wi::int_traits ): New override. >> (wi::extended_tree): Add a default constructor. >> (wi::extended_tree::get_tree): New function. >> (wi::widest_extended_tree, wi::offset_extended_tree): New typedefs. >> (wi::tree_to_widest_ref, wi::tree_to_offset_ref): Use them. >> (wi::tree_to_poly_widest_ref, wi::tree_to_poly_offset_ref) >> (wi::tree_to_poly_wide_ref): New typedefs. >> (wi::ints_for): Provide overloads for extended_tree and >> unextended_tree. >> (poly_int_cst_value, wi::to_poly_widest, wi::to_poly_offset) >> (wi::to_wide): New functions. >> (wi::fits_to_boolean_p, wi::fits_to_tree_p): Handle poly_ints. >> * tree.c (poly_int_cst_hasher): New struct. >> (poly_int_cst_hash_table): New variable. >> (tree_node_structure_for_code, tree_code_size, simple_cst_equal) >> (valid_constant_size_p, add_expr, drop_tree_overflow): Handle >> POLY_INT_CST. >> (initialize_tree_contains_struct): Handle TS_POLY_INT_CST. >> (init_ttree): Initialize poly_int_cst_hash_table. >> (build_int_cst, build_int_cst_type, build_invariant_address): Take >> a poly_int64 instead of a HOST_WIDE_INT. >> (build_int_cstu, build_array_type_nelts): Take a poly_uint64 >> instead of an unsigned HOST_WIDE_INT. >> (wide_int_to_tree): Rename to... >> (wide_int_to_tree_1): ...this. >> (build_new_poly_int_cst, build_poly_int_cst): New functions. >> (force_fit_type): Take a poly_wide_int_ref instead of a wide_int_ref. >> (wide_int_to_tree): New function that takes a poly_wide_int_ref. >> (ptrdiff_tree_p, tree_to_poly_int64, tree_to_poly_uint64) >> (tree_fits_poly_int64_p, tree_fits_poly_uint64_p): New functions. >> * lto-streamer-out.c (DFS::DFS_write_tree_body, hash_tree): Handle >> TS_POLY_INT_CST. >> * tree-streamer-in.c (lto_input_ts_poly_tree_pointers): Likewise. >> (streamer_read_tree_body): Likewise. >> * tree-streamer-out.c (write_ts_poly_tree_pointers): Likewise. >> (streamer_write_tree_body): Likewise. >> * tree-streamer.c (streamer_check_handled_ts_structures): Likewise. >> * asan.c (asan_protect_global): Require the size to be an INTEGER_CST. >> * cfgexpand.c (expand_debug_expr): Handle POLY_INT_CST. >> * expr.c (const_vector_element, expand_expr_real_1): Likewise. >> * gimple-expr.h (is_gimple_constant): Likewise. >> * gimplify.c (maybe_with_size_expr): Likewise. >> * print-tree.c (print_node): Likewise. >> * tree-data-ref.c (data_ref_compare_tree): Likewise. >> * tree-pretty-print.c (dump_generic_node): Likewise. >> * tree-ssa-address.c (addr_for_mem_ref): Likewise. >> * tree-vect-data-refs.c (dr_group_sort_cmp): Likewise. >> * tree-vrp.c (compare_values_warnv): Likewise. >> * tree-ssa-loop-ivopts.c (determine_base_object, constant_multiple_of) >> (get_loop_invariant_expr, add_candidate_1, get_computation_aff_1) >> (force_expr_to_var_cost): Likewise. >> * tree-ssa-loop.c (for_each_index): Likewise. >> * fold-const.h (build_invariant_address, size_int_kind): Take a >> poly_int64 instead of a HOST_WIDE_INT. >> * fold-const.c (fold_negate_expr_1, const_binop, const_unop) >> (fold_convert_const, multiple_of_p, fold_negate_const): Handle >> POLY_INT_CST. >> (size_binop_loc): Likewise. Allow int_const_binop_1 to fail. >> (int_const_binop_2): New function, split out from... >> (int_const_binop_1): ...here. Handle POLY_INT_CST. >> (size_int_kind): Take a poly_int64 instead of a HOST_WIDE_INT. >> * expmed.c (make_tree): Handle CONST_POLY_INT_P. >> * gimple-ssa-strength-reduction.c (slsr_process_add) >> (slsr_process_mul): Check for INTEGER_CSTs before using them >> as candidates. >> * stor-layout.c (bits_from_bytes): New function. >> (bit_from_pos): Use it. >> (layout_type): Likewise. For vectors, multiply the TYPE_SIZE_UNIT >> by BITS_PER_UNIT to get the TYPE_SIZE. >> * tree-cfg.c (verify_expr, verify_types_in_gimple_reference): Allow >> MEM_REF and TARGET_MEM_REF offsets to be a POLY_INT_CST. >> >> Index: gcc/tree.h >> =================================================================== >> --- gcc/tree.h 2017-10-23 16:52:20.504766418 +0100 >> +++ gcc/tree.h 2017-10-23 17:00:57.784962010 +0100 >> @@ -5132,6 +5195,29 @@ extern bool anon_aggrname_p (const_tree) >> /* The tree and const_tree overload templates. */ >> namespace wi >> { >> + class unextended_tree >> + { >> + private: >> + const_tree m_t; >> + >> + public: >> + unextended_tree () {} >> + unextended_tree (const_tree t) : m_t (t) {} >> + >> + unsigned int get_precision () const; >> + const HOST_WIDE_INT *get_val () const; >> + unsigned int get_len () const; >> + const_tree get_tree () const { return m_t; } >> + }; >> + >> + template <> >> + struct int_traits >> + { >> + static const enum precision_type precision_type = VAR_PRECISION; >> + static const bool host_dependent_precision = false; >> + static const bool is_sign_extended = false; >> + }; >> + >> template >> class extended_tree >> { >> @@ -5139,11 +5225,13 @@ extern bool anon_aggrname_p (const_tree) >> const_tree m_t; >> >> public: >> + extended_tree () {} >> extended_tree (const_tree); >> >> unsigned int get_precision () const; >> const HOST_WIDE_INT *get_val () const; >> unsigned int get_len () const; >> + const_tree get_tree () const { return m_t; } >> }; > Similarly I'll defer on part of the patch since the empty ctors play > into the initialization question that's still on the table. FWIW, I'd expect these two constructors to go away if we switch to C++11 in future, rather than become "() = default". We only really need them because of C++03 restrictions. > Otherwise this is OK. Thanks, Richard