[M3commit] CVS Update: cm3
Jay Krell
jkrell at elego.de
Sat Mar 13 14:45:59 CET 2010
CVSROOT: /usr/cvs
Changes by: jkrell at birch. 10/03/13 14:45:59
Modified files:
cm3/m3-sys/m3front/src/exprs/: CompareExpr.m3 EqualExpr.m3
Log message:
Fairly simple analysis to optimize comparison of subranges
that either don't overlap at all, or only "on the edge"
("on the edge" means the max of one is equal to the min of the other
or vice versa)
I don't presume that this really helps much real world code, but
it is pretty simple so shouldn't hurt.
Probably it is rare to mix unequal subranges, let alone non-overlapping
or barely overlapping, as well probably rare to compare subranges to
constants outside the subrange (or again, "on the edge")
This handles, integers, longints, enums, constants, but addresses don't work
e.g. address < NIL should perhaps always be false.
It seems to me that maybe EqualExpr.m3 and CompareExpr.m3 could be combined somehow?
I was surprised to see that they are separate.
It also seemed odd to have to call ConstValue before GetBounds.
Backends are not directly given the information for them to do this work, though
more advanced analysis might regain the information.
subranges and enums just end up as generally unbounded int32, etc.
(backends do see range checks and can remember what they imply but
I believe parameters are not range checked upon receipt, for example)
see test case p233 (though it should probably move to the "c for code" section,
since running it doesn't do anything, one reads the code and notices that
many of the functions are optimized to just return a constant true or false)
This is actually fallout/tangent from not-yet-done work to optimize integer (and possibly other)
compares in m3back, which has a pretty non-optimal implementation.
More information about the M3commit
mailing list