bitwise short-circuiting

Chris Torek chris at trantor.umd.edu
Tue Feb 16 20:59:43 AEST 1988


Without further supporting evidence, I will claim that any optimiser
could convert

	a = 0 & f();

into

	(void) f(), a = 0

and

	if (1 | g()) s1; else s2;

into

	(void) g(); s1;

(s2 may be deleted entirely iff it is not reachable via labels),
and that unless the compiler can determine that f() and g() have
no side effects, any further optimisation is simply wrong.  If
the compiler knows that f() is a pure function, e.g.,

	static int f() { return 0; }
	...	a = 0 & f();

it could then delete the call.
-- 
In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163
(hiding out on trantor.umd.edu until mimsy is reassembled in its new home)
Domain: chris at mimsy.umd.edu		Path: not easily reachable



More information about the Comp.lang.c mailing list