middle-end/101156 - remove not working optimization in gimplification
authorRichard Biener <rguenther@suse.de>
Tue, 22 Jun 2021 10:13:44 +0000 (12:13 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 22 Jun 2021 13:31:04 +0000 (15:31 +0200)
commitb4e21c80462682c4e6e5e487fe87107b27f8b4bd
treed61d2d580aa7b0f7edbcb668f2aacdca003289af
parent3adb9ac6626c15ba21e4eaf27fec95688a3ca8c2
middle-end/101156 - remove not working optimization in gimplification

This removes a premature and not working optimization from the
gimplifier.  When gimplification is requested not to produce a SSA
name we try to avoid generating a copy when we did so anyway but
instead replace the LHS of its definition.  But that only works in
case there are no uses of the SSA name already which is something
we cannot easily check, so the following removes said optimization.

Statistics on the whole bootstrap shows we hit this optimization
only for libiberty/cp-demangle.c and overall we have 21652112
gimplifications where just 240 copies are elided.  Preserving
the optimization would require scanning the original expression
and the pre and post sequences for SSA names and uses, that seems
excessive to avoid these 240 copies.

2021-06-22  Richard Biener  <rguenther@suse.de>

PR middle-end/101156
* gimplify.c (gimplify_expr): Remove premature incorrect
optimization.

* gcc.dg/pr101156.c: New testcase.
gcc/gimplify.c
gcc/testsuite/gcc.dg/pr101156.c [new file with mode: 0644]