public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/66013] New: Missed optimization after inlining va_list parameter, -m32 case
@ 2015-05-05  7:24 vries at gcc dot gnu.org
  2015-05-05  7:33 ` [Bug tree-optimization/66013] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2015-05-05  7:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66013

            Bug ID: 66013
           Summary: Missed optimization after inlining va_list parameter,
                    -m32 case
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ -m32 twin PR of PR66010 ]

Consider this test-case (based on gcc.dg/tree-ssa/stdarg-2.c, f15):
...
#include <stdarg.h>

int
f1 (int i, ...)
{
  int res;
  va_list ap;

  va_start (ap, i);
  res = va_arg (ap, int);
  va_end (ap);

  return res;
}

inline int __attribute__((always_inline))
f2_1 (va_list ap)
{
  return va_arg (ap, int);
}

int
f2 (int i, ...)
{
  int res;
  va_list ap;

  va_start (ap, i);
  res = f2_1 (ap);
  va_end (ap);

  return res;
}
...

When compiling at -O2 with -m32, the optimized dump for f1 and f2 are very
similar:
...
   # .MEM_9 = VDEF <.MEM_1(D)>
   # USE = anything 
   # CLB = anything 
-  ap_8 = __builtin_next_argD.993 (0);
-  ap_6 = ap_8;
+  ap_11 = __builtin_next_argD.993 (0);
+  ap_6 = ap_11;
   # PT = nonlocal 
-  ap_7 = ap_6;
+  ap_3 = ap_6;
   # VUSE <.MEM_9>
-  res_4 = MEM[(intD.1 *)ap_7];
+  _7 = MEM[(intD.1 *)ap_3];
   GIMPLE_NOP
   # VUSE <.MEM_9>
-  return res_4;
+  return _7;
 ;;    succ:       EXIT [100.0%] 
...

However, at pass_stdarg, we see on one hand:
...
f1: va_list escapes 0, needs to save 4 GPR units and all FPR units.
...

but OTOH:
...
f2: va_list escapes 1, needs to save all GPR units and all FPR units.
...

Still the .s code is identical for f1 and f2:
...
        .cfi_startproc
        movl    8(%esp), %eax
        ret
        .cfi_endproc
...

This is because ix86_setup_incoming_varargs doesn't do anything for -m32:
...
static void
ix86_setup_incoming_varargs (cumulative_args_t cum_v, machine_mode mode,
                             tree type, int *, int no_rtl)
{
  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
  CUMULATIVE_ARGS next_cum;
  tree fntype;

  /* This argument doesn't appear to be used anymore.  Which is good,
     because the old code here didn't suppress rtl generation.  */
  gcc_assert (!no_rtl);

  if (!TARGET_64BIT)
    return;
...


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-06-08 12:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05  7:24 [Bug tree-optimization/66013] New: Missed optimization after inlining va_list parameter, -m32 case vries at gcc dot gnu.org
2015-05-05  7:33 ` [Bug tree-optimization/66013] " vries at gcc dot gnu.org
2015-05-05  7:34 ` vries at gcc dot gnu.org
2015-05-05  7:41 ` vries at gcc dot gnu.org
2015-05-07 22:17 ` vries at gcc dot gnu.org
2015-05-08 15:37 ` vries at gcc dot gnu.org
2015-06-08 12:29 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).