Re: Passing the complex args in the GPR's
Hey, On Tue, 6 Jun 2023, Umesh Kalappa via Gcc wrote: > Question is : Why does GCC choose to use GPR's here and have any > reference to support this decision ? You explicitely used -m32 ppc, so https://www.polyomino.org.uk/publications/2011/Power-Arch-32-bit-ABI-supp-1.0-Unified.pdf applies. It explicitely states in "B.1 ATR-Linux Inclusion and Conformance" that it is "ATR-PASS-COMPLEX-IN-GPRS", and other sections detail what that means (namely passing complex args in r3 .. r10, whatever fits). GCC adheres to that, and has to. The history how that came to be was explained in the thread. Ciao, Michael. > > Thank you > ~Umesh > > > > On Tue, Jun 6, 2023 at 10:16 PM Segher Boessenkool > wrote: > > > > Hi! > > > > On Tue, Jun 06, 2023 at 08:35:22PM +0530, Umesh Kalappa wrote: > > > Hi Adnrew, > > > Thank you for the quick response and for PPC64 too ,we do have > > > mismatches in ABI b/w complex operations like > > > https://godbolt.org/z/bjsYovx4c . > > > > > > Any reason why GCC chose to use GPR 's here ? > > > > What did you expect, what happened instead? Why did you expect that, > > and why then is it an error what did happen? > > > > You used -O0. As long as the code works, all is fine. But unoptimised > > code frequently is hard to read, please use -O2 instead? > > > > As Andrew says, why did you use -m32 for GCC but -m64 for LLVM? It is > > hard to compare those at all! 32-bit PowerPC Linux ABI (based on 32-bit > > PowerPC ELF ABI from 1995, BE version) vs. 64-bit ELFv2 ABI from 2015 > > (LE version). > > > > > > Segher >
Re: Passing the complex args in the GPR's
On Tue, Jun 6, 2023 at 1:08 PM Umesh Kalappa via Gcc wrote: > Hi Segher , > > >>What did you expect, what happened instead? > For example the complex args are passed in GPR's for cexp in the case > GCC and Clang uses caller memory . > > for reference : https://godbolt.org/z/MfMz3cTe7 > > We have cross tools like some of libraries built using the GCC and > some use Clang . > > We approached Clang developers on this behaviour (Why stack , not the > FPR's registers like PPC64) and they are not going to change this > behaviour, and asked us to refer back to GCC ,hence this email thread. > > Question is : Why does GCC choose to use GPR's here and have any > reference to support this decision ? > The use of GPRs to pass complex floating point arguments was an early implementation mistake -- the parameter passing code missed the enumeration of a type. The behavior cannot be changed and corrected without breaking the ABI. I don't know what you mean by "support this decision". It was not intentionally chosen through careful performance analysis or type system design as the preferred method to pass complex floating point values. The initial implementation was wrong and not discovered until it was too late. The reference to support this is that one cannot break the ABI without causing chaos in the ecosystem. Thanks, David > > Thank you > ~Umesh > > > > On Tue, Jun 6, 2023 at 10:16 PM Segher Boessenkool > wrote: > > > > Hi! > > > > On Tue, Jun 06, 2023 at 08:35:22PM +0530, Umesh Kalappa wrote: > > > Hi Adnrew, > > > Thank you for the quick response and for PPC64 too ,we do have > > > mismatches in ABI b/w complex operations like > > > https://godbolt.org/z/bjsYovx4c . > > > > > > Any reason why GCC chose to use GPR 's here ? > > > > What did you expect, what happened instead? Why did you expect that, > > and why then is it an error what did happen? > > > > You used -O0. As long as the code works, all is fine. But unoptimised > > code frequently is hard to read, please use -O2 instead? > > > > As Andrew says, why did you use -m32 for GCC but -m64 for LLVM? It is > > hard to compare those at all! 32-bit PowerPC Linux ABI (based on 32-bit > > PowerPC ELF ABI from 1995, BE version) vs. 64-bit ELFv2 ABI from 2015 > > (LE version). > > > > > > Segher >
Re: Passing the complex args in the GPR's
On Tue, 6 Jun 2023, Andrew Pinski via Gcc wrote: > You are looking at the wrong ABI document. > That is for the 64bit ABI. > The 32bit ABI document is located at: > http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf > > Plus the 32bit ABI document does not document Complex argument passing > as it was written in 1995 and never updated. For the 32-bit ABI see https://www.polyomino.org.uk/publications/2011/Power-Arch-32-bit-ABI-supp-1.0-Unified.pdf (sources at https://github.com/ryanarn/powerabi - power.org has long since disappeared). -- Joseph S. Myers jos...@codesourcery.com
Re: Passing the complex args in the GPR's
Hi Segher , >>What did you expect, what happened instead? For example the complex args are passed in GPR's for cexp in the case GCC and Clang uses caller memory . for reference : https://godbolt.org/z/MfMz3cTe7 We have cross tools like some of libraries built using the GCC and some use Clang . We approached Clang developers on this behaviour (Why stack , not the FPR's registers like PPC64) and they are not going to change this behaviour, and asked us to refer back to GCC ,hence this email thread. Question is : Why does GCC choose to use GPR's here and have any reference to support this decision ? Thank you ~Umesh On Tue, Jun 6, 2023 at 10:16 PM Segher Boessenkool wrote: > > Hi! > > On Tue, Jun 06, 2023 at 08:35:22PM +0530, Umesh Kalappa wrote: > > Hi Adnrew, > > Thank you for the quick response and for PPC64 too ,we do have > > mismatches in ABI b/w complex operations like > > https://godbolt.org/z/bjsYovx4c . > > > > Any reason why GCC chose to use GPR 's here ? > > What did you expect, what happened instead? Why did you expect that, > and why then is it an error what did happen? > > You used -O0. As long as the code works, all is fine. But unoptimised > code frequently is hard to read, please use -O2 instead? > > As Andrew says, why did you use -m32 for GCC but -m64 for LLVM? It is > hard to compare those at all! 32-bit PowerPC Linux ABI (based on 32-bit > PowerPC ELF ABI from 1995, BE version) vs. 64-bit ELFv2 ABI from 2015 > (LE version). > > > Segher
Re: Passing the complex args in the GPR's
Hi! On Tue, Jun 06, 2023 at 08:35:22PM +0530, Umesh Kalappa wrote: > Hi Adnrew, > Thank you for the quick response and for PPC64 too ,we do have > mismatches in ABI b/w complex operations like > https://godbolt.org/z/bjsYovx4c . > > Any reason why GCC chose to use GPR 's here ? What did you expect, what happened instead? Why did you expect that, and why then is it an error what did happen? You used -O0. As long as the code works, all is fine. But unoptimised code frequently is hard to read, please use -O2 instead? As Andrew says, why did you use -m32 for GCC but -m64 for LLVM? It is hard to compare those at all! 32-bit PowerPC Linux ABI (based on 32-bit PowerPC ELF ABI from 1995, BE version) vs. 64-bit ELFv2 ABI from 2015 (LE version). Segher
Re: Passing the complex args in the GPR's
On Tue, Jun 6, 2023 at 8:05 AM Umesh Kalappa wrote: > > Hi Adnrew, > Thank you for the quick response and for PPC64 too ,we do have > mismatches in ABI b/w complex operations like > https://godbolt.org/z/bjsYovx4c . > > Any reason why GCC chose to use GPR 's here ? Yes because it was set before 2003. There could not be an ABI break. r0-50273-gded9bf77e35ce9a2246 fixed GCC for the AIX ABI though. > > ~Umesh > > On Tue, Jun 6, 2023 at 8:28 PM Andrew Pinski wrote: > > > > On Tue, Jun 6, 2023 at 7:50 AM Umesh Kalappa via Libc-alpha > > wrote: > > > > > > Hi all , > > > > > > For the test case https://godbolt.org/z/vjs1vfs5W ,we see the mismatch > > > in the ABI b/w gcc and clang . > > > > > > Do we have any supporting documents that second the GCC behaviour over > > > CLANG ? > > > > > > EABI states like > > > > > > In the Power Architecture 64-Bit ELF V2 ABI Specification document > > > (v1.1 from 16 July 2015) > > > > You are looking at the wrong ABI document. > > That is for the 64bit ABI. > > The 32bit ABI document is located at: > > http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf > > > > Plus the 32bit ABI document does not document Complex argument passing > > as it was written in 1995 and never updated. > > > > https://www.nxp.com/docs/en/reference-manual/E500ABIUG.pdf does not > > document it either. > > > > Thanks, > > Andrew Pinski > > > > > > > > Page 53: > > > > > > Map complex floating-point and complex integer types as if the > > > argument was specified as separate real > > > and imaginary parts. > > > > > > and in this case the double complexes are broken down with double real > > > and double img and expected to pass in FPR not the GPR. > > > > > > > > > > > > Thank you > > > ~Umesh
Re: Passing the complex args in the GPR's
Hi Adnrew, Thank you for the quick response and for PPC64 too ,we do have mismatches in ABI b/w complex operations like https://godbolt.org/z/bjsYovx4c . Any reason why GCC chose to use GPR 's here ? ~Umesh On Tue, Jun 6, 2023 at 8:28 PM Andrew Pinski wrote: > > On Tue, Jun 6, 2023 at 7:50 AM Umesh Kalappa via Libc-alpha > wrote: > > > > Hi all , > > > > For the test case https://godbolt.org/z/vjs1vfs5W ,we see the mismatch > > in the ABI b/w gcc and clang . > > > > Do we have any supporting documents that second the GCC behaviour over > > CLANG ? > > > > EABI states like > > > > In the Power Architecture 64-Bit ELF V2 ABI Specification document > > (v1.1 from 16 July 2015) > > You are looking at the wrong ABI document. > That is for the 64bit ABI. > The 32bit ABI document is located at: > http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf > > Plus the 32bit ABI document does not document Complex argument passing > as it was written in 1995 and never updated. > > https://www.nxp.com/docs/en/reference-manual/E500ABIUG.pdf does not > document it either. > > Thanks, > Andrew Pinski > > > > > Page 53: > > > > Map complex floating-point and complex integer types as if the > > argument was specified as separate real > > and imaginary parts. > > > > and in this case the double complexes are broken down with double real > > and double img and expected to pass in FPR not the GPR. > > > > > > > > Thank you > > ~Umesh
Re: Passing the complex args in the GPR's
On Tue, Jun 6, 2023 at 7:50 AM Umesh Kalappa via Libc-alpha wrote: > > Hi all , > > For the test case https://godbolt.org/z/vjs1vfs5W ,we see the mismatch > in the ABI b/w gcc and clang . > > Do we have any supporting documents that second the GCC behaviour over CLANG ? > > EABI states like > > In the Power Architecture 64-Bit ELF V2 ABI Specification document > (v1.1 from 16 July 2015) You are looking at the wrong ABI document. That is for the 64bit ABI. The 32bit ABI document is located at: http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf Plus the 32bit ABI document does not document Complex argument passing as it was written in 1995 and never updated. https://www.nxp.com/docs/en/reference-manual/E500ABIUG.pdf does not document it either. Thanks, Andrew Pinski > > Page 53: > > Map complex floating-point and complex integer types as if the > argument was specified as separate real > and imaginary parts. > > and in this case the double complexes are broken down with double real > and double img and expected to pass in FPR not the GPR. > > > > Thank you > ~Umesh