This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/24913] New: undocumented new CPU upgrade by -mpowerpc-gpopt overrides user-selected -mcpu= setting

        The G4 PowerPC processor does not support the (full) GPOPT instruction
set that can be activated with -mpowerpc-gpopt. The documentation is not
explicitly clear on which (current) processors support this instruction set -
or any of the other additional/extended/optional sets like those selected with
-mpowerpc-gfxopt, -mstrings, -mmultiple, etc.

Earlier versions of gcc (until at least 4.0.0 4061) used to ignore
-mpowerpc-gpopt on the G4, judging from the assembly they produce (a simple
y=sqrt(x) statement is enough). Gcc 4.0.1 5301 has a new, undocumented
behaviour: it changes the target cpu to ppc970. The resulting code crashes on a
G4, of course. This happens even when the compiler was instructed to compile
for a G4, i.e. when invoked with -mcpu=G4 -mpowerpc-gpopt (the order is

System: Darwin Zygiella.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30
20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh

        <machine, os, target, libraries (multiple lines)>
host: powerpc-apple-darwin7
build: powerpc-apple-darwin7
target: powerpc-apple-darwin7
configured with: /Volumes/Debian/gcc/gcc401build/../gcc-401-5301/configure
--prefix=/usr/local/gnu/gcc/4.0.1 --enable-languages=c,c++,objc,obj-c++,f95
--build=powerpc-apple-darwin7 --host=powerpc-apple-darwin7

        Invoked the compiler with -mpowerpc-gpopt on a simple source file like
the example below. On a G4, the resulting fsqrt instruction that is generated
for the sqrt expression will crash. This also happens when compiled with
-mcpu=G4 -mpowerpc-gpopt .

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

main( int argc, char *argv[] )
{ double x, y, z;
  long long a, b;
        if( argc>= 2 ){
                sscanf( argv[1], "%lf", &x );
                sscanf( argv[2], "%lf", &y );
                x= drand48() * 10.0;
                y= drand48() * 5.0;
        if( y== 0.5 ){
                z= sqrt(x);
                z= pow( x, y );
        printf( "pow(%g,%g)=%g\n", x, y, z );
        a= x;
        b= y;
        printf( "(long long)(%lld * %lld) = %lld\n", a, b, a*b );

------- Comment #1 from vsxo at hotmail dot com  2005-11-17 16:47 -------
        The workaround is not to give the instruction. There are several
solutions. The documentation should be made up to date in this aspect; *also*
for -mpowerpc-gfxopt -mnew-mnemonics -mstring -mmultiple -misel). A good
additional solution would be to output a warning or error when selecting
incompatible instruction sets and target cpus. (Rationale: -mcpu=G4 -mmmx also
gives an abortive error...)
        Ideally, a warning would also be given when an option is selected that
cause the resulting code to (potentially) crash on the host CPU (this used to
be the case under Irix), (even) in the absence of a specific cpu selector.

           Summary: undocumented new CPU upgrade by -mpowerpc-gpopt
                    overrides user-selected -mcpu= setting
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vsxo at hotmail dot com
 GCC build triplet: powerpc-apple-darwin7
  GCC host triplet: powerpc-apple-darwin7
GCC target triplet: powerpc-apple-darwin7

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]