The mask array must be value-aligned with the source array. The result array must be aligned to the source array, with replicated alignment in dimension dim (see section 4.5).