From 59eefaa6dfaac01e645dadf727f25775f5d3aeed Mon Sep 17 00:00:00 2001
From: Ira Rosen <irar@il.ibm.com>
Date: Sun, 18 Apr 2010 12:20:34 +0000
Subject: [PATCH] re PR tree-optimization/43771 (ICE on valid when compiling
 ParMetis with gcc 4.5.0 and -O3)

	PR tree-optimization/43771
	* tree-vect-slp.c (vect_supported_load_permutation_p): Check that
	load permutation doesn't have gaps.

From-SVN: r158484
---
 gcc/ChangeLog                        |  6 ++++++
 gcc/testsuite/ChangeLog              |  5 +++++
 gcc/testsuite/g++.dg/vect/pr43771.cc | 14 ++++++++++++++
 gcc/tree-vect-slp.c                  |  6 +++++-
 4 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/vect/pr43771.cc

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 912670d50ddc..f88ff216565b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-04-18 Ira Rosen <irar@il.ibm.com> 
+
+	PR tree-optimization/43771
+	* tree-vect-slp.c (vect_supported_load_permutation_p): Check that
+	load permutation doesn't have gaps.
+
 2010-04-18  Jan Hubicka  <jh@suse.cz>
 
 	* i386.md (UNSPEC_SSE_PROLOGUE_SAVE_LOW): New.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a926c8435343..901a727587c4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-18 Ira Rosen <irar@il.ibm.com>
+
+	PR tree-optimization/43771
+	* g++.dg/vect/pr43771.cc: New test.
+
 2010-04-17  Steven G. Kargl  <kargl@gcc.gnu.org>
 
    PR fortran/31538
diff --git a/gcc/testsuite/g++.dg/vect/pr43771.cc b/gcc/testsuite/g++.dg/vect/pr43771.cc
new file mode 100644
index 000000000000..1a2d09aae932
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr43771.cc
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+void KWayNodeRefine__(int nparts, int *gpwgts, int *badminpwgt, int
+*badmaxpwgt)
+{
+   int i;
+
+   for (i=0; i<nparts; i+=2) {
+       badminpwgt[i] = badminpwgt[i+1] = gpwgts[i]+gpwgts[i+1];
+       badmaxpwgt[i] = badmaxpwgt[i+1] = gpwgts[i]+gpwgts[i+1];
+   }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index d25d34787e0c..afc4f3110782 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -844,7 +844,11 @@ vect_supported_load_permutation_p (slp_instance slp_instn, int group_size,
 
       SET_BIT (load_index, prev);
     }
-  
+ 
+  for (j = 0; j < group_size; j++)
+    if (!TEST_BIT (load_index, j))
+      return false;
+
   sbitmap_free (load_index);
 
   if (supported && i == group_size * group_size
-- 
GitLab