use of memset and optimization

Bill Sommerfeld sommerfeld at
Fri Nov 8 10:55:01 EST 2002

I think a good case can be made that even a memset of an auto volatile
array can be optimized away if the compiler can prove through
interprocedural or intermodule analysis that the address of the array
never escapes.

You'd have to "pierce the abstraction barrier" to notice otherwise and
therefore the optimization is "safe".

Remember, the compiler owns the stack.  

The compiler folks will get very bent out of shape if you say that
you've set things up so that auto volatile array will land on top of a
virtual mapping in I/O space for a particular device and this it's
always worked in past releases of the compiler....

Oh, for something about the state of the "art" in intermodule
optimization, see:

(yes, that's right, a C compiler determined when it was safe to turn
an array-of-structures into a structure-of-arrays to improve memory
bandwidth for an inner loop which only looked at a couple of the
structure fields..)

					- Bill

More information about the krbdev mailing list