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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Macleod from comment #6)
> My other question. so is the issue that unsigned divides are cheaper than
> signed divides?

The middle-end doesn't really know.  On some targets unsigned divides can be
cheaper than signed divides, on others it doesn't matter, it wouldn't surprise
me if there
were targets where signed divides are cheaper than unsigned.  And then there
could
be targets where say unsigned divides aren't implemented in hw and signed ones
are or vice versa (and the other is implemented in libgcc).

On GIMPLE, adding any further casts makes the IL larger and shorter IL is what
we usually consider the canonical case (sure, there can be some exceptions, but
if there are, it is for stuff that is desirable on all targets, not just a
subset of them).

So, the idea is if we from ranges find out that a division or similar operation
can be equivalently implemented as signed or unsigned because the ranges say
that the operands
don't have MSB set when used on the division/modulo stmt, we emit both as RTL
and ask the backend what is cheaper.

Reply via email to