diff mbox

Fix PR63665

Message ID alpine.LSU.2.11.1410281354540.19560@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 28, 2014, 12:55 p.m. UTC
It seems that SLP vectorization can somehow generate out-of-bound
masks for VEC_PERM.  The following fixes that (the ICE reproduces
on x86_64 with the added assert).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2014-10-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/63665
	* tree-vect-slp.c (vect_get_mask_element): Properly handle
	accessing out-of-bound elements.

Comments

Eric Botcazou Oct. 29, 2014, 9:04 a.m. UTC | #1
> 2014-10-28  Richard Biener  <rguenther@suse.de>
> 
> 	PR tree-optimization/63665
> 	* tree-vect-slp.c (vect_get_mask_element): Properly handle
> 	accessing out-of-bound elements.

Does fix it the assertion failure on the attached testcase?  If so, would you 
mind committing the testcase with the patch?


	* gnat.dg/opt42.ad[sb]: New test.
Richard Biener Oct. 29, 2014, 9:41 a.m. UTC | #2
On Wed, Oct 29, 2014 at 10:04 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> 2014-10-28  Richard Biener  <rguenther@suse.de>
>>
>>       PR tree-optimization/63665
>>       * tree-vect-slp.c (vect_get_mask_element): Properly handle
>>       accessing out-of-bound elements.
>
> Does fix it the assertion failure on the attached testcase?  If so, would you
> mind committing the testcase with the patch?

Sorry - I saw this mail too late.  The assert already triggers various
existing tests in gcc.dg/vect on x86_64-linux so I didn't add a new one.

Feel free to add the test if you think more Ada coverage is warranted here.

Thanks,
Richard.

>
>         * gnat.dg/opt42.ad[sb]: New test.
>
>
> --
> Eric Botcazou
diff mbox

Patch

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	(revision 216771)
+++ gcc/tree-vect-slp.c	(working copy)
@@ -2890,7 +2890,7 @@  vect_get_mask_element (gimple stmt, int
     }
 
   /* The mask requires the next vector.  */
-  if (*current_mask_element >= mask_nunits * 2)
+  while (*current_mask_element >= mask_nunits * 2)
     {
       if (*needs_first_vector || *mask_fixed)
         {
@@ -3041,6 +3041,7 @@  vect_transform_slp_perm_load (slp_tree n
 					  &number_of_mask_fixes, &mask_fixed,
 					  &needs_first_vector))
 		return false;
+	      gcc_assert (current_mask_element < 2 * nunits);
 	      mask[index++] = current_mask_element;
 
               if (index == nunits)