* [PATCH GCC 7/9]Skip loops iterating only 1 time in predictive commoning
@ 2016-09-06 18:54 Bin Cheng
2016-09-07 12:31 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2016-09-06 18:54 UTC (permalink / raw)
To: gcc-patches; +Cc: nd
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
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.
[-- Attachment #2: 007-skip-predcom-for-1-iter-loop-20160902.txt --]
[-- Type: text/plain, Size: 1473 bytes --]
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH GCC 7/9]Skip loops iterating only 1 time in predictive commoning
2016-09-06 18:54 [PATCH GCC 7/9]Skip loops iterating only 1 time in predictive commoning Bin Cheng
@ 2016-09-07 12:31 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2016-09-07 12:31 UTC (permalink / raw)
To: Bin Cheng, gcc-patches; +Cc: nd
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-07 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 18:54 [PATCH GCC 7/9]Skip loops iterating only 1 time in predictive commoning Bin Cheng
2016-09-07 12:31 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).