public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/24913]  New: undocumented new CPU upgrade by -mpowerpc-gpopt overrides user-selected -mcpu= setting
@ 2005-11-17 16:47 gcc-bugzilla at gcc dot gnu dot org
  2005-11-17 16:56 ` [Bug target/24913] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2005-11-17 16:47 UTC (permalink / raw)
  To: gcc-bugs



        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
irrelevant).

Environment:
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
powerpc


        <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
--target=powerpc-apple-darwin7

How-To-Repeat:
        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 );
        }
        else{
                x= drand48() * 10.0;
                y= drand48() * 5.0;
        }
        if( y== 0.5 ){
                z= sqrt(x);
        }
        else{
                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 );
        exit(0);
}
###########


------- Comment #1 from vsxo at hotmail dot com  2005-11-17 16:47 -------
Fix:
        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


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-17 21:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-17 16:47 [Bug target/24913] New: undocumented new CPU upgrade by -mpowerpc-gpopt overrides user-selected -mcpu= setting gcc-bugzilla at gcc dot gnu dot org
2005-11-17 16:56 ` [Bug target/24913] " pinskia at gcc dot gnu dot org
2005-11-17 21:06 ` vsxo at hotmail dot com
2005-11-17 21:08 ` pinskia at gcc dot gnu dot org
2005-11-17 21:10 ` pinskia at gcc dot gnu dot org
2005-11-17 21:26 ` vsxo at hotmail dot com
2005-11-17 21:43 ` pinskia at gcc dot gnu dot org
2005-11-17 21:52 ` vsxo at hotmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).