From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117840 invoked by alias); 6 Dec 2017 18:50:43 -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 117829 invoked by uid 89); 6 Dec 2017 18:50:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Dec 2017 18:50:41 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF51F13AA6; Wed, 6 Dec 2017 18:50:39 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-2.rdu2.redhat.com [10.10.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4D395C1A3; Wed, 6 Dec 2017 18:50:38 +0000 (UTC) Subject: Re: [025/nnn] poly_int: SUBREG_BYTE To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org References: <871sltvm7r.fsf@linaro.org> <87vaj5pz81.fsf@linaro.org> From: Jeff Law Message-ID: Date: Wed, 06 Dec 2017 18:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <87vaj5pz81.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00335.txt.bz2 On 10/23/2017 11:10 AM, Richard Sandiford wrote: > This patch changes SUBREG_BYTE from an int to a poly_int. > Since valid SUBREG_BYTEs must be contained within the mode of the > SUBREG_REG, the required range is the same as for GET_MODE_SIZE, > i.e. unsigned short. The patch therefore uses poly_uint16(_pod) > for the SUBREG_BYTE. > > Using poly_uint16_pod rtx fields requires a new field code ('p'). > Since there are no other uses of 'p' besides SUBREG_BYTE, the patch > doesn't add an XPOLY or whatever; all uses should go via SUBREG_BYTE > instead. > > The patch doesn't bother implementing 'p' support for legacy > define_peepholes, since none of the remaining ones have subregs > in their patterns. > > As it happened, the rtl documentation used SUBREG as an example of a > code with mixed field types, accessed via XEXP (x, 0) and XINT (x, 1). > Since there's no direct replacement for XINT, and since people should > never use it even if there were, the patch changes the example to use > INT_LIST instead. > > The patch also changes subreg-related helper functions so that they too > take and return polynomial offsets. This makes the patch quite big, but > it's mostly mechanical. The patch generally sticks to existing choices > wrt signedness. > > > 2017-10-23 Richard Sandiford > Alan Hayward > David Sherwood > > gcc/ > * doc/rtl.texi: Update documentation of SUBREG_BYTE. Document the > 'p' format code. Use INT_LIST rather than SUBREG as the example of > a code with an XINT and an XEXP. Remove the implication that > accessing an rtx field using XINT is expected to work. > * rtl.def (SUBREG): Change format from "ei" to "ep". > * rtl.h (rtunion::rt_subreg): New field. > (XCSUBREG): New macro. > (SUBREG_BYTE): Use it. > (subreg_shape): Change offset from an unsigned int to a poly_uint16. > Update constructor accordingly. > (subreg_shape::operator ==): Update accordingly. > (subreg_shape::unique_id): Return an unsigned HOST_WIDE_INT rather > than an unsigned int. > (subreg_lsb, subreg_lowpart_offset, subreg_highpart_offset): Return > a poly_uint64 rather than an unsigned int. > (subreg_lsb_1): Likewise. Take the offset as a poly_uint64 rather > than an unsigned int. > (subreg_size_offset_from_lsb, subreg_size_lowpart_offset) > (subreg_size_highpart_offset): Return a poly_uint64 rather than > an unsigned int. Take the sizes as poly_uint64s. > (subreg_offset_from_lsb): Return a poly_uint64 rather than > an unsigned int. Take the shift as a poly_uint64 rather than > an unsigned int. > (subreg_regno_offset, subreg_offset_representable_p): Take the offset > as a poly_uint64 rather than an unsigned int. > (simplify_subreg_regno): Likewise. > (byte_lowpart_offset): Return the memory offset as a poly_int64 > rather than an int. > (subreg_memory_offset): Likewise. Take the subreg offset as a > poly_uint64 rather than an unsigned int. > (simplify_subreg, simplify_gen_subreg, subreg_get_info) > (gen_rtx_SUBREG, validate_subreg): Take the subreg offset as a > poly_uint64 rather than an unsigned int. > * rtl.c (rtx_format): Describe 'p' in comment. > (copy_rtx, rtx_equal_p_cb, rtx_equal_p): Handle 'p'. > * emit-rtl.c (validate_subreg, gen_rtx_SUBREG): Take the subreg > offset as a poly_uint64 rather than an unsigned int. > (byte_lowpart_offset): Return the memory offset as a poly_int64 > rather than an int. > (subreg_memory_offset): Likewise. Take the subreg offset as a > poly_uint64 rather than an unsigned int. > (subreg_size_lowpart_offset, subreg_size_highpart_offset): Take the > mode sizes as poly_uint64s rather than unsigned ints. Return a > poly_uint64 rather than an unsigned int. > (subreg_lowpart_p): Treat subreg offsets as poly_ints. > (copy_insn_1): Handle 'p'. > * rtlanal.c (set_noop_p): Treat subregs offsets as poly_uint64s. > (subreg_lsb_1): Take the subreg offset as a poly_uint64 rather than > an unsigned int. Return the shift in the same way. > (subreg_lsb): Return the shift as a poly_uint64 rather than an > unsigned int. > (subreg_size_offset_from_lsb): Take the sizes and shift as > poly_uint64s rather than unsigned ints. Return the offset as > a poly_uint64. > (subreg_get_info, subreg_regno_offset, subreg_offset_representable_p) > (simplify_subreg_regno): Take the offset as a poly_uint64 rather than > an unsigned int. > * rtlhash.c (add_rtx): Handle 'p'. > * genemit.c (gen_exp): Likewise. > * gengenrtl.c (type_from_format, gendef): Likewise. > * gensupport.c (subst_pattern_match, get_alternatives_number) > (collect_insn_data, alter_predicate_for_insn, alter_constraints) > (subst_dup): Likewise. > * gengtype.c (adjust_field_rtx_def): Likewise. > * genrecog.c (find_operand, find_matching_operand, validate_pattern) > (match_pattern_2): Likewise. > (rtx_test::SUBREG_FIELD): New rtx_test::kind_enum. > (rtx_test::subreg_field): New function. > (operator ==, safe_to_hoist_p, transition_parameter_type) > (print_nonbool_test, print_test): Handle SUBREG_FIELD. > * genattrtab.c (attr_rtx_1): Say that 'p' is deliberately not handled. > * genpeep.c (match_rtx): Likewise. > * print-rtl.c (print_poly_int): Include if GENERATOR_FILE too. > (rtx_writer::print_rtx_operand): Handle 'p'. > (print_value): Handle SUBREG. > * read-rtl.c (apply_int_iterator): Likewise. > (rtx_reader::read_rtx_operand): Handle 'p'. > * alias.c (rtx_equal_for_memref_p): Likewise. > * cselib.c (rtx_equal_for_cselib_1, cselib_hash_rtx): Likewise. > * caller-save.c (replace_reg_with_saved_mem): Treat subreg offsets > as poly_ints. > * calls.c (expand_call): Likewise. > * combine.c (combine_simplify_rtx, expand_field_assignment): Likewise. > (make_extraction, gen_lowpart_for_combine): Likewise. > * loop-invariant.c (hash_invariant_expr_1, invariant_expr_equal_p): > Likewise. > * cse.c (remove_invalid_subreg_refs): Take the offset as a poly_uint64 > rather than an unsigned int. Treat subreg offsets as poly_ints. > (exp_equiv_p): Handle 'p'. > (hash_rtx_cb): Likewise. Treat subreg offsets as poly_ints. > (equiv_constant, cse_insn): Treat subreg offsets as poly_ints. > * dse.c (find_shift_sequence): Likewise. > * dwarf2out.c (rtl_for_decl_location): Likewise. > * expmed.c (extract_low_bits): Likewise. > * expr.c (emit_group_store, undefined_operand_subword_p): Likewise. > (expand_expr_real_2): Likewise. > * final.c (alter_subreg): Likewise. > (leaf_renumber_regs_insn): Handle 'p'. > * function.c (assign_parm_find_stack_rtl, assign_parm_setup_stack): > Treat subreg offsets as poly_ints. > * fwprop.c (forward_propagate_and_simplify): Likewise. > * ifcvt.c (noce_emit_move_insn, noce_emit_cmove): Likewise. > * ira.c (get_subreg_tracking_sizes): Likewise. > * ira-conflicts.c (go_through_subreg): Likewise. > * ira-lives.c (process_single_reg_class_operands): Likewise. > * jump.c (rtx_renumbered_equal_p): Likewise. Handle 'p'. > * lower-subreg.c (simplify_subreg_concatn): Take the subreg offset > as a poly_uint64 rather than an unsigned int. > (simplify_gen_subreg_concatn, resolve_simple_move): Treat > subreg offsets as poly_ints. > * lra-constraints.c (operands_match_p): Handle 'p'. > (match_reload, curr_insn_transform): Treat subreg offsets as poly_ints. > * lra-spills.c (assign_mem_slot): Likewise. > * postreload.c (move2add_valid_value_p): Likewise. > * recog.c (general_operand, indirect_operand): Likewise. > * regcprop.c (copy_value, maybe_mode_change): Likewise. > (copyprop_hardreg_forward_1): Likewise. > * reginfo.c (simplifiable_subregs_hasher::hash, simplifiable_subregs) > (record_subregs_of_mode): Likewise. > * rtlhooks.c (gen_lowpart_general, gen_lowpart_if_possible): Likewise. > * reload.c (operands_match_p): Handle 'p'. > (find_reloads_subreg_address): Treat subreg offsets as poly_ints. > * reload1.c (alter_reg, choose_reload_regs): Likewise. > (compute_reload_subreg_offset): Likewise, and return an poly_int64. > * simplify-rtx.c (simplify_truncation, simplify_binary_operation_1): > (test_vector_ops_duplicate): Treat subreg offsets as poly_ints. > (simplify_const_poly_int_tests::run): Likewise. > (simplify_subreg, simplify_gen_subreg): Take the subreg offset as > a poly_uint64 rather than an unsigned int. > * valtrack.c (debug_lowpart_subreg): Likewise. > * var-tracking.c (var_lowpart): Likewise. > (loc_cmp): Handle 'p'. > > Index: gcc/rtlanal.c [ ... Going to assume these bits are right WRT the endianness bits ...] > - unsigned int lower_word_part = lower_bytes & -UNITS_PER_WORD; > - unsigned int upper_word_part = upper_bytes & -UNITS_PER_WORD; > + /* When bytes and words have oppposite endianness, we must be able Nit. Oppposite OK with nit fixed. jeff