[Bug target/30484] INT_MIN % -1 is well defined for -fwrapv

vincent-gcc at vinc17 dot net gcc-bugzilla@gcc.gnu.org
Mon Aug 23 21:06:58 GMT 2021


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

--- Comment #14 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Well, you could change the definition of -fwrapv in the same way that the
standard has changed. I mean that the intent of making INT_MIN / -1 undefined
was *only* for a performance reason (not for a mathematical reason). Normally,
-fwrapv should be as fast as without it (except for some optimizations like
VRP, but I would actually expect a program based on -fwrapv to be faster in
general, because the programmer does not have to care about intermediate
overflows). However, if INT_MIN % -1 is defined with -fwrapv, you get a
performance penalty. And ditto for INT_MIN / -1.


More information about the Gcc-bugs mailing list