https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100499
--- Comment #21 from Andrew Macleod <amacleod at redhat dot com> --- > > > > Would this be useful? and would it solve this problem? I'm sure there are > > other details to work out related to the increased precision, but it seems > > like it might work? > > Hmm, so the issue we're facing is asking whether x * 3 is a multiple of 3 > but we have to consider that x * 3 might overflow. For '3' being > power-of-two > overflow doesn't change anything but for some C ((X * C) % S % C) != 0 > (where S is the modulo reduction applied on overflow). > > So it seems that, to be useful, this ranger expression walk would need to be > integrated with multiple_of_p itself. Or we need to restrict calls to > multiple_of_p to those C where S is a multiple of C. (but in principle > multiple_of_p is happy with a symbolic C - not sure if it is ever called with > one though) > We'll add the general expression evaluator, since I think its pretty straightforward and useful in general. And if we then add the ability to indicate an expression may overflow, then multiple_of_p can decide whether that is a check it wants to make or not, and if it is, then it can simply ask. multiple_of_p would simply be a client calling "may_overflow_p (expr)"