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

            Bug ID: 80237
           Summary: float to double conversion is not optimized away
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

i get suboptimal code for

__attribute__((noinline))
static float f(float x)
{
  return x*x;
}

static double g(float x)
{
  return x>0 ? f(x) : x+1.0;
}

float foo(float x)
{
  return g(x);
}

i expected a tail call because for float x, (float)(double)x conversion is a
nop, but with -O3 i get

f:
        mulss   %xmm0, %xmm0
        ret
foo:
        ucomiss .LC0(%rip), %xmm0
        jbe     .L8
        call    f     ///////////////// why not tail call?
        cvtss2sd        %xmm0, %xmm0
        cvtsd2ss        %xmm0, %xmm0
        ret
.L8:
        cvtss2sd        %xmm0, %xmm0
        addsd   .LC1(%rip), %xmm0
        cvtsd2ss        %xmm0, %xmm0
        ret
.LC0:
        .long   0
.LC1:
        .long   0
        .long   1072693248

Reply via email to