https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85512

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to ktkachov from comment #2)
> Indeed a SSHR by zero is not valid.
> One would hope that the optimisers would have eliminated the shift by zero

It can't be guaranteed.  The reason the __builtin_add_overflow_p is not
optimized into constant earlier is the UB in it, where it uses uninitialized
argument, so we don't fold it into constant at gimple nor during combine, but
later.
Given that this will happen rarely, we don't need to optimize it perfectly, it
is fine to force the shift count into a register, at least the constraints need
to be accurate though, I think it is fine if the predicates allow the 0, RA
should be able to cope with it hopefully.

Reply via email to