Message ID | AM4PR0802MB2163C46150C94AF286DB2FD9E7F90@AM4PR0802MB2163.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show |
On 09/06/2016 12:53 PM, Bin Cheng wrote: > Hi, > For loops which are bounded to iterate only 1 time (thus loop's latch doesn't roll), there is nothing to predictive common, this patch detects/skips these cases. A test is also added in gcc/testsuite/gfortran.dg/vect/fast-math-mgrid-resid.f for this. > > Thanks, > bin > > 2016-09-01 Bin Cheng <bin.cheng@arm.com> > > * tree-predcom.c (tree_predictive_commoning_loop): Skip loop that only > iterates 1 time. > > gcc/testsuite/ChangeLog > 2016-09-01 Bin Cheng <bin.cheng@arm.com> > > * gfortran.dg/vect/fast-math-mgrid-resid.f: New test string. > OK. jeff
diff --git a/gcc/testsuite/gfortran.dg/vect/fast-math-mgrid-resid.f b/gcc/testsuite/gfortran.dg/vect/fast-math-mgrid-resid.f index fcf475d..88238f9 100644 --- a/gcc/testsuite/gfortran.dg/vect/fast-math-mgrid-resid.f +++ b/gcc/testsuite/gfortran.dg/vect/fast-math-mgrid-resid.f @@ -42,3 +42,4 @@ C ! { dg-final { scan-tree-dump-times "Executing predictive commoning without unrolling" 1 "pcom" { target lp64 } } } ! { dg-final { scan-tree-dump-times "Executing predictive commoning without unrolling" 2 "pcom" { target ia32 } } } ! { dg-final { scan-tree-dump-times "Predictive commoning failed: no suitable chains" 0 "pcom" } } +! { dg-final { scan-tree-dump-times "Loop iterates only 1 time, nothing to do" 1 "pcom" } } diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 096365a..14d53c2 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -2465,6 +2465,15 @@ tree_predictive_commoning_loop (struct loop *loop) if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Processing loop %d\n", loop->num); + /* Nothing for predicitive commoning if loop only iterates 1 time. */ + if (get_max_loop_iterations_int (loop) == 0) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Loop iterates only 1 time, nothing to do.\n"); + + return false; + } + /* Find the data references and split them into components according to their dependence relations. */ auto_vec<loop_p, 3> loop_nest;