tree-ssa-uninit: avoid ICE with BIT_AND_EXPR (PR 90394)

2019-05-16  Vladislav Ivanishin  <vlad@ispras.ru>

	PR tree-optimization/90394
	* tree-ssa-uninit.c (is_pred_expr_subset_of): Potentially give false
	positives rather than ICE for cases where (code2 == NE_EXPR
	&& code1 == BIT_AND_EXPR).

testsuite/
	* gcc.dg/uninit-pr90394-1-gimple.c: New test.
	* gcc.dg/uninit-pr90394.c: New test.

From-SVN: r271287
This commit is contained in:
Vladislav Ivanishin 2019-05-16 12:36:33 +00:00 committed by Alexander Monakov
parent 0bc229dbbe
commit 74a96dd28c
5 changed files with 94 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2019-05-16 Vladislav Ivanishin <vlad@ispras.ru>
PR tree-optimization/90394
* tree-ssa-uninit.c (is_pred_expr_subset_of): Potentially give false
positives rather than ICE for cases where (code2 == NE_EXPR
&& code1 == BIT_AND_EXPR).
2019-05-16 Jakub Jelinek <jakub@redhat.com>
PR fortran/90329

View File

@ -1,3 +1,9 @@
2019-05-16 Vladislav Ivanishin <vlad@ispras.ru>
PR tree-optimization/90394
* gcc.dg/uninit-pr90394-1-gimple.c: New test.
* gcc.dg/uninit-pr90394.c: New test.
2019-05-16 Richard Biener <rguenther@suse.de>
PR testsuite/90502

View File

@ -0,0 +1,47 @@
/* { dg-do compile } */
/* { dg-options "-fgimple -O -Wmaybe-uninitialized" } */
unsigned int __GIMPLE (ssa,startwith("uninit1"))
foo (unsigned int v)
{
/* The warning is not bogus, because (5 & 3) != 0 and therefore if v == 5,
the value of undef is used without being initialized. */
unsigned int undef; /* { dg-warning "may be used uninitialized" } */
unsigned int _2;
unsigned int _9;
unsigned int _10;
unsigned pred;
__BB(2):
if (v_4(D) != 5u)
goto __BB3;
else
goto __BB4;
/* 'undef' is defined conditionally (under 'v != 5' predicate) */
__BB(3):
undef_8 = 8u;
goto __BB4;
/* An undef value flows into a phi. */
__BB(4):
undef_1 = __PHI (__BB2: undef_5(D), __BB3: undef_8);
pred = v_4(D) & 3u;
if (pred != 0u)
goto __BB5;
else
goto __BB6;
/* The phi value is used here (under 'v & 3' predicate). */
__BB(5):
_9 = undef_1;
goto __BB7;
__BB(6):
_10 = v_4(D);
goto __BB7;
__BB(7):
_2 = __PHI (__BB5: _9, __BB6: _10);
return _2;
}

View File

@ -0,0 +1,33 @@
/* { dg-do compile } */
/* { dg-options "-O1 -fno-tree-fre -Wuninitialized" } */
int pz;
int zi;
void
uk (void)
{
int th = 1;
int *gw = &zi;
for (zi = 0; zi < 2; ++zi)
{
int a2 = 0;
for (zi = 0; zi < 1; ++zi)
{
th = a2 * 2;
og:
for (pz = 0; pz < 1; ++pz)
{
}
}
pz = !!*gw ? *gw : pz;
pz = (!!th ? (pz & 1) : 0);
if (pz == 0)
++a2;
}
goto og;
}

View File

@ -1471,7 +1471,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2)
if (code2 == NE_EXPR && code1 == NE_EXPR)
return false;
if (code2 == NE_EXPR)
if (code2 == NE_EXPR && code1 != BIT_AND_EXPR)
return !is_value_included_in (expr2.pred_rhs, expr1.pred_rhs, code1);
if ((code1 == EQ_EXPR || code1 == BIT_AND_EXPR) && code2 == BIT_AND_EXPR)