[Bug c++/12558] New: structure not returned in xmm0 & xmm1

kong at ece dot ucdavis dot edu gcc-bugzilla@gcc.gnu.org
Thu Oct 9 21:47:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12558

           Summary: structure not returned in xmm0 & xmm1
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kong at ece dot ucdavis dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86-*-linux
  GCC host triplet: x86-*-linux
GCC target triplet: x86_64-*-linux

In the C++ program below, "g++ -S" (no optimzation) produces assembler code
where the function "ggPoint2 operator+" does not return the ggPoint2 structure
in the function return value registers xmm0 and xmm1, even though the ggPoint2
structure (double e[2]) fits in xmm0 and xmm1.  However, if the source line as
indicated below is commented out, the assembler code does return the structure
in xmm0 and xmm1.

Even with this bug, the program compiled by g++ was able to run correctly
because although the wrong ABI was used, it was used consistently throughout
the program.

class ggVector2 {
public:
    ggVector2() { e[0] = 1.0; e[0] = 0.0; }
    double e[2];
};

class ggPoint2 {
public:
    ggPoint2(double e0, double e1) {e[0] = e0; e[1] = e1;}

    ggPoint2(const ggPoint2& p) {}      // comment out this line will produce
                                        // correct code
    double e[2];
};

inline ggPoint2 operator+(const ggPoint2 &p, const ggVector2 &v) {
    return ggPoint2(1.0, 2.0);
}

ggPoint2
foo(const int &a, const int &b, const ggPoint2& pin)
{
  ggVector2 v;
  return pin + v;
}



More information about the Gcc-bugs mailing list