tree-optimization/95295 - fix wrong-code with SM
We failed to compare the rematerialized store values when merging paths after walking PHIs. 2020-05-25 Richard Biener <rguenther@suse.de> PR tree-optimization/95295 * tree-ssa-loop-im.c (sm_seq_valid_bb): Compare remat stores RHSes and drop to full sm_other if they are not equal. * gcc.dg/torture/pr95295-1.c: New testcase. * gcc.dg/torture/pr95295-2.c: Likewise. * gcc.dg/torture/pr95283.c: Likewise.
This commit is contained in:
parent
c0e27f7235
commit
4acca1c063
@ -1,3 +1,9 @@
|
||||
2020-05-25 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/95295
|
||||
* tree-ssa-loop-im.c (sm_seq_valid_bb): Compare remat stores
|
||||
RHSes and drop to full sm_other if they are not equal.
|
||||
|
||||
2020-05-25 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/95271
|
||||
|
@ -1,3 +1,10 @@
|
||||
2020-05-25 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/95295
|
||||
* gcc.dg/torture/pr95295-1.c: New testcase.
|
||||
* gcc.dg/torture/pr95295-2.c: Likewise.
|
||||
* gcc.dg/torture/pr95283.c: Likewise.
|
||||
|
||||
2020-05-25 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/95271
|
||||
|
19
gcc/testsuite/gcc.dg/torture/pr95283.c
Normal file
19
gcc/testsuite/gcc.dg/torture/pr95283.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* { dg-do compile } */
|
||||
|
||||
short c;
|
||||
_Bool d;
|
||||
unsigned e, f;
|
||||
char g, h;
|
||||
extern _Bool i[];
|
||||
void j()
|
||||
{
|
||||
for (char a = 0; a < 100; a++)
|
||||
for (char b = 0; b < 20; b += 2)
|
||||
{
|
||||
if (e)
|
||||
d = f = 0;
|
||||
else
|
||||
g = i[8] = 0;
|
||||
h = c;
|
||||
}
|
||||
}
|
15
gcc/testsuite/gcc.dg/torture/pr95295-1.c
Normal file
15
gcc/testsuite/gcc.dg/torture/pr95295-1.c
Normal file
@ -0,0 +1,15 @@
|
||||
/* { dg-do run } */
|
||||
/* { dg-additional-sources "pr95295-2.c" } */
|
||||
|
||||
extern int var_4, a;
|
||||
extern unsigned var_9;
|
||||
extern short arr_272[];
|
||||
void test()
|
||||
{
|
||||
for (int b = 0; b < 9; b++)
|
||||
for (int c = 0; c < 9; c += 4)
|
||||
{
|
||||
arr_272[c] = var_9 ? var_4 : 0;
|
||||
a = 0;
|
||||
}
|
||||
}
|
14
gcc/testsuite/gcc.dg/torture/pr95295-2.c
Normal file
14
gcc/testsuite/gcc.dg/torture/pr95295-2.c
Normal file
@ -0,0 +1,14 @@
|
||||
/* { dg-do compile } */
|
||||
|
||||
int a;
|
||||
int var_4 = 1;
|
||||
unsigned var_9 = 8;
|
||||
short arr_272[20];
|
||||
void test();
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
if (arr_272[4] != 1)
|
||||
__builtin_abort ();
|
||||
return 0;
|
||||
}
|
@ -2402,6 +2402,7 @@ sm_seq_valid_bb (class loop *loop, basic_block bb, tree vdef,
|
||||
if (edge_seq[i].second == sm_ord)
|
||||
bitmap_set_bit (refs_not_supported, edge_seq[i].first);
|
||||
first_edge_seq[i].second = sm_other;
|
||||
first_edge_seq[i].from = NULL_TREE;
|
||||
}
|
||||
/* sm_other prevails. */
|
||||
else if (first_edge_seq[i].second != edge_seq[i].second)
|
||||
@ -2410,7 +2411,14 @@ sm_seq_valid_bb (class loop *loop, basic_block bb, tree vdef,
|
||||
gcc_assert (bitmap_bit_p (refs_not_supported,
|
||||
first_edge_seq[i].first));
|
||||
first_edge_seq[i].second = sm_other;
|
||||
first_edge_seq[i].from = NULL_TREE;
|
||||
}
|
||||
else if (first_edge_seq[i].second == sm_other
|
||||
&& first_edge_seq[i].from != NULL_TREE
|
||||
&& (edge_seq[i].from == NULL_TREE
|
||||
|| !operand_equal_p (first_edge_seq[i].from,
|
||||
edge_seq[i].from, 0)))
|
||||
first_edge_seq[i].from = NULL_TREE;
|
||||
}
|
||||
/* Any excess elements become sm_other since they are now
|
||||
coonditionally executed. */
|
||||
|
Loading…
Reference in New Issue
Block a user