Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use subscalar mode to move struct block for parameter
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". On some targets(ppc64), for below case: ////case3.c typedef struct SA {double a[3]; long l; } A; A ret_arg_pt (A *a) {return *a;} The optimized GIMPLE code looks like: <retval> = *a_2(D); return <retval>; Here, <retval>(aka. RESULT_DECL) is MEM, and "aggregate_value_p" returns true for <retval>. * While for below case, the generated code is still suboptimal. ////case4.c typedef struct SA {double a[3];} A; A ret_arg_pt (A *a) {return *a;} The optimized GIMPLE code looks like: D.3951 = *a_2(D); return D.3951; The "return/assign" stmts are using D.3951(VAR_DECL) instead "<retval>(RESULT_DECL)". The mode of D.3951/<retval> is BLK. The RTL of D.3951 is MEM, and RTL of <retval> is PARALLEL. For PARALLEL, aggregate_value_p returns false. In function expand_assignment, there is code: if (TREE_CODE (to) == RESULT_DECL && (REG_P (to_rtx) || GET_CODE (to_rtx) == PARALLEL)) This code can handle "<retval>", but can not handle "D.3951". I'm thinking of one way to handle this issue is to update the GIMPLE sequence as: "<retval> = *a_2(D); return <retval>;" Or, collecting VARs which are used by return stmts; and for assignments to those VARs, using sub scalar mode for the block move. Thanks for any comments and suggestions! BR, Jeff (Jiufu)
- Loading branch information