[Bug lto/82027] [5/6/7/8 Regression] wrong code with -O3 -flto
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Aug 30 09:41:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82027
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
Assignee|marxin at gcc dot gnu.org |unassigned at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Interesting problem, first we IPA CP creates a clone:
Evaluating opportunities for calcPercent/34.
- considering value "" for param #1 const char * (caller_count: 1)
good_cloning_opportunity_p (time: 2, size: 12, freq_sum: 4532) ->
evaluation: 755, threshold: 500
Creating a specialized node of calcPercent/34.
adding an extra known polymorphic context Speculative outer type:struct
Position (or a derived type) at offset 0 for param #0 struct Combined * const
replacing param #1 const char * with const ""
Accounting size:3.00, time:2.85 on predicate:(true)
Accounting size:4.00, time:2.85 on new predicate:(not inlined)
Accounting size:1.00, time:1.00 on new predicate:(op2 changed)
Accounting size:1.00, time:10.00 on new predicate:(op2 changed
|| op3 changed)
the new node is calcPercent.constprop/69.
known ctx 0 is Speculative outer type:struct Position (or a derived
type) at offset 0
Which is fine. Then we inline the function:
Considering calcPercent.constprop/69 with 12 size
to be inlined into _ZThn8_N8Combined11calcPercentEPKcii.artificial_thunk.1/70
in unknown:-1
Estimated badness is -5.611048, frequency 4.53.
Badness calculation for
_ZThn8_N8Combined11calcPercentEPKcii.artificial_thunk.1/70 ->
calcPercent.constprop/69
size growth 7, time 26 inline hints: declared_inline big_speedup
-0.175345: guessed profile. frequency 4.532000, count 0 caller count 0
time w/o inlining 318.428000, time w/ inlining 259.512000 overall growth -5
(current) -5 (original) -5 (compensated)
Adjusted by hints -5.611048
Accounting size:3.00, time:12.90 on predicate:(true)
Accounting size:1.00, time:4.53 on predicate:(true)
Accounting size:1.00, time:45.32 on predicate:(true)
Processing frequency calcPercent.constprop
Called by _ZThn8_N8Combined11calcPercentEPKcii.artificial_thunk.1 that is
normal or hot
Inlined into _ZThn8_N8Combined11calcPercentEPKcii.artificial_thunk.1 which now
has time 12 and size 5, net change of -5.
New minimal size reached: 95
The caller is inline copy in main:
Function _ZThn8_N8Combined11calcPercentEPKcii.artificial_thunk.1/70 is inline
copy in main/37
And somewhere here there must be a function signature discrepancy because we
end in ltrans with:
<bb 5> [67.99%]:
_47 = _16 + 18446744073709551608;
pos_40 = (int) "";
_41 = pos_40 * 100;
percent_42 = _41 / pos_15;
_43 = MEM[(struct Combined *)_47].m_percent;
if (percent_42 != _43)
goto <bb 6>; [69.50%]
else
goto <bb 8>; [30.50%]
Note that original function does:
void calcPercent( const char *name,int pos,int size )
{
int percent = 100*pos/size;
if( percent!=m_percent )
m_percent = percent;
}
So arguments are shifted by one. Martin can you please take a look?
More information about the Gcc-bugs
mailing list