Commit 7088053c authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ir: Cleanup and correct comments of smaller_mode().

parent 8a165c89
......@@ -291,7 +291,7 @@ FIRM_API int mode_is_data (const ir_mode *mode);
* Returns true if a value of mode @p sm can be converted to mode @p lm without
* loss.
*
* That is the interpretation of the numbers does not changes, so you a signed
* That is the interpretation of the numbers does not changes, so a signed
* integer mode is never smaller than an unsigned integer mode since the
* unsigned mode can't represent negative numbers in a way that they are
* interpreted as negative numbers.
......@@ -304,7 +304,7 @@ FIRM_API int smaller_mode(const ir_mode *sm, const ir_mode *lm);
* Returns true if no information is lost when converting a value of mode @p sm
* into mode @p lm (and back to mode @p sm).
*
* So the interpretation of the values may change in the intermediate mode @p sm
* So the interpretation of the values may change in the intermediate mode @p lm
* (for example when converting negative signed integer numbers into unsigned
* integers) but after a conversion back they are exactly the same value.
*
......
......@@ -356,24 +356,18 @@ int smaller_mode(const ir_mode *sm, const ir_mode *lm)
assert(get_mode_arithmetic(sm) == irma_twos_complement);
/* integers are convertable if
* - both have the same sign and lm is the larger one
* - lm is the signed one and is at least two bits larger
* (one for the sign, one for the highest bit of sm)
* - sm & lm are two_complement and lm has greater or equal
* number of bits
*/
* - both have the same sign and lm is the larger one
* - lm is signed and is at least one bit larger (the sign) */
unsigned sm_bits = get_mode_size_bits(sm);
unsigned lm_bits = get_mode_size_bits(lm);
if (mode_is_signed(sm)) {
if (!mode_is_signed(lm))
return 0;
return sm_bits <= lm_bits;
return false;
} else {
if (mode_is_signed(lm)) {
if (mode_is_signed(lm))
return sm_bits < lm_bits;
}
return sm_bits <= lm_bits;
}
return sm_bits <= lm_bits;
case irms_auxiliary:
case irms_data:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment