A method and system for generating efficient versioned codes for single
instruction multiple data units whose memory systems have alignment
constraints. The system creates multiple versions of codes based on
relative alignments of the data streams involved in the computation. The
system also analyzes characteristics of relative alignments (e.g.
compile-time or runtime) to determine whether code versioning is
beneficial based on a cost model.