Bug 32686 - Code to convert double to _Complex double for arguments passing is not good (extra load)
Summary: Code to convert double to _Complex double for arguments passing is not good (...
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: missed-optimization
Depends on:
Blocks: 26163
  Show dependency treegraph
Reported: 2007-07-09 03:31 UTC by Andrew Pinski
Modified: 2007-07-09 09:20 UTC (History)
1 user (show)

See Also:
Target: powerpc-darwin
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2007-07-09 03:31:51 UTC
_Complex double f(_Complex double);
_Complex double g(double a)
  return f(a);

----- Cut ----
We currently get:
        mflr r0
        bcl 20,31,"L00000000001$pb"
        stw r31,-4(r1)
        mflr r31
        stfd f1,-24(r1)
        mtlr r0
        lwz r3,-24(r1)
        lwz r4,-20(r1)
        addis r2,r31,ha16(LC0-"L00000000001$pb")
        lwz r31,-4(r1)
        la r5,lo16(LC0-"L00000000001$pb")(r2)
        lwz r6,4(r5)
        lwz r5,0(r5)
        b L_f$stub

We should be able to get:
        stfd f1,-8(r1)
        li r6,0
        li r5,0
        lwz r3,-8(r1)
        lwz r4,-4(r1)
        b L_f$stub

Without the need for the PIC register.
Comment 1 Andrew Pinski 2007-07-09 03:33:37 UTC
powerpc64-darwin is just as bad, we get:
        mflr r0
        std r31,-8(r1)
        stfd f1,-32(r1)
        bcl 20,31,"L00000000001$pb"
        mflr r31
        addis r2,r31,ha16(LC0-"L00000000001$pb")
        mtlr r0
        ld r4,lo16(LC0-"L00000000001$pb")(r2)
        ld r3,-32(r1)
        ld r31,-8(r1)
        b L_f$stub

When we should get:

        stfd f1,-8(r1)
        li r4,0
        ld r3,-8(r1)
        b L_f$stub

With a few nops through in there so we don't reject the distpatch group.