On SMP machines is there a performance benefit to #2 vs #1:
1) x = 0;
or
2) if (x) x = 0;
I was thinking that the behind the scenes overhead to manage cache coherency between the CPUs might have some cost. Am I nuts?
Even with single-threaded code, the latter can have an advantage if the object lies in copy-on-write memory (for example, a private mapping of a file, or almost any writable memory after a fork). I suspect the advantage you're asking about is real too, at least on systems like x86 where memory consistency is handled automatically. On such machines, writing to memory that might be in another cpu's cache will invalidate the cached copy (actually the entire cache line). Just reading won't do any harm. Of course, if this is memory that's potentially being modified and shared by multiple threads, it needs to be protected by synchronization mechanisms anyway, and then you probably lose most or all of the advantage.