From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46103 invoked by alias); 26 Apr 2015 11:22:37 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 46077 invoked by uid 48); 26 Apr 2015 11:22:33 -0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65893] New: ifcombine not done anymore on expansion of va_arg Date: Sun, 26 Apr 2015 11:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg02218.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65893 Bug ID: 65893 Summary: ifcombine not done anymore on expansion of va_arg Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- I observed the following when investigating the effect of the introduction of ifn_va_arg for aarch64 on stdarg-1.c. At optimized dump, before introduction of ifn_va_arg we have a single comparison (_4 >= -7): ... foo (int v, struct va_list ap) { int * iftmp.0_1; int _4; void * _5; void * _7; sizetype _8; int * iftmp.1_9; int foo_arg.2_10; : switch (v_2(D)) , case 5: > : _4 = ap.__gr_offs; _5 = ap.__stack; if (_4 >= -7) goto ; else goto ; : _7 = ap.__gr_top; _8 = (sizetype) _4; iftmp.1_9 = _7 + _8; : # iftmp.0_1 = PHI <_5(3), iftmp.1_9(4)> foo_arg.2_10 = *iftmp.0_1; foo_arg = foo_arg.2_10; return; : abort (); } ... After introduction of ifn_va_arg, we have two comparisons (ap$__gr_offs_20 >= 0, ap$__gr_offs_20 >= -7): ... foo (int v, struct va_list ap) { int ap$__gr_offs; void * ap$__stack; int * iftmp.28; int * iftmp.29; void * D.2827; sizetype D.2828; int foo_arg.0_4; : switch (v_1(D)) , case 5: > : ap$__stack_26 = MEM[(struct *)&ap]; ap$__gr_offs_20 = MEM[(struct *)&ap + 24B]; if (ap$__gr_offs_20 >= 0) goto ; else goto ; : if (ap$__gr_offs_20 >= -7) goto ; else goto ; : _28 = ap.__gr_top; _29 = (sizetype) ap$__gr_offs_20; iftmp.29_30 = _28 + _29; : # iftmp.29_10 = PHI : # iftmp.28_9 = PHI foo_arg.0_4 = *iftmp.28_9; foo_arg = foo_arg.0_4; return; : abort (); } ... The tree optimization ifcombine can combine the two comparisons, so: 1. Before the introduction of ifn_va_arg, the va_arg is expanded at gimplification, and ifcombine manages to combine the two comparisons. 2. After the introduction of ifn_va_arg, the va_arg is expanded at pass_starg, a few steps after the ifcombine pass, and the optimization does not happen: ... NEXT_PASS (pass_tree_ifcombine); NEXT_PASS (pass_phiopt); NEXT_PASS (pass_tail_recursion); NEXT_PASS (pass_ch); NEXT_PASS (pass_stdarg); ...