Hi, This patch rewrites classification part of builtin partition so that nested builtin partitions are supported. With this extension, below loop nest: void foo (void) { for (unsigned i = 0; i < M; ++i) for (unsigned j = 0; j < N; ++j) arr[i][j] = 0; will be distributed into a single memset, rather than a loop of memset. Bootstrap and test in patch set on x86_64 and AArch64, is it OK? Thanks, bin 2017-10-04 Bin Cheng * tree-loop-distribution.c (struct builtin_info): New struct. (struct partition): Refactor fields into struct builtin_info. (partition_free): Free struct builtin_info. (build_size_arg_loc, build_addr_arg_loc): Delete. (generate_memset_builtin, generate_memcpy_builtin): Get memory range information from struct builtin_info. (find_single_drs): New function refactored from classify_partition. Also moved builtin validity checks to this function. (compute_access_range, alloc_builtin): New functions. (classify_builtin_1, classify_builtin_2): New functions. (classify_partition): Refactor code into functions find_single_drs, classify_builtin_1 and classify_builtin_2. (distribute_loop): Don't do runtime alias check when distributing loop nest. (find_seed_stmts_for_distribution): New function. (pass_loop_distribution::execute): Refactor code finding seed stmts into above function. Support distribution for the innermost two-level loop nest. Adjust dump information. gcc/testsuite/ChangeLog 2017-10-04 Bin Cheng * gcc.dg/tree-ssa/ldist-28.c: New test. * gcc.dg/tree-ssa/ldist-29.c: New test. * gcc.dg/tree-ssa/ldist-30.c: New test. * gcc.dg/tree-ssa/ldist-31.c: New test.