delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/23/07:30:17

Newsgroups: comp.os.msdos.djgpp
From: "William A. Barath" <wi534 AT victoria DOT tc DOT canada>
Subject: Re: how to make switch(){ } compile as lookup table always?
In-Reply-To: <4B0C721CA8@fs2.mt.umist.ac.uk>
Message-ID: <Pine.GSO.3.95.iB1.0.971223004425.25592A-100000@vtn1>
Sender: news AT freenet DOT victoria DOT bc DOT ca (News Manager)
Organization: Victoria Telecommunity Network
References: <4B0C721CA8 AT fs2 DOT mt DOT umist DOT ac DOT uk>
Mime-Version: 1.0
Date: Tue, 23 Dec 1997 08:46:49 GMT
Lines: 19
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 22 Dec 1997, Anthony.Appleyard wrote:

|I have djgpp v2. A program contains a switch(c){  } statement which is obeyed
|very many times. c can be from 0 to 511. How can I make djgpp compile the
|switch() always as a lookup table of labels and not as a lot of time-wasting
|tests and jumps even if the resulting lookup table would be very gappy? I
|can't find anything about this in DJGPP\INFO\ or in the FAQ.

On a superscalar CPU, tests and jumps are almost always faster than a
sparse lookup table where cache misses will seriously slow down address
resolution, and the pipelines will always get stalled while ifetch is in
hazard.  GCC does a very good job of detecting the threshold of when it is
faster to use a table.  Trust it. 

Wil Barath, aka WseM : "I feel as though I see my pen to write"
Author of VPM, EDITPLN, and other VGA Planets support programs
Visit my homepage! -------------> http://victoria.tc.ca/~wi534


- Raw text -


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