summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/ipa-icf-gimple.c38
-rw-r--r--gcc/ipa-icf-gimple.h3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr90555.c67
5 files changed, 120 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1fb8fddbea2..4c2bb69a1c8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2019-05-28 Martin Liska <mliska@suse.cz>
+
+ PR ipa/90555
+ * ipa-icf-gimple.c (func_checker::compare_loops): New function.
+ * ipa-icf-gimple.h (func_checker::compare_loops): Likewise.
+ (func_checker::compare_bb): Call compare_loops.
+
2019-05-27 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_scan_omp_clauses): Allow lastprivate conditional
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 25284936bc3..0713e125898 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-utils.h"
#include "tree-eh.h"
#include "builtins.h"
+#include "cfgloop.h"
#include "ipa-icf-gimple.h"
@@ -605,6 +606,40 @@ func_checker::compare_variable_decl (tree t1, tree t2)
return return_with_debug (ret);
}
+/* Compare loop information for basic blocks BB1 and BB2. */
+
+bool
+func_checker::compare_loops (basic_block bb1, basic_block bb2)
+{
+ if ((bb1->loop_father == NULL) != (bb2->loop_father == NULL))
+ return return_false ();
+
+ struct loop *l1 = bb1->loop_father;
+ struct loop *l2 = bb2->loop_father;
+ if (l1 == NULL)
+ return true;
+
+ if ((bb1 == l1->header) != (bb2 == l2->header))
+ return return_false_with_msg ("header");
+ if ((bb1 == l1->latch) != (bb2 == l2->latch))
+ return return_false_with_msg ("latch");
+ if (l1->simdlen != l2->simdlen)
+ return return_false_with_msg ("simdlen");
+ if (l1->safelen != l2->safelen)
+ return return_false_with_msg ("safelen");
+ if (l1->can_be_parallel != l2->can_be_parallel)
+ return return_false_with_msg ("can_be_parallel");
+ if (l1->dont_vectorize != l2->dont_vectorize)
+ return return_false_with_msg ("dont_vectorize");
+ if (l1->force_vectorize != l2->force_vectorize)
+ return return_false_with_msg ("force_vectorize");
+ if (l1->unroll != l2->unroll)
+ return return_false_with_msg ("unroll");
+ if (!compare_variable_decl (l1->simduid, l2->simduid))
+ return return_false_with_msg ("simduid");
+
+ return true;
+}
/* Function visits all gimple labels and creates corresponding
mapping between basic blocks and labels. */
@@ -727,6 +762,9 @@ func_checker::compare_bb (sem_bb *bb1, sem_bb *bb2)
if (!gsi_end_p (gsi2))
return return_false ();
+ if (!compare_loops (bb1->bb, bb2->bb))
+ return return_false ();
+
return true;
}
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 0035db32e66..51aadced9ea 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -226,6 +226,9 @@ public:
/* Verifies that trees T1 and T2 do correspond. */
bool compare_variable_decl (tree t1, tree t2);
+ /* Compare loop information for basic blocks BB1 and BB2. */
+ bool compare_loops (basic_block bb1, basic_block bb2);
+
/* Return true if types are compatible for polymorphic call analysis.
COMPARE_PTR indicates if polymorphic type comparsion should be
done for pointers, too. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index caeb40691f3..fe90a4fda8b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-05-28 Martin Liska <mliska@suse.cz>
+
+ PR ipa/90555
+ * gcc.dg/ipa/pr90555.c: New test.
+
2019-05-28 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/machine_attr1.ad[sb]: New test.
diff --git a/gcc/testsuite/gcc.dg/ipa/pr90555.c b/gcc/testsuite/gcc.dg/ipa/pr90555.c
new file mode 100644
index 00000000000..a9c751cd63c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr90555.c
@@ -0,0 +1,67 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd -O2 -mavx512f -fdump-ipa-icf" } */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+
+#define N 1024
+int a[N];
+
+void
+test_simdlen1 (void)
+{
+ int i;
+ #pragma omp simd simdlen (4)
+ for (i = 0; i < N; ++i)
+ a[i] = a[i] + 1;
+}
+
+void
+test_simdlen2 (void)
+{
+ int i;
+ #pragma omp simd simdlen (8)
+ for (i = 0; i < N; ++i)
+ a[i] = a[i] + 1;
+}
+
+void
+test_safelen1 (void)
+{
+ int i;
+ #pragma omp simd safelen (4)
+ for (i = 0; i < N; ++i)
+ a[i] = a[i] + 1;
+}
+
+void
+test_safelen2 (void)
+{
+ int i;
+ #pragma omp simd safelen (8)
+ for (i = 0; i < N; ++i)
+ a[i] = a[i] + 1;
+}
+
+int d[1024];
+
+int
+test_simduid1 (int j, int b)
+{
+ int l, c = 0;
+#pragma omp simd reduction(+: c)
+ for (l = 0; l < b; ++l)
+ c += d[j + l];
+ return c;
+}
+
+int
+test_simduid2 (int j, int b)
+{
+ int l, c2 = 0;
+#pragma omp simd reduction(+: c2)
+ for (l = 0; l < b; ++l)
+ c2 += d[j + l];
+ return c2;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:test_simduid1->test_simduid2" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */