www.delorie.com/archives/browse.cgi   search  
Mail Archives: pgcc/1999/09/26/20:54:11

Date: Mon, 27 Sep 1999 01:06:32 +0200
From: Ronald de Man <deman AT win DOT tue DOT nl>
To: pgcc AT delorie DOT com
Subject: Re: using cmov* not that great
Message-ID: <19990927010632.A24587@win.tue.nl>
References: <3 DOT 0 DOT 32 DOT 19990926230735 DOT 00c74930 AT pop DOT xs4all DOT nl>
Mime-Version: 1.0
X-Mailer: Mutt 0.95.4i
In-Reply-To: <3.0.32.19990926230735.00c74930@pop.xs4all.nl>; from Vincent Diepeveen on Sun, Sep 26, 1999 at 11:07:37PM +0100
X-Operating-System: Linux localhost 2.2.12
Reply-To: pgcc AT delorie DOT com
X-Mailing-List: pgcc AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, Sep 26, 1999 at 11:07:37PM +0100, Vincent Diepeveen wrote:
> 
> The general patterns sure are hard to rewrite:
> 
>   if( GENERAL PATTERN ) {
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_XXXX;
> 
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_YXXX;
> 
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_XXXX;
>    }
> 
> So to fall through i would have to do next:
>    if( !GENERALPATTERN ) {
>      // nothing
>    } 
>    else {
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_XXXX;
> 
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_YXXX;
> 
>     if( PATTERN l PATTERN l PATTERN ) 
>       s += SCORE_XXXX;  
>    }
> 
> Question: is above rewrite smart?

I would be surprised if the rewrite results in different code.
pgcc/gcc is smart enough to see that both are equivalent.

In fact, I just tried it in a small example, and the generated
code was the same in both cases.

So you won't get faster code, but at least you don't have to
worry about rewriting your code in a smart way that would make
it more difficult to understand and maintain.

Ronald

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019