[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2024-03-10 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

--- Comment #6 from Jan Hubicka  ---
The reason why GIMPLE_PREDICT is ignored is that it is never used after ipa-icf
and gets removed at the very beggining of late optimizations.  

GIMPLE_PREDICT is consumed by profile_generate pass which is run before
ipa-icf.  The reason why GIMPLE_PREDICT statements are not stripped during ICF
is early inlining.  If we early inline, we throw away its profile and estimate
it again (in the context of function it was inlined to) and for that it is a
good idea to keep predicts.

There is no convenient place to remove them after early inlining was done and
before IPA passes and that is the only reason why they are around.  We may
revisit that since streaming them to LTO bytecode is probably more harmful then
adding extra pass after early opts to strip them.

ICF doesn't code to compare edge profiles and stmt histograms.  It knows how to
merge them (so resulting BB profile is consistent with merging) but I suppose
we may want to have some threshold on when we do not want to marge functions
with very different branch probabilities in the hot part of their bodies...

[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2023-09-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

Andrew Pinski  changed:

   What|Removed |Added

 CC||moncef.mechri at gmail dot com

--- Comment #5 from Andrew Pinski  ---
*** Bug 111297 has been marked as a duplicate of this bug. ***

[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2022-08-23 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed||2022-08-23
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Keywords||missed-optimization

--- Comment #4 from Richard Biener  ---
Confirmed.

[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2022-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

--- Comment #3 from Andrew Pinski  ---

[[unlikely]]/[[likely]] attribute gets expanded into
PREDICT_EXPR:PRED_HOT_LABEL/PRED_COLD_LABEL:TAKEN/NOT_TAKEN see
cp/cp-gimplify.cc (process_stmt_hotness_attribute) and is removed.
And that is all done in the front-end.

PREDICT_EXPR gets expanded into GIMPLE_PREDICT (via gimplify_expr in
gimplify.cc)

And then the code in sem_function::init ignores GIMPLE_PREDICT .

Which was done in r5-7496-a8d9381738d22
(https://gcc.gnu.org/pipermail/gcc-patches/2015-March/413730.html )

[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2022-08-22 Thread tomerv at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

--- Comment #2 from Tomer Vromen  ---
IMO, attribute information should be checked in this optimization stage, so
that ipa-icf knows the functions are different. It seems like maybe this is
already partially the behavior - removing the attribute from one of the
functions makes them different again after ipa-icf. Maybe the existence of the
attribute is considered, but not its value? There's some code in
sem_item::compare_referenced_symbol_properties() that looks like it's trying to
do this.

[Bug ipa/106716] Identical Code Folding (-fipa-icf) confuses between functions with different [[likely]] attributes

2022-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106716

--- Comment #1 from Andrew Pinski  ---
I suspect fipa-icf does not compare the branch predication data while doing the
comparison. I don't know if this is the right thing to do or not. Because if
there was exact data from profiling feedback then it would not merge any
function ...