This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/17617] Micro-optimize INTEGRAL_TYPE_P (or tree.def rather)


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]