-/* Here detect when we can distribute the truncation down past some arithmetic.
- For example, if adding two longs and converting to an int,
- we can equally well convert both to ints and then add.
- For the operations handled here, such truncation distribution
- is always safe.
- It is desirable in these cases:
- 1) when truncating down to full-word from a larger size
- 2) when truncating takes no work.
- 3) when at least one operand of the arithmetic has been extended
- (as by C's default conversions). In this case we need two conversions
- if we do the arithmetic as already requested, so we might as well
- truncate both and then combine. Perhaps that way we need only one.
-
- Note that in general we cannot do the arithmetic in a type
- shorter than the desired result of conversion, even if the operands
- are both extended from a shorter type, because they might overflow
- if combined in that type. The exceptions to this--the times when
- two narrow values can be combined in their narrow type even to
- make a wider result--are handled by "shorten" in build_binary_op. */
+ /* If TYPE is an enumeral type or a type with a precision less
+ than the number of bits in its mode, do the conversion to the
+ type corresponding to its mode, then do a nop conversion
+ to TYPE. */
+ else if (TREE_CODE (type) == ENUMERAL_TYPE
+ || outprec != GET_MODE_BITSIZE (TYPE_MODE (type)))
+ return build1 (NOP_EXPR, type,
+ convert ((*lang_hooks.types.type_for_mode)
+ (TYPE_MODE (type), TREE_UNSIGNED (type)),
+ expr));
+
+ /* Here detect when we can distribute the truncation down past some
+ arithmetic. For example, if adding two longs and converting to an
+ int, we can equally well convert both to ints and then add.
+ For the operations handled here, such truncation distribution
+ is always safe.
+ It is desirable in these cases:
+ 1) when truncating down to full-word from a larger size
+ 2) when truncating takes no work.
+ 3) when at least one operand of the arithmetic has been extended
+ (as by C's default conversions). In this case we need two conversions
+ if we do the arithmetic as already requested, so we might as well
+ truncate both and then combine. Perhaps that way we need only one.
+
+ Note that in general we cannot do the arithmetic in a type
+ shorter than the desired result of conversion, even if the operands
+ are both extended from a shorter type, because they might overflow
+ if combined in that type. The exceptions to this--the times when
+ two narrow values can be combined in their narrow type even to
+ make a wider result--are handled by "shorten" in build_binary_op. */