[Bug gcov-profile/100145] missed optimization for dead code elimination at -O3 (vs. -O2)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100145 --- Comment #4 from Andrew Pinski --- (In reply to Richard Biener from comment #2) > So we get optimize_edge_for_size_p () returning OPTIMIZE_SIZE_BALANCED and > thus optimize_edge_for_speed_p which is > > 340 bool > 341 optimize_edge_for_speed_p (edge e) > 342 { > 343 return !optimize_edge_for_size_p (e); > 344 } > > return false. And that's likely because this is 'main'. Yes it is. If we do s/main/c123/ And then add: ``` int main() { return c123(); } ``` The -O3 issue goes away.
[Bug gcov-profile/100145] missed optimization for dead code elimination at -O3 (vs. -O2)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100145 --- Comment #3 from Richard Biener --- Note after inlining we still have a backedge into BB 3: [local count: 1073741824]: c = 0; b.1_7 = b; if (b.1_7 != 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: _9 = 1; _10 = 0; _11 = _9 & _10; if (_11 != 0) goto ; [50.00%] else goto ; [50.00%] [local count: 1659419208]: _12 = 0; _13 = _10 & _12; if (_13 != 0) goto ; [50.00%] else goto ; [50.00%] [local count: 829709603]: iftmp.0_14 = 1; [local count: 3318838410]: # iftmp.0_15 = PHI <0(3), 0(4), iftmp.0_14(5)> _19 = iftmp.0_15; _8 = _19; c = _8; if (_8 != 0) goto ; [11.00%] else goto ; [89.00%] [local count: 1073741824]: but that's quickly elided by CCP after inlining producing [local count: 1073741824]: c = 0; b.1_7 = b; if (b.1_7 != 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: if (0 != 0) goto ; [50.00%] else goto ; [50.00%] [local count: 1659419208]: if (0 != 0) goto ; [50.00%] else goto ; [50.00%] [local count: 829709603]: [local count: 3318838410]: c = 1; if (1 != 0) goto ; [11.00%] else goto ; [89.00%] [local count: 1073741824]: and the CFG cleanup ends up with the following: [local count: 1073741824]: c = 0; b.1_7 = b; if (b.1_7 != 0) goto ; [34.00%] else goto ; [66.00%] [local count: 3318838410]: c = 1; [local count: 1073741824]: d = 1; _1 = c; if (_1 > 100) goto ; [33.00%] else goto ; [67.00%] [local count: 354334800]: foo (); [local count: 1073741824]: return 0;
[Bug gcov-profile/100145] missed optimization for dead code elimination at -O3 (vs. -O2)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100145 Richard Biener changed: What|Removed |Added Component|ipa |gcov-profile --- Comment #2 from Richard Biener --- So we get optimize_edge_for_size_p () returning OPTIMIZE_SIZE_BALANCED and thus optimize_edge_for_speed_p which is 340 bool 341 optimize_edge_for_speed_p (edge e) 342 { 343 return !optimize_edge_for_size_p (e); 344 } return false. And that's likely because this is 'main'. At -O2 BB counts are broken: [local count: 1073741824]: c = 0; b.1_7 = b; if (b.1_7 != 0) goto ; [34.00%] else goto ; [66.00%] [local count: 708669600]: goto ; [100.00%] [local count: 3318838410]: c = 1; [local count: 1073741824]: d = 1; here 3->4 artificially appears 'hot'. The bogus counts appear during IPA inlining of g() into main.