This is the mail archive of the gcc-patches@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]

Re: [PATCH] Implement switch statements with bit tests


Roger Sayle <roger@www.eyesopen.com> writes:

> e.g. we'd like to convert
> 
> 	if ((x==4) || (x==6) || (x==9) || (x==11))
> 
> into
> 
> 	if ((1<<x) & ((1<<4)|(1<<6)|(1<<9)|(1<<11)))

Wouldn't this be better:

if ((((1<<4)|(1<<6)|(1<<9)|(1<<11)) >> x) & 1)

e. g. on Alpha, it would save two instructions, since we don't need to
generate a 1, and one could use "branch if low bit set".

-- 
	Falk


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