You see a lot of logical operators used in HW code as well, due to a myth that the bit-wise operators should not be used with 1-bit operands. Bit-wise operators are used in SW code also, wherever you need a bit-wise operation. Short-circuiting opportunities for the bit-wise operations would be much less common, only where one of the operands in all zeros (for &) or all ones (for |). Shalom > This does still leave the justification of why && and || should be > short-circuiting when the other operators are not. > > Part of this is based on the fact that C (and Vera) work this way. > But there are underlying reasons that they work this way. There are > common idioms that use && and || and rely on short-circuiting to > work properly. Examples have been given of these. I don't know of > any such common idioms for the other operators. > > The logical connectives tend to be used in software-ish situations, > where avoiding run-time errors is an issue. The bitwise logical > operators tend to be used in hardware-ish situations, where this is > not an issue. The special values where short-circuiting can be done > for && and || are common (one expects about 50% of the time). The > special values where short-circuiting can be done for other operators > like + are rare corner cases. So from an simulation optimization > perspective, you have allowed short-circuiting where it is most > profitable.Received on Wed Aug 16 00:05:40 2006
This archive was generated by hypermail 2.1.8 : Wed Aug 16 2006 - 00:06:03 PDT