http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46374
Summary: Add nooverflow attribute
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: lfs...@gmail.com
When representing a small width unsigned integer in a larger width register,
the compiler has to clear the upper bits of the register before many
expressions, notably shift rights and comparisons. Consider the additional
instructions that have to be inserted in the following code, as opposed to a
signed version in a cpu that always passes parameters in full registers, such
as the ARM.
bool
f (uint16_t x, uint16_t y)
{
return x + 8 == y - 17;
}
It would be helpful if the compiler provided something such as a type attribute
nooverflow that would indicate no overflow involving values of the
corresponding unsigned type may occur. This way, not only this problem is
solved, but optimizations analogous to the ones involving signed values would
apply to these unsigned ones (such as turning for (i = 1; i != 0; ++i) into an
infinite loop).
I respect you possible decision to ignore this report. This is a mere
suggestion. Also, if you consider this a bad idea, please explain why.
Thank you for your attention.