jkmcnk / sx-gcc

The GNU Compiler Collection port to NEC SX CPU architecture.
GNU General Public License v2.0
0 stars 2 forks source link

umodsi insertion is wrong #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
when encountering umodsi3 insertion, we simply emit the modsi3 insertion.
this is, of course, wrong. we need to fix it so that it handles *unsigned*
modulo correctly.

also, we should check the signed modulo, when the divisor is a negative
integer. ISO C standard states that "the binary % operator yields the
remainder from the division of the first expression by the second. .... If
both operands are nonnegative then the remainder is nonnegative; if not,
the sign of the remainder is implementation-defined." however, gcc conforms
to the euclidean definition of modulo (at least my tests suggest this),
which constrains the remainder to positive numbers. thus, 5 % -3 = 2.

this issue touches test case gcc.c-torture/execute/980526-3.c

Original issue reported on code.google.com by jmoc...@gmail.com on 8 Dec 2008 at 3:32

GoogleCodeExporter commented 8 years ago
of course, the above has to do with expands, not insns.

fixed with r159, which also fixes udivsi3 expand.

Original comment by jmoc...@gmail.com on 9 Dec 2008 at 1:06