Don't register nonsensical relations.

gcc/
	PR tree-optimization/103003
	* value-relation.cc (dom_oracle::register_relation): If the 2
	ssa names are the same, don't register any relation.

	gcc/testsuite/
	* gcc.dg/pr103003.c: New.
This commit is contained in:
Andrew MacLeod 2021-10-30 11:00:49 -04:00
parent 14d3140405
commit 0187c03be3
2 changed files with 19 additions and 1 deletions

View file

@ -0,0 +1,12 @@
/* { dg-do compile } */
/* { dg-options "-O2" } */
typedef char int8_t;
int8_t c_4, uli_5;
unsigned short us_6;
void func_1() {
int uli_9;
short ptr_16ptr_11 = &uli_9; /* { dg-warning "initialization of*" } */
for (; us_6 <= 6;)
if ((us_6 *= uli_9) < (uli_5 || 0) ?: ((c_4 = us_6) >= us_6) - uli_5)
uli_9 = 9;
}

View file

@ -877,7 +877,13 @@ relation_oracle::register_edge (edge e, relation_kind k, tree op1, tree op2)
void
dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1,
tree op2)
{ // Equivalencies are handled by the equivalence oracle.
{
// If the 2 ssa_names are the same, do nothing. An equivalence is implied,
// and no other relation makes sense.
if (op1 == op2)
return;
// Equivalencies are handled by the equivalence oracle.
if (k == EQ_EXPR)
equiv_oracle::register_relation (bb, k, op1, op2);
else