https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55177
--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #20) > So the original testcase shows there are missing other bitop related > optimizations on the tree level and conversions. > I have two patches which fix the original issue. > The first patch also fixes: > unsigned foo(unsigned x, int b) > { > int a = x; > a &= b; > x = a; > x |= b; > return x; > } > --- CUT --- > The problem here is: > a_3 = (int) x_2(D); > a_5 = a_3 & b_4(D); > x_6 = (unsigned int) a_5; > > is not optimized to: > _7 = (unsigned int) b_4(D); > x_6 = _6 & x_2(D); > > Which shows up in testcase in comment #0: > _2 = __builtin_bswap32 (x.0_1); > a_6 = (int) _2; > a_7 = a_6 & 1515936861; > a.1_3 = (unsigned int) a_7; > _4 = __builtin_bswap32 (a.1_3); > > Fixing the bitop with convert, we get rid of the two byteswaps in comment #0. That I happened to file as PR 103228 a few days ago but only on accident while looking into a different issue. Since PR 60669 is now fixed, I will test my original patch to fix this.