For the testcase double a[16][16][64], y[16][64], x[16][16];
void foo(void) { int i, j, k; for (k = 0; k < 16; ++k) for (j = 0; j < 64; ++j) for (i = 0; i < 16; ++i) { y[k][j] = y[k][j] + a[k][i][j] * x[k][i]; } } loop interchange is performed with -O2 -fno-tree-pre -fno-tree-loop-im -ftree-loop-linear but not with PRE or lim moving the store/load to/from y[k][j]. The interchange fails because /* Validate the resulting matrix. When the transformation is not valid, reverse to the previous transformation. */ if (!lambda_transform_legal_p (trans, depth, dependence_relations)) returns false which is because constants or SSA names from final values leak into the access fns like (compute_affine_dependence (stmt_a = pretmp.11_3 = y[k_41][j_40]) (stmt_b = y[k_41][j_40] = D.1578_20) (subscript_dependence_tester (analyze_overlapping_iterations (chrec_a = {0, +, 1}_2) (chrec_b = 63) (analyze_siv_subscript ) (overlap_iterations_a = [63] ) (overlap_iterations_b = [0] ) which confuses dependency analysis here: else if (!operand_equal_p (access_fn_a, access_fn_b, 0)) { /* This can be for example an affine vs. constant dependence (T[i] vs. T[3]) that is not an affine dependence and is not representable as a distance vector. */ non_affine_dependence_relation (ddr); return false; -- Summary: Loop interchange not performed, data dependence analysis defect Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36011