tree-optimization/95295 - fix sinking after path merging in new SM code

This fixes a missed sinking of remat stores across unrelated stores
after merging from different paths.

2020-05-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/95295
	* tree-ssa-loop-im.c (sm_seq_valid_bb): Fix sinking after
	merging stores from paths.

	* gcc.dg/torture/pr95295-3.c: New testcase.
This commit is contained in:
Richard Biener
2020-05-27 13:05:07 +02:00
parent 116e3cfc7b
commit 6c8e16aea8
2 changed files with 22 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
/* { dg-do compile } */
extern short var_15, var_20;
extern int var_18, var_21, var_23;
extern _Bool arr_2[];
extern long arr_3[];
void test()
{
var_20 = 1;
for (int a = 0; a < 12; a += 2)
for (short b = 0; b < 8; b += 2) {
arr_2[b] = var_21 = var_18 ? var_15 : 0;
arr_3[b] = 8569;
}
var_23 = -1096835496;
}

View File

@@ -2447,12 +2447,16 @@ sm_seq_valid_bb (class loop *loop, basic_block bb, tree vdef,
unsigned id = first_edge_seq[i].first;
seq.safe_push (first_edge_seq[i]);
unsigned new_idx;
if (first_edge_seq[i].second == sm_ord
if ((first_edge_seq[i].second == sm_ord
|| (first_edge_seq[i].second == sm_other
&& first_edge_seq[i].from != NULL_TREE))
&& !sm_seq_push_down (seq, seq.length () - 1, &new_idx))
{
bitmap_set_bit (refs_not_supported, id);
if (first_edge_seq[i].second == sm_ord)
bitmap_set_bit (refs_not_supported, id);
/* Mark it sm_other. */
seq[new_idx].second = sm_other;
seq[new_idx].from = NULL_TREE;
}
}
return 1;