https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85344
--- Comment #17 from Segher Boessenkool <segher at gcc dot gnu.org> --- When you cast to *signed* short instead, you get -32768, at tree level already. And that is correct. This is not the problem here. With the "unsigned short" code, f() here, you get +32768 at tree level, also correct. And then somehow cfgexpand messes it up (hard to say where exactly, expand_asm_stmt is >700 lines already, and the problem probably happens in one or more of its callees!)