gallivm: move mask_vec function up higher so it can be reused.