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] add insn implementing signbit to middle end and s390


On 4/30/07, Wolfgang Gellerich <gellerich@de.ibm.com> wrote:

...reworked version.


With best regards,



2007-04-27 Wolfgang Gellerich <gellerich@de.ibm.com>


        * optabs.h: Added declaration for signbit_optab.
        * optabs.c: (init_optabs): Added initialization for signbit_optab.
        * genoptinit.c (optabs): Added entry for signbit insns.
        * builtins.c (expand_builtin_signbit): Added code to use a signbit insn,
        if available.
        * config/s390/s390.h (S390_TDC_SIGNBIT_SET): New constant.
        * config/s390/s390.md (signbit<mode>2): New expander.

----------------------------------------------------------------------------------



Index: builtins.c
===================================================================
--- builtins.c  (Revision 124147)
+++ builtins.c  (Arbeitskopie)
@@ -230,6 +230,11 @@
                          int (*)(mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr, mp_rnd_t));
 static tree do_mpfr_sincos (tree, tree, tree);

+/* This array records the insn_code of insns to imlement the signbit
+   function.  */
+enum insn_code signbit_optab[NUM_MACHINE_MODES];
+
+
 /* Return true if NODE should be considered for inline expansion regardless
    of the optimization level.  This means whenever a function is invoked with
    its "internal" name, which normally contains the prefix "__builtin".  */
@@ -5553,12 +5558,15 @@
   return tramp;
 }

-/* Expand a call to the built-in signbit, signbitf, signbitl, signbitd32,
-   signbitd64, or signbitd128 function.
-   Return NULL_RTX if a normal call should be emitted rather than expanding
-   the function in-line.  EXP is the expression that is a call to the builtin
-   function; if convenient, the result should be placed in TARGET.  */
-
+/* Expand the call EXP to the built-in signbit, signbitf or signbitl
+   function.  The function first checks whether the back end provides
+   an insn to implement signbit for the respective mode.  If not, it
+   checks whether the floating point format of the value is such that
+   the sign bit can be extracted.  If that is not the case, the
+   function returns NULL_RTX to indicate that a normal call should be
+   emitted rather than expanding the function in-line.  EXP is the
+   expression that is a call to the builtin function; if convenient,
+   the result should be placed in TARGET.  */
 static rtx
 expand_builtin_signbit (tree exp, rtx target)
 {
@@ -5567,6 +5575,7 @@
   HOST_WIDE_INT hi, lo;
   tree arg;
   int word, bitpos;
+  enum insn_code signbit_insn_code;
   rtx temp;

   if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE))
@@ -5577,6 +5586,19 @@
   rmode = TYPE_MODE (TREE_TYPE (exp));
   fmt = REAL_MODE_FORMAT (fmode);

+  /* Expand the argument yielding a RTX expression. */
+  temp = expand_normal (arg);

You need to guard this agains multiple expansions. See other uses of builtin_save_expr in builtins.c.

The middle-end parts are ok with this change.

Thanks,
Richard.


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