This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Simple optimizations missing
- To: Jan Hubicka <jh at suse dot cz>
- Subject: Simple optimizations missing
- From: Frank Klemm <pfk at fuchs dot offl dot uni-jena dot de>
- Date: Sun, 9 Sep 2001 15:36:48 +0200
- >Received: (from pfk@localhost)by fuchs.offl.uni-jena.de (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id PAA02504;Sun, 9 Sep 2001 15:36:48 +0200
- Cc: gcc at gcc dot gnu dot org
- References: <20010901202854.A7713@fuchs.offl.uni-jena.de> <20010902000000.C27182@atrey.karlin.mff.cuni.cz> <20010902024104.F7713@fuchs.offl.uni-jena.de> <20010903154513.C13574@atrey.karlin.mff.cuni.cz> <20010904003127.C335@fuchs.offl.uni-jena.de> <20010905133458.D15564@atrey.karlin.mff.cuni.cz> <20010905185526.A559@fuchs.offl.uni-jena.de> <20010906174007.B1486@atrey.karlin.mff.cuni.cz> <20010906222524.A2578@fuchs.offl.uni-jena.de> <20010907111641.G9651@atrey.karlin.mff.cuni.cz>
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