https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115636
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So looking at what LLVM does (Note it does not handle the original case here). It only handles the simple: `1 << (a ? b : 1000)` cases. That is: ``` int f0(int a, int b) { if (a) b = 1000; int t = 1 << b; return t; } ``` is optimized to `1 << b` without the condition. But once you add something more complex in the condition, it does not do anything: ``` int g(); int f1(int a, int b) { if (a) b = 1000; else b = g(); int t = 1 << b; g(); return t; } int f2(int a, int b) { if (a) b = 1000; else g(); int t = 1 << b; g(); return t; } ``` changing f0 to be: ``` if (a) t = 0; else t = 1 << b; ``` Generates worse code for that. I have to think this one through a little more I think ... undefined behavior is fun.