This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, midlevel]: Handle (int)trunc(float x) cases


On Mon, 11 Apr 2005, Uros Bizjak wrote:
> 2005-04-11  Uros Bizjak  <uros@kss-loka.si>
>
>     * convert.c (convert_to_integer): Convert (long int)trunc{,f,l},
>     and (long long int)ceil{,f,l} into FIX_TRUNC_EXPR.
>
> testsuite:
>
>     * gcc.dg/builtins-53.c: Also check (int)trunc* and
>     (long long int)trunc*.

This is OK for mainline.

Sorry for the delay in reviewing but I've been investigating the
asymmetry between trunc and the other integer rounding functions;
round, floor and ceil.  The following code from expr.c explains a
lot:

>>    case FIX_ROUND_EXPR:
>>    case FIX_FLOOR_EXPR:
>>    case FIX_CEIL_EXPR:
>>      gcc_unreachable ();                       /* Not used for C.  */
>>
>>    case FIX_TRUNC_EXPR:
>>      op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
>>      if (target == 0 || modifier == EXPAND_STACK_PARM)
>>        target = gen_reg_rtx (mode);
>>      expand_fix (target, op0, unsignedp);
>>      return target;

So although tree codes are defined for the other "fix" conversions,
it's clearly unsafe to use them.  It's not clear what the best way
to clean this up is (either add to add the missing support or to
remove the partially implemented tree codes).  An issue for another
day...

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]