https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86604
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2018-07-20 Summary|Compiler can't think of |phiopt missed optimization |smaller variable ranges |of conditional add Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Sure it does but we 1) cannot make the dereference of t unconditional because it may trap, 2) we do not implement the transform if ([0, 1] var == 0) othervar += 1; to othervar += var ^ 1; that's a missed optimization in phiopt. value_replacement handles some cases but not (for unanalyzed reason): #define __builtin_guarantee(a) \ if (!(a)) { \ __builtin_unreachable(); \ } void CreateChecksum(int isTestNet, int *t) { __builtin_guarantee(isTestNet == 0 || isTestNet == 1); int tem = *t; if (isTestNet == 1) tem += 1; *t = tem; } where it could replace the conditional with tem += isTestNet;