public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/17617] Micro-optimize INTEGRAL_TYPE_P (or tree.def rather)
Date: Mon, 20 Dec 2004 17:15:00 -0000	[thread overview]
Message-ID: <20041220171446.16762.qmail@sourceware.org> (raw)
In-Reply-To: <20040922190625.17617.kazu@cs.umass.edu>


------- Additional Comments From bangerth at dealii dot org  2004-12-20 17:14 -------
The question raised in several of the messages in that discussion 
is whether an enumeration of equality checks is converted into a 
range check if the tested values are consecutive. 
 
Here is the answer: 
-------------------- 
enum E  
{ 
      eins = 1, 
      zwei = 2, 
      drei = 3, 
      vier = 4, 
      fuenf= 5, 
      sechs= 6 
}; 
 
bool test_range (E e) 
{ 
  return e==drei || e==vier || e==fuenf; 
} 
------------------------ 
 
This is indeed compiled into a range check: 
_Z10test_range1E: 
	pushl	%ebp 
	movl	%esp, %ebp 
	movl	8(%ebp), %eax 
	popl	%ebp 
	subl	$3, %eax 
	cmpl	$2, %eax 
	setbe	%al 
	movzbl	%al, %eax 
	ret 
 
W. 

-- 


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


  parent reply	other threads:[~2004-12-20 17:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22 19:06 [Bug tree-optimization/17617] New: " kazu at cs dot umass dot edu
2004-09-22 21:17 ` [Bug tree-optimization/17617] " pinskia at gcc dot gnu dot org
2004-12-20 17:08 ` bangerth at dealii dot org
2004-12-20 17:15 ` bangerth at dealii dot org [this message]
2004-12-21 17:42 ` nathan at gcc dot gnu dot org
2004-12-21 17:43 ` nathan at gcc dot gnu dot org
2005-01-07 14:15 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041220171446.16762.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).