https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90823
Bug ID: 90823 Summary: PowerPC command line switches don't work with #pragma CPU target or target attribute Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: meissner at gcc dot gnu.org Target Milestone: --- I was working on the patch to temporarily disable -mpcrel in GCC 10 until the full pc-relative support is in place. When I went to update the tests that test the pc-relative support that is in there to add the -mpcrel option, I discovered that the tests that change the target to power9 did not work (because -mpcrel requires the 'future' processor). This would be true of other switches like -mpower9-vector. If you compile the following code with -O2 -mpower9-vector: double def (long a, long b) { return (double) (a % b); } #pragma GCC target ("cpu=power9") double p9 (long a, long b) { return (double) (a % b); } #pragma GCC target ("cpu=power8") double p8 (long a, long b) { return (double) (a % b); } #pragma GCC target ("cpu=power7") double p7 (long a, long b) { return (double) (a % b); } Each of the functions will get compiled for the -mcpu=power9 target because the -mpower9-vector from the command line is applied after the #pragma GCC target stuff is done, and using -mpower9-vector turns on all of the other power9 options. If instead you compile it using -O2 -mcpu=power9, then it generates the expected code (the 'def' and 'p9' functions use modsd/mtvsrd, the 'p8' function does divide/multiply/subtract and mtvsrd, and the 'p7' function does divide/multiply/subtract, store, and load).