On 03/18/2014 07:25 AM, Peter Maydell wrote: > Why do you think this? tcg/README says out of > range shifts are undefined behaviour. That means we > mustn't execute them, and this code doesn't attempt > to branch around or otherwise avoid the shift by -1.
Bah. Stuff and nonsense. None of our backends are so stupid as to start WWIII with an out of range input. For most backends, the shift count gets (partially) masked as it is inserted into the immediate field. Then either the cpu considers a large shift as producing zero (arm), or fully masks the input (everyone else). Though indeed, Sparc considers an out of range shift immediate as an illegal instruction, so we have an extra step in the backend for exactly this case: do_shift32: /* Limit immediate shift count lest we create an illegal insn. */ tcg_out_arithc(s, args[0], args[1], args[2] & 31, const_args[2], c); break; > The docs say undefined behaviour, not undefined > result value... (Is there a C standard term for > the latter?) The README is hardly standard-ese. Don't read it like it's been written that way. The term from C you're looking for is unspecified behaviour. r~