Hi All, Here is updated patch to optimize mask stores. The main goal of it is to avoid execution of mask store if its mask is zero vector since loads that follow it can be blocked. The following changes were done: 1. A test on sink legality was added - it simply prohibits to cross statements with non-null vdef or vuse. 2. New phi node is created in join block for moved MASK_STORE statements. 3. Test was changed to check that 2 MASK_STORE statements are not moved to the same block. 4. New field was added to loop_vec_info structure to mark loops having MASK_STORE's. Any comments will be appreciated. Yuri. 2015-05-20 Yuri Rumyantsev * config/i386/i386.c: Include files stringpool.h and tree-ssanames.h. (ix86_vectorize_is_zero_vector): New function. (TARGET_VECTORIZE_IS_ZERO_VECTOR): New target macro * doc/tm.texi.in: Add @hook TARGET_VECTORIZE_IS_ZERO_VECTOR. * doc/tm.texi: Updated. * target.def (is_zero_vector): New DEFHOOK. * tree-vect-stmts.c : Include tree-into-ssa.h. (vectorizable_mask_load_store): Initialize has_mask_store field. (is_valid_sink): New function. (optimize_mask_stores): New function. * tree-vectorizer.c (vectorize_loops): Invoke optimaze_mask_stores for loops having masked stores. * tree-vectorizer.h (loop_vec_info): Add new has_mask_store field and correspondent macros. (optimize_mask_stores): Update prototype. gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-vect-mask-store-move1.c: New test.