[patch] Fix SSA corruption with SLP

Eric Botcazou ebotcazou@adacore.com
Sun Mar 27 15:47:00 GMT 2011


Hi,

the attached testcase exhibits a corruption of the SSA form:

t.c: In function 'foo':
t.c:9:10: error: definition in block 2 follows the use
for SSA_NAME: vect_p.7_12 in statement:
# VUSE <.MEM_6(D)>
vect_var_.8_13 = MEM[(struct R *)vect_p.7_12];
t.c:9:10: internal compiler error: verify_ssa failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

introduced by SLP on x86-64 at -O2 -ftree-vectorize -fno-vect-cost-model.

This is a wrong statement rewriting in vectorizable_load.  Before SLP we have:

  D.2687_1 = arg.d2;
  D.2688_2 = arg.d1;
  D.2689_3 = 0.0 - D.2688_2;
  D.2690_4 = D.2687_1 * D.2689_3;
  D.2692.d1 = D.2690_4;

vect_check_interleaving computes that field d1 is accessed before field d2 
because the structure is defined as

struct R {
  double d1;
  double d2;
};

but it's the opposite in the code.  So, in vectorizable_load, first_stmt is the 
load of d1 and new statements are wrongly inserted _after_ the load of d2.
Note that, on release branches (4.5 and 4.6 at least), you get wrong code.

Proposed fix attached.  It adds a GSI parameter to vect_create_data_ref_ptr.
Tested on {i586,x86_64}-suse-linux, OK for the mainline?  And the branches?


2011-03-27  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-vectorizer.h (vect_create_data_ref_ptr): Adjust prototype.
	* tree-vect-data-refs.c (vect_create_data_ref_ptr): Add GSI parameter.
	Insert new statements at it in lieu of STMT.
	(vect_setup_realignment): Adjust call to vect_create_data_ref_ptr.
	* tree-vect-stmts.c (vectorizable_store): Likewise.
	(vectorizable_load): Likewise.


2011-03-27  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/slp-1.c: New test.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 4487 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110327/d468b735/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.c
Type: text/x-csrc
Size: 248 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110327/d468b735/attachment-0001.bin>


More information about the Gcc-patches mailing list