Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ll-xn!mit-eddie!uw-beaver!cornell!rochester!udel!burdvax!sdcrdcf!ism780c!news From: news@ism780c.UUCP (News system) Newsgroups: comp.lang.c Subject: Re: bitwise short-circuiting Message-ID: <9130@ism780c.UUCP> Date: 20 Feb 88 03:26:00 GMT References: <4224@june.cs.washington.edu> <2303@umd5.umd.edu> Reply-To: marv@ism780.UUCP (Marvin Rubenstein) Organization: Interactive Systems Corp., Santa Monica CA Lines: 27 Keywords: bitwise optimize open-eyes Chris Torek writing about optimizing expressions like: a = 0 & f(); (void) f(), a = 0 if (1 | g()) s1; else s2; says: >(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. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163 Chris, how do you justify the above assertion? I just got my copy of the the proposed standard (11 Jan 88 version). On page 51 the semantics of the bitwise & operator is defined. I quote: "The usual arithmetic conversions are performed on the operands." "The result of the binary & operator is the bitwise AND of the operands (that is, each bit in the result is set if and only if each of the corresponding bits in the converted operands is set)." I could not find any thing in the standard that requires evaluation of side effects of the operands if the result can be determined without evaluating the operands. Marv Rubinstein -- Interactive Systems