https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108847
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Just for reference here are the functions I tried to see which way was the best (set_bool0 and set_bool0_ produce the best for x86): void set_bool(bool& fl, __UINT32_TYPE__ value) { bool t = fl; __UINT32_TYPE__ t1 = value>>31; __UINT32_TYPE__ t2 = t; t = t2 | t1; fl = t; } void set_bool0(bool& fl, __UINT32_TYPE__ value) { bool t = fl; __UINT32_TYPE__ t1 = value>>31; bool t3 = t1; t = t | t3; fl = t; } void set_bool0_(bool& fl, __INT32_TYPE__ value) { bool t = fl; __UINT32_TYPE__ t1 = value<0; bool t3 = t1; t = t | t3; fl = t; } void set_bool1(bool& fl, __UINT32_TYPE__ value) { fl |= value >> 31; }