]> gcc.gnu.org Git - gcc.git/commit
phiopt: Drop SSA_NAME_RANGE_INFO in maybe equal case [PR108166]
authorJakub Jelinek <jakub@redhat.com>
Thu, 22 Dec 2022 11:52:48 +0000 (12:52 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 22 Dec 2022 11:52:48 +0000 (12:52 +0100)
commit5c17adfb5d08e34da7a7f234dfc2ed1f0aaadaa9
tree074a124b4bfb86b74decdc4e6542f241ae69808f
parent0cb5d7cdbab8e5f8359764ef5f62d93c2bc88552
phiopt: Drop SSA_NAME_RANGE_INFO in maybe equal case [PR108166]

The following place in value_replacement is after proving that
x == cst1 ? cst2 : x
phi result is only used in a comparison with constant which doesn't
care if it compares cst1 or cst2 and replaces it with x.
The testcase is miscompiled because we have after the replacement
incorrect range info for the phi result, we would need to
effectively union the phi result range with cst1 (oarg in the code)
because previously that constant might be missing in the range, but
newly it can appear (we've just verified that the single use stmt
of the phi result doesn't care about that value in particular).

The following patch just resets the info, bootstrapped/regtested
on x86_64-linux and i686-linux, ok for trunk?

Aldy/Andrew, how would one instead union the SSA_NAME_RANGE_INFO
with some INTEGER_CST and store it back into SSA_NAME_RANGE_INFO
(including adjusting non-zero bits and the like)?

2022-12-22  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108166
* tree-ssa-phiopt.cc (value_replacement): For the maybe_equal_p
case turned into equal_p reset SSA_NAME_RANGE_INFO of phi result.

* g++.dg/torture/pr108166.C: New test.
gcc/testsuite/g++.dg/torture/pr108166.C [new file with mode: 0644]
gcc/tree-ssa-phiopt.cc
This page took 0.057768 seconds and 5 git commands to generate.