Jan Hubicka - Simplify floating point conversions IV (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing 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]

On Wed, Nov 06, 2002 at 10:48:03PM +0100, Jan Hubicka wrote:

  •   /* Wind away possible cast.  */
  •   if (TREE_CODE (arg0) == NOP_EXPR
  •   && (TYPE_PRECISION (TREE_TYPE (arg0))
  •       > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg0, 0)))))
  • arg0 = TREE_OPERAND (arg0, 0);
    [...]
  •   /* Be curefull about integer to fp conversions.
  •  These may overflow still.  */
  •   if (FLOAT_TYPE_P (TREE_TYPE (arg0))

I'd rather something like

static tree strip_float_extensions (exp) tree exp; { tree sub, expt, subt;

if (TREE_CODE (exp) != NOP_EXPR) return exp;

sub = TREE_OPERAND (exp, 0); subt = TREE_TYPE (sub); expt = TREE_TYPE (exp);

if (!FLOAT_TYPE_P (subt)) return exp;

if (TYPE_PRECISION (subt) > TYPE_PRECISION (expt)) return exp;

return strip_float_extensions (sub); }

  • case RDIV_EXPR:
  •    {
  •      tree arg0 = TREE_OPERAND (expr, 0);
  •      tree arg1 = TREE_OPERAND (expr, 1);
  •      /* Unwind possible casts.  */

Useful here as well. Nice. I've added that and suppressed the builtin transformation when not optimizing.

OK now?

Wed Nov 6 19:48:32 PST 2002 Jan Hubicka jh@suse.cz * convert.c (strip_float_extensions): New function. (convert_to_real): Optimize some cases. Index: convert.c

RCS file: /cvs/gcc/egcs/gcc/convert.c,v retrieving revision 1.19 diff -c -3 -p -r1.19 convert.c *** convert.c 4 Jul 2002 06:38:54 -0000 1.19 --- convert.c 7 Nov 2002 10:53:27 -0000 *************** Software Foundation, 59 Temple Place - S *** 30,35 **** --- 30,36 ---- #include "convert.h" #include "toplev.h" #include "langhooks.h"

*************** convert_to_pointer (type, expr) *** 71,76 **** --- 72,101 ---- } }

*************** tree *** 80,85 **** --- 105,244 ---- convert_to_real (type, expr) tree type, expr; {


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