You missed my point or perhaps I missed yours. The generated code in our compiler code is the same as (A != B) which is generally implemented as a XOR. I assumed you were referring a well known common compiler bug where if ((A == B) != 1) the (A==B) part implemented as a XOR and is then compared to 1 fails. I walked through the ISO definitions in my example. BTW this has shown up in different forms as a WG-14 question at ISO an number of times in the last few years. w.. Sergio Masci wrote: > ----- Original Message ----- > From: Walter Banks > To: Microcontroller discussion list - Public. > Sent: Friday, October 08, 2004 4:39 PM > Subject: Re: [PIC] new optimisation in XCSB > > > > > > > Sergio Masci wrote: > > > > > An insteresting question is what does you favourite PIC C compiler make of > > > > > > if ((A == B) == 0) > > > or > > > if ((A == B) != 1) > > > > > > xcsb sees this as > > > > > > if A != B then > > > > > > > C logical operations return 0 or 1. 0 is false 1 is true > > When logically testing 0 is false non zero is true > > > > case of A != B > > > > if ((A == B) == 0) > > > > if ( (0) == 0) > > > > if (0 == 0) > > > > if (1) The if condition is true > > No "(A == B)" can return 0 or 1 so the result is not known at compile time. "(A > == B)" cannot be reduced to 0 at compile time. > > > > > ===================== > > > > if ((A == B) != 1) > > > > if ((0) != 0) > > if (0 != 0) > > if (1) The if condition is true > > Again "(A == B)" cannot be reduced to 0 at compile time, however it is known > that the result of "(A == B)" can only be 0 or 1 so in this case "!= 1" is the > same as "== 0" > > > > > ======================= > > > > I agree that it is the same as > > if (A !=B) > > > > Walter.. > > Regards > Sergio Masci > > http://www.xcprod.com/titan/XCSB - optimising PIC compiler > > _______________________________________________ > http://www.piclist.com > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist