[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 --- Comment #10 from vries at gcc dot gnu.org --- Author: vries Date: Wed May 13 09:06:18 2015 New Revision: 223120 URL: https://gcc.gnu.org/viewcvs?rev=223120root=gccview=rev Log: Gimplify va_arg ap based on do_deref 2015-05-13 Tom de Vries t...@codesourcery.com PR tree-optimization/66010 * gimplify.h (gimplify_va_arg_internal): Remove declaration. * gimplify.c (gimplify_va_arg_internal): Remove and inline into ... * tree-stdarg.c (expand_ifn_va_arg_1): ... here. Choose between lval and rval based on do_deref. Modified: trunk/gcc/ChangeLog trunk/gcc/gimplify.c trunk/gcc/gimplify.h trunk/gcc/tree-stdarg.c
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 --- Comment #11 from vries at gcc dot gnu.org --- FTR, patch submission for follow-up patch: https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01178.html .
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 --- Comment #8 from vries at gcc dot gnu.org --- Author: vries Date: Tue May 12 09:46:47 2015 New Revision: 223054 URL: https://gcc.gnu.org/viewcvs?rev=223054root=gccview=rev Log: Don't take address of ap unless necessary 2015-05-12 Tom de Vries t...@codesourcery.com PR tree-optimization/66010 * gimplify.c (gimplify_modify_expr): Handle new do_deref argument of ifn_va_arg. * gimplify.h (gimplify_va_arg_internal): Remove loc parameter. (gimplify_va_arg_internal): Remove loc parameter. Assert no array-typed va_lists are passed, and remove corresponding handling. (gimplify_va_arg_expr): Only take address of ap if necessary. Add do_deref argument to ifn_va_arg. * tree-stdarg.c (expand_ifn_va_arg_1): Handle new do_deref argument of ifn_va_arg. * c-common.c (build_va_arg): Don't mark ap addressable unless necessary. * gcc.dg/tree-ssa/stdarg-2.c: Undo scan xfails for f15. Modified: trunk/gcc/ChangeLog trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/gimplify.c trunk/gcc/gimplify.h trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c trunk/gcc/tree-stdarg.c
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 vries at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #9 from vries at gcc dot gnu.org --- Patch committed, marking resolved fixed.
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 vries at gcc dot gnu.org changed: What|Removed |Added Keywords||patch --- Comment #7 from vries at gcc dot gnu.org --- https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00742.html
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 Richard Biener rguenth at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-05-06 Target Milestone|--- |6.0 Ever confirmed|0 |1 --- Comment #5 from Richard Biener rguenth at gcc dot gnu.org --- apD.1859 = apD.1844; # .MEM_7 = VDEF .MEM_3 # USE = nonlocal null { D.1844 D.1859 } (escaped) # CLB = nonlocal null { D.1844 D.1859 } (escaped) _6 = VA_ARG (apD.1859, this also looks like double-indirection (and thus wrong-code?) Note that I'd defer all possible optimization issues to _after_ re-writing the stdarg pass to take advantage of va_arg not being lowered.
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 --- Comment #6 from vries at gcc dot gnu.org --- Created attachment 35480 -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35480action=edit Tentative patch (In reply to Richard Biener from comment #5) apD.1859 = apD.1844; # .MEM_7 = VDEF .MEM_3 # USE = nonlocal null { D.1844 D.1859 } (escaped) # CLB = nonlocal null { D.1844 D.1859 } (escaped) _6 = VA_ARG (apD.1859, this also looks like double-indirection (and thus wrong-code?) It looks wrong to me as well, but I haven't seen any wrong generated code as a consequence. There's some fixup code in gimplify_va_arg_internal, that adds an occasional addr expression, I suspect this bit is handling (or balancing out) this extra indirection: ... /* For this case, the backends will be expecting a pointer to TREE_TYPE (abi), but it's possible we've actually been given an array (an actual TARGET_FN_ABI_VA_LIST). So fix it. */ if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE) { tree p1 = build_pointer_type (TREE_TYPE (have_va_type)); valist = fold_convert_loc (loc, p1, build_fold_addr_expr_loc (loc, valist)); } gimplify_expr (valist, pre_p, post_p, is_gimple_val, fb_rvalue); ... Note that I'd defer all possible optimization issues to _after_ re-writing the stdarg pass to take advantage of va_arg not being lowered. Right. But the double indirection is suspicious, so I tried to get rid of it. Attached tentative patch achieves this. It manages to generate: ... f2_1 (struct * ap) { intD.6 D.1852; # USE = anything # CLB = anything D.1852 = VA_ARG (apD.1837, 0B, 0); return D.1852; } ... And after early inlinling we get in f2: ... # .MEM_2 = VDEF .MEM_1(D) # USE = anything # CLB = anything __builtin_va_startD.1030 (apD.1844, 0); # .MEM_3 = VDEF .MEM_2 # USE = anything # CLB = anything _8 = VA_ARG (apD.1844, 0B, 0); ... That fixes this PR: ... f2: va_list escapes 0, needs to save 8 GPR units and 0 FPR units. ...
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 --- Comment #4 from vries at gcc dot gnu.org --- Investigated -m32 case in twin PR66013.
[Bug tree-optimization/66010] [6 Regression] Missed optimization after inlining va_list parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66010 vries at gcc dot gnu.org changed: What|Removed |Added Summary|Missed optimization after |[6 Regression] Missed |inlining va_list parameter |optimization after inlining ||va_list parameter --- Comment #3 from vries at gcc dot gnu.org --- Before postponing expansion of va_arg to pass_stdarg, we had at pass_stdarg: ... f2: va_list escapes 0, needs to save 8 GPR units and 0 FPR units. Pass statistics: f2 (intD.6 iD.1840) { struct apD.1844[1]; unsigned intD.9 _6; voidD.41 * _7; sizetype _8; voidD.41 * addr.1_9; unsigned intD.9 _10; voidD.41 * _11; voidD.41 * _12; voidD.41 * addr.1_13; intD.6 _14; ;; basic block 2, loop depth 0, count 0, freq 1, maybe hot ;;prev block 0, next block 3, flags: (NEW, REACHABLE) ;;pred: ENTRY [100.0%] (FALLTHRU,EXECUTABLE) # .MEM_2 = VDEF .MEM_1(D) # USE = nonlocal escaped # CLB = nonlocal escaped { D.1844 } __builtin_va_startD.1030 (apD.1844, 0); # VUSE .MEM_2 _6 = MEM[(struct *)apD.1844].gp_offsetD.2; ... Already after early inline, we have the desired: ... # .MEM_2 = VDEF .MEM_1(D) # USE = anything # CLB = anything __builtin_va_startD.1030 (apD.1844, 0); # VUSE .MEM_2 _8 = MEM[(struct *)apD.1844].gp_offsetD.2; ... So, this is a regression.