Fix compute_operand when op1 == op2 symbolically.
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 24 Mar 2023 15:21:20 +0000 (11:21 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 28 Mar 2023 13:32:40 +0000 (09:32 -0400)
commitdd63bba0c8dc3a6ae06cfdc084bca7c68b8bbd39
tree82687825d14c3850b6bcb16dba5a7e3bb17243cf
parent2b9d76c1af189b918a9970f471e6d2e2c08f7e7d
Fix compute_operand when op1 == op2 symbolically.

First, class value_relation should not sanitize records. just create
what is asked.

Second., if there is not a relation record, compute_operand was
creating one for op1 == op2 if op1 and op2 were the same symbol.   This
is not the correct way to communicate the information, as that record
will continue to be passed along the GORI unwind chain.

Instead, simply pass that information locally to the opX_range routine
for only the current statement.

PR tree-optimization/109265
PR tree-optimization/109274
gcc/
* gimple-range-gori.cc (gori_compute::compute_operand_range): Do
not create a relation record is op1 and op2 are the same symbol.
(gori_compute::compute_operand1_range): Pass op1 == op2 to the
handler for this stmt, but create a new record only if this statement
generates a relation based on the ranges.
(gori_compute::compute_operand2_range): Ditto.
* value-relation.h (value_relation::set_relation): Always create the
record that is requested.

gcc/testsuite/
* gcc.dg/pr109274.c: New.
* gfortran.dg/pr109265.f90: New.
gcc/gimple-range-gori.cc
gcc/testsuite/gcc.dg/pr109274.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr109265.f90 [new file with mode: 0644]
gcc/value-relation.h