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

Simple optimizations missing




Expression optimizations:

	x / x = 1
	x % x = 0

Trivial.

----------------------------------------------------------

Another thing which can save at least size:

 b is a 8 bit value. There is an expression like:

	( b + otherstuff ) & mask

 otherstuff is any other expression, can also be very complex.
 mask is a value between 0 and 255.

 So you can change

	movzbl	(....), %eax
	addl	...
	andl	$mask, %eax
  or
	movzbl	%al, %eax
	addl	...
	andl	$mask, %eax

 to

	movzb	(....), %al		# may be only if optimizing for size
	addl	...
	andl	$mask, %eax
  or 
	addl	...			# always good
	andl	$mask, %eax


 This optimzation can also be done for

	(b + otherstuff) | value

 if value is in the range from 0xFFFFFF00...0xFFFFFFFF.

 This optimization is also possible for 16 bit quantities. Range of the masks
 is different. The operator '+' can also be:

	+
	-
	^
	|
	&

 or a mixture of them.

-- 
Frank Klemm


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