Bug 8243 - GCC 3.2 does not check for CMOV instruction before generating code
Summary: GCC 3.2 does not check for CMOV instruction before generating code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 8525 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-16 10:16 UTC by forsmark
Modified: 2005-02-16 09:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description forsmark 2002-10-16 10:16:02 UTC
When compiling any C code with GCC 3.2 (and all other versions) Configure finds out that the VIA C3 processor is a i686 processor. That’s ok, but the VIA C3 processor doesn’t have the CMOV instruction. 
When GCC generates code for the i686 processor it includes the use of the CMOV instruction and therefore the code will result in an "illegal instruction" error when executed on a VIA C3 processor.
The VIA C3 is indeed a 'model 6' processor. The Pentium Pro manual states that this cmov (conditional move) instruction is optional and you are supposed to check for its present before using it.
This means that GCC should check for this before generation code including this instruction. If CMOV is not present, the code should be generated without using this instruction.

Release:
GCC 3.2 (and all earlier versions)

Environment:
Linux kernel 2.4.19
VIA C3 processor
GCC Version 3.2

How-To-Repeat:
Use GCC to compile any program (ex XFREE 4.2) on a Linux PC with compiler option "-march=i686 -mcpu=i686".
Then run the compiled program an see the "illegal instruction" error.
Comment 1 forsmark 2002-10-16 10:16:02 UTC
Fix:
Use GCC with "-march=i586 -mcpu=i586" but then the code is not optimal for the processor.
Comment 2 Richard Henderson 2002-10-21 23:55:43 UTC
State-Changed-From-To: open->closed
State-Changed-Why: Defined as "not a bug".  When we say i686, we really do mean
    "pentiumpro".  Checking for cmov is a waste of time; it'd be
    faster to not use it than to check.
    
    Use -march=i586 instead.
Comment 3 kokorozashi 2003-02-13 11:54:39 UTC
From: Pete Gontier <kokorozashi@gontier.org>
To: <gcc-gnats@gcc.gnu.org>,
	<forsmark@odense.kollegienet.dk	<gcc-bugs@gcc.gnu.org	<nobody@gcc.gnu.org	<gcc-prs@gcc.gnu.orgCc:  
Subject: Re: target/8243: GCC 3.2 does not check for CMOV instruction
	before generating code
Date: Thu, 13 Feb 2003 11:54:39 -0800

 I don't think I fully understand the closure of this bug. I understand if by
 i686 you really mean Pentium Pro. (I hope that's documented.) The claim that
 it would be dumb for GCC to generate code which checks for CMOV before using
 it also makes sense. However, if there were a way to tell GCC not to
 generate CMOV instructions in the first place, that would seem reasonable,
 too, assuming there are other i686 optimizations worth doing.
 

Comment 4 kokorozashi 2003-02-13 12:34:28 UTC
From: Pete Gontier <kokorozashi@gontier.org>
To: <gcc-gnats@gcc.gnu.org>,
	<forsmark@odense.kollegienet.dk	<gcc-bugs@gcc.gnu.org	<nobody@gcc.gnu.org	<gcc-prs@gcc.gnu.orgCc:  
Subject: Re: target/8243: GCC 3.2 does not check for CMOV instruction
	before generating code
Date: Thu, 13 Feb 2003 12:34:28 -0800

 circa 2/13/03 11:54 AM, Pete Gontier <kokorozashi@gontier.org> wrote:
 
 > I don't think I fully understand the closure of this bug. I understand if by
 > i686 you really mean Pentium Pro. (I hope that's documented.) The claim that
 > it would be dumb for GCC to generate code which checks for CMOV before using
 > it also makes sense. However, if there were a way to tell GCC not to generate
 > CMOV instructions in the first place, that would seem reasonable, too,
 > assuming there are other i686 optimizations worth doing.
 
 Hmmm. Perhaps this is already present in the form of -march=c3. And from
 what I hear, CMOV was the only significant optimization for i686. If this is
 all true, then feel free to ignore my previous message. (Well, OK, I would
 still appreciate an off-list note.)
 
  --
  
   Pete Gontier <http://www.pete.gontier.org/>
Comment 5 Michael Behrisch 2005-02-16 09:41:59 UTC
(In reply to comment #4) 
> From: Pete Gontier <kokorozashi@gontier.org> 
> To: <gcc-gnats@gcc.gnu.org>, 
>         <forsmark@odense.kollegienet.dk <gcc-bugs@gcc.gnu.org   
<nobody@gcc.gnu.org     <gcc-prs@gcc.gnu.orgCc:   
> Subject: Re: target/8243: GCC 3.2 does not check for CMOV instruction 
>         before generating code 
> Date: Thu, 13 Feb 2003 12:34:28 -0800 
>  
>  circa 2/13/03 11:54 AM, Pete Gontier <kokorozashi@gontier.org> wrote: 
>   
>  > I don't think I fully understand the closure of this bug. I understand if 
by 
>  > i686 you really mean Pentium Pro. (I hope that's documented.) The claim 
that 
>  > it would be dumb for GCC to generate code which checks for CMOV before 
using 
>  > it also makes sense. However, if there were a way to tell GCC not to 
generate 
>  > CMOV instructions in the first place, that would seem reasonable, too, 
>  > assuming there are other i686 optimizations worth doing. 
>   
>  Hmmm. Perhaps this is already present in the form of -march=c3. And from 
>  what I hear, CMOV was the only significant optimization for i686. 
 
This patch indicates that there -march=c3 is not the solution: 
http://gcc.gnu.org/ml/gcc-patches/2004-07/msg02718.html 
There is another (german) report on patching gcc to create optimized 
code for the c3 
http://epia.std-err.de/gcc.php 
 
Michael