From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 67CFE3858C20; Tue, 22 Nov 2022 21:57:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67CFE3858C20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1030.google.com with SMTP id b11so14362519pjp.2; Tue, 22 Nov 2022 13:57:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=RzlA0dip0HYpajuGF2wGYW8XKF4pLGY4Wcf0QSHjcn4=; b=HnogDkrDoxxMmIjgia6ADiI7A1O4mTWyow3xhYL2RiBlsOdLn6pUNMO/gBBT8l1cac dvhIhrvIbXyffoWFHz5NF47LMpyv8Pf0Beis3CVQvOdqBWDgdYeQJTMQ786kSnblO08v OgApNpOiffsnWF90os4AXiGJlzMeoFBLSaxQVjmyst29AtaRrz5V8kuoOT/qt8Ofy6Js hIMpZNGK5DKHzR+rMsOBMa/ioxi+RVPBByUxcnsUHT8/6e+GfzzIf8qcevUBrDCdwEOy cNMZeTiWbw1ksU+i6RkemJUdU66pzlj+uyik8U9Q/IufVmuJtX1wAPtHFwJMGYfZ5uNO 5PZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RzlA0dip0HYpajuGF2wGYW8XKF4pLGY4Wcf0QSHjcn4=; b=dKbJICdZPMYSXbVGsMhHDYBL6846aEhmc3s/TlTguK0LGGURnj8BrOvDXpKoZcyACo jgXdxi+A7QoqFAv3eCSOYNkq9ss0NwBN8yjsVEuWZaPAnTJsqlFRXgDK/Nbnir2HirBv 0KUxVSr2rShb/5ybuBmY1imucc1VnH6LRuD2apimaVj6obuEED3l3lwKxKksxsvg+8s2 J2zDGVfTWctamX0YJPiT6rZ4Vo3YJAb/i3F+HP9AszuxRFaSs9Vtcf/dVk2D2gJRDhwq VDhYgMH3oyafMgMqfTUZKDS/+g5/zkySRa4mQ9/WTHCZUL/axnSqlYTN3UwgKFlajy7x 6e0g== X-Gm-Message-State: ANoB5pmhpDaozLuKxjPw7JHXnlkcYZuYvHCYKfR1RSeG7uFyAMp95x9c cqecMVIFDIkRb2OZeRwK3Jw= X-Google-Smtp-Source: AA0mqf6NMF1g4KX56aDWwsNf0WvtxFZS9X+7B4lzpUmRHgeQiH22WS0J3udtnn2H7i7Npci/hrPb4w== X-Received: by 2002:a17:903:2109:b0:186:8d7b:377e with SMTP id o9-20020a170903210900b001868d7b377emr6549424ple.19.1669154231077; Tue, 22 Nov 2022 13:57:11 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::99f? ([2601:681:8600:13d0::99f]) by smtp.gmail.com with ESMTPSA id 185-20020a6214c2000000b005618189b0ffsm11160339pfu.104.2022.11.22.13.57.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 13:57:10 -0800 (PST) Message-ID: <9424d98e-a95f-58ae-9764-bcf8b4f503dc@gmail.com> Date: Tue, 22 Nov 2022 14:57:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH V2] Use subscalar mode to move struct block for parameter Content-Language: en-US To: Jiufu Guo , gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, rguenther@suse.de References: <20221117061549.178481-1-guojiufu@linux.ibm.com> <7ea64lroo6.fsf@pike.rch.stglabs.ibm.com> From: Jeff Law In-Reply-To: <7ea64lroo6.fsf@pike.rch.stglabs.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/20/22 20:07, Jiufu Guo wrote: > Jiufu Guo writes: > >> Hi, >> >> As mentioned in the previous version patch: >> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604646.html >> The suboptimal code is generated for "assigning from parameter" or >> "assigning to return value". >> This patch enhances the assignment from parameters like the below >> cases: >> /////case1.c >> typedef struct SA {double a[3];long l; } A; >> A ret_arg (A a) {return a;} >> void st_arg (A a, A *p) {*p = a;} >> >> ////case2.c >> typedef struct SA {double a[3];} A; >> A ret_arg (A a) {return a;} >> void st_arg (A a, A *p) {*p = a;} >> >> For this patch, bootstrap and regtest pass on ppc64{,le} >> and x86_64. >> * Besides asking for help reviewing this patch, I would like to >> consult comments about enhancing for "assigning to returns". > I updated the patch to fix the issue for returns. This patch > adds a flag DECL_USEDBY_RETURN_P to indicate if a var is used > by a return stmt. This patch fix the issue in expand pass only, > so, we would try to update the patch to avoid this flag. > > diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc > index dd29ffffc03..09b8ec64cea 100644 > --- a/gcc/cfgexpand.cc > +++ b/gcc/cfgexpand.cc > @@ -2158,6 +2158,20 @@ expand_used_vars (bitmap forced_stack_vars) > frame_phase = off ? align - off : 0; > } > > + /* Collect VARs on returns. */ > + if (DECL_RESULT (current_function_decl)) > + { > + edge_iterator ei; > + edge e; > + FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) > + if (greturn *ret = safe_dyn_cast (last_stmt (e->src))) > + { > + tree val = gimple_return_retval (ret); > + if (val && VAR_P (val)) > + DECL_USEDBY_RETURN_P (val) = 1; > + } > + } > + > /* Set TREE_USED on all variables in the local_decls. */ > FOR_EACH_LOCAL_DECL (cfun, i, var) > TREE_USED (var) = 1; > diff --git a/gcc/expr.cc b/gcc/expr.cc > index d9407432ea5..20973649963 100644 > --- a/gcc/expr.cc > +++ b/gcc/expr.cc > @@ -6045,6 +6045,52 @@ expand_assignment (tree to, tree from, bool nontemporal) > return; > } > > + if ((TREE_CODE (from) == PARM_DECL && DECL_INCOMING_RTL (from) > + && TYPE_MODE (TREE_TYPE (from)) == BLKmode > + && (GET_CODE (DECL_INCOMING_RTL (from)) == PARALLEL > + || REG_P (DECL_INCOMING_RTL (from)))) > + || (VAR_P (to) && DECL_USEDBY_RETURN_P (to) > + && TYPE_MODE (TREE_TYPE (to)) == BLKmode > + && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) > + == PARALLEL)) > + { > + push_temp_slots (); > + rtx par_ret; > + machine_mode mode; > + par_ret = TREE_CODE (from) == PARM_DECL > + ? DECL_INCOMING_RTL (from) > + : DECL_RTL (DECL_RESULT (current_function_decl)); > + mode = GET_CODE (par_ret) == PARALLEL > + ? GET_MODE (XEXP (XVECEXP (par_ret, 0, 0), 0)) > + : word_mode; > + int mode_size = GET_MODE_SIZE (mode).to_constant (); > + int size = INTVAL (expr_size (from)); > + > + /* If/How the parameter using submode, it dependes on the size and > + position of the parameter. Here using heurisitic number. */ > + int hurstc_num = 8; Where did this come from and what does it mean? Note that BLKmode subword values passed in registers can be either right or left justified.  I think you also need to worry about endianness here. Jeff