https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111003
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|rguenther at suse dot de |rguenth at gcc dot gnu.org --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- So the only additional hoisting is in LIM4 Moving statement _60 = _13 ^ iftmp.9_18; (cost 1) out of loop 1. Moving statement _62 = _60 == 10; (cost 21) out of loop 1. @@ -239,6 +279,8 @@ goto <bb 31>; [100.00%] <bb 50> [local count: 477815112]: + _60 = _13 ^ iftmp.9_18; + _62 = _60 == 10; <bb 7> [local count: 4343774241]: _9 = a (); @@ -296,8 +338,6 @@ goto <bb 15>; [100.00%] <bb 14> [local count: 14585209535]: - _60 = _13 ^ iftmp.9_18; - _62 = _60 == 10; <bb 15> [local count: 35145083376]: # prephitmp_63 = PHI <0(73), _62(14), 0(74)> and -fdisable-tree-lim4 restores the missed optimization. The difference is then in CCP4 which is able to remove the call to foo() when not hoisting the compare. When not hoisting the global range of _60 is stricter: - # RANGE [irange] unsigned int [0, 511] MASK 0x1c7 VALUE 0x0 - _60 = _13 ^ iftmp.9_18; + # RANGE [irange] unsigned int [0, 16383] MASK 0x3fff VALUE 0x0 + _60 = _13 ^ iftmp.9_18;