]> gcc.gnu.org Git - gcc.git/commit
tree-optimization/107852 - missed optimization with PHIs
authorRichard Biener <rguenther@suse.de>
Tue, 29 Nov 2022 11:56:22 +0000 (12:56 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 29 Nov 2022 13:30:35 +0000 (14:30 +0100)
commitfd8dd6c0384969170e594be34da278a072d5eb76
tree9afc4155efc589af6eb7990d7e8793cfbf503a9a
parent063ba138eaa15ceecf23a24906e0e19be98d509d
tree-optimization/107852 - missed optimization with PHIs

The following deals with the situation where we have

<bb 2> [local count: 1073741824]:
_5 = bytes.D.25336._M_impl.D.24643._M_start;
_6 = bytes.D.25336._M_impl.D.24643._M_finish;
pretmp_66 = bytes.D.25336._M_impl.D.24643._M_end_of_storage;
if (_5 != _6)
  goto <bb 3>; [70.00%]
else
  goto <bb 4>; [30.00%]

...

<bb 6> [local count: 329045359]:
_89 = operator new (4);
_43 = bytes.D.25336._M_impl.D.24643._M_start;
_Num_44 = _137 - _43;
if (_Num_44 != 0)

but fail to see that _137 is equal to _5 and thus eventually _Num_44
is zero if not operator new would possibly clobber the global
bytes variable.

The following resolves this in value-numbering by using the
predicated values for _5 == _6 recorded for the dominating
condition.

PR tree-optimization/107852
* tree-ssa-sccvn.cc (visit_phi): Use equivalences recorded
as predicated values to elide more redundant PHIs.

* gcc.dg/tree-ssa/ssa-fre-101.c: New testcase.
gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-101.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc
This page took 0.05826 seconds and 5 git commands to generate.