[m-rev.] diff: MLDS back-end: optimize away trivial switches
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Oct 24 13:24:41 AEST 2001
Estimated hours taken: 0.5
Branches: main
compiler/ml_simplify_switch.m:
Optimize away trivial switches (those with only one case,
and where the default is unreachable).
Workspace: /home/earth/fjh/ws-earth2/mercury
Index: compiler/ml_simplify_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_simplify_switch.m,v
retrieving revision 1.2
diff -u -d -r1.2 ml_simplify_switch.m
--- compiler/ml_simplify_switch.m 20 Jan 2001 15:42:47 -0000 1.2
+++ compiler/ml_simplify_switch.m 16 Aug 2001 15:35:29 -0000
@@ -93,6 +93,18 @@
{ Statement = ml_switch_to_if_else_chain(Cases, Default, Rval,
MLDS_Context) }
;
+ %
+ % Optimize away trivial switches
+ % (these can occur e.g. with --tags none, where the
+ % primary tag test always has only one reachable case)
+ %
+ { Stmt0 = switch(_Type, _Rval, _Range, Cases, Default) },
+ { Cases = [SingleCase] },
+ { Default = default_is_unreachable }
+ ->
+ { SingleCase = _MatchCondition - CaseStatement },
+ { Statement = CaseStatement }
+ ;
{ Stmt = Stmt0 },
{ Statement = mlds__statement(Stmt, MLDS_Context) }
).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "... it seems to me that 15 years of
The University of Melbourne | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh> | -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list