From: Wolfgang Gellerich<gellerich@de.ibm.com>
To: rth@redhat.com
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] add insn implementing signbit to middle end and s390
Date: Mon, 30 Apr 2007 17:02:00 -0000 [thread overview]
Message-ID: <4635FEAF.mailDOR1PBXYL@de.ibm.com> (raw)
In-Reply-To: <OF0DD6B328.2549D5F8-ONC12572B1.002B8E31-422572B1.002B8BF6@de.ibm.com>
...reworked version.
With best regards,
Wolfgang Gellerich
---
Dr. Wolfgang Gellerich
IBM Deutschland Entwicklung GmbH
Schönaicher Strasse 220
71032 Böblingen, Germany
Tel. +49 / 7031 / 162598
gellerich@de.ibm.com
=======================
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen
Geschäftsführung: Herbert Kircher
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
----------------------------------------------------------------------------------
Changelog:
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: optabs.c
===================================================================
--- optabs.c (Revision 124147)
+++ optabs.c (Arbeitskopie)
@@ -5587,6 +5587,7 @@
for (i = 0; i < NUM_MACHINE_MODES; i++)
{
movmem_optab[i] = CODE_FOR_nothing;
+ signbit_optab[i] = CODE_FOR_nothing;
cmpstr_optab[i] = CODE_FOR_nothing;
cmpstrn_optab[i] = CODE_FOR_nothing;
cmpmem_optab[i] = CODE_FOR_nothing;
Index: optabs.h
===================================================================
--- optabs.h (Revision 124147)
+++ optabs.h (Arbeitskopie)
@@ -523,6 +523,9 @@
/* This array records the insn_code of insns to perform block moves. */
extern enum insn_code movmem_optab[NUM_MACHINE_MODES];
+/* This array records the insn_code of insns to implement the signbit function. */
+extern enum insn_code signbit_optab[NUM_MACHINE_MODES];
+
/* This array records the insn_code of insns to perform block sets. */
extern enum insn_code setmem_optab[NUM_MACHINE_MODES];
Index: genopinit.c
===================================================================
--- genopinit.c (Revision 124147)
+++ genopinit.c (Arbeitskopie)
@@ -174,6 +174,7 @@
"push_optab->handlers[$A].insn_code = CODE_FOR_$(push$a1$)",
"reload_in_optab[$A] = CODE_FOR_$(reload_in$a$)",
"reload_out_optab[$A] = CODE_FOR_$(reload_out$a$)",
+ "signbit_optab[$A] = CODE_FOR_$(signbit$F$a2$)",
"movmem_optab[$A] = CODE_FOR_$(movmem$a$)",
"cmpstr_optab[$A] = CODE_FOR_$(cmpstr$a$)",
"cmpstrn_optab[$A] = CODE_FOR_$(cmpstrn$a$)",
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);
+
+ /* Check if the back end provides an insn that handles signbit for the
+ argument's mode. */
+ signbit_insn_code = signbit_optab [(int) fmode];
+ if (signbit_insn_code != CODE_FOR_nothing)
+ {
+ target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
+ emit_unop_insn (signbit_insn_code, target, temp, UNKNOWN);
+ return target;
+ }
+
/* For floating point formats without a sign bit, implement signbit
as "ARG < 0.0". */
bitpos = fmt->signbit_ro;
@@ -5591,7 +5613,6 @@
return expand_expr (arg, target, VOIDmode, EXPAND_NORMAL);
}
- temp = expand_normal (arg);
if (GET_MODE_SIZE (fmode) <= UNITS_PER_WORD)
{
imode = int_mode_for_mode (fmode);
Index: config/s390/s390.h
===================================================================
--- config/s390/s390.h (Revision 124147)
+++ config/s390/s390.h (Arbeitskopie)
@@ -156,6 +156,13 @@
#define S390_TDC_POSITIVE_SIGNALING_NAN (1 << 1)
#define S390_TDC_NEGATIVE_SIGNALING_NAN (1 << 0)
+#define S390_TDC_SIGNBIT_SET (S390_TDC_NEGATIVE_ZERO \
+ | S390_TDC_NEGATIVE_NORMALIZED_NUMBER \
+ | S390_TDC_NEGATIVE_DENORMALIZED_NUMBER\
+ | S390_TDC_NEGATIVE_INFINITY \
+ | S390_TDC_NEGATIVE_QUIET_NAN \
+ | S390_TDC_NEGATIVE_SIGNALING_NAN )
+
#define S390_TDC_INFINITY (S390_TDC_POSITIVE_INFINITY \
| S390_TDC_NEGATIVE_INFINITY )
Index: config/s390/s390.md
===================================================================
--- config/s390/s390.md (Revision 124147)
+++ config/s390/s390.md (Arbeitskopie)
@@ -2274,6 +2274,18 @@
; Test data class.
;
+(define_expand "signbit<mode>2"
+ [(set (reg:CCZ CC_REGNUM)
+ (unspec:CCZ [(match_operand:BFP 1 "register_operand" "f")
+ (match_dup 2)]
+ UNSPEC_TDC_INSN))
+ (set (match_operand:SI 0 "register_operand" "=d")
+ (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
+ "TARGET_HARD_FLOAT"
+{
+ operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
+})
+
(define_expand "isinf<mode>2"
[(set (reg:CCZ CC_REGNUM)
(unspec:CCZ [(match_operand:BFP 1 "register_operand" "f")
next prev parent reply other threads:[~2007-04-30 14:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-30 9:36 Wolfgang Gellerich
2007-03-30 14:49 ` Ulrich Weigand
2007-03-30 17:24 ` Richard Henderson
2007-04-02 7:57 ` Wolfgang Gellerich
2007-04-30 17:02 ` Wolfgang Gellerich [this message]
2007-06-11 9:25 ` Richard Guenther
2007-07-06 15:02 ` Wolfgang Gellerich
2007-07-06 15:37 ` Wolfgang Gellerich
2007-07-06 16:22 ` Richard Guenther
2007-04-03 13:35 Gellerich
2007-04-03 13:50 ` Richard Guenther
2007-04-11 7:46 ` gellerich
2007-04-11 7:46 ` gellerich
2007-04-11 7:46 ` gellerich
2007-04-11 8:54 ` gellerich
2007-04-03 14:02 ` Paolo Bonzini
2007-04-11 10:17 ` gellerich
2007-04-03 14:18 Uros Bizjak
2007-04-11 12:58 ` gellerich
2007-04-12 6:59 ` Uros Bizjak
2007-04-30 15:05 ` Wolfgang Gellerich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4635FEAF.mailDOR1PBXYL@de.ibm.com \
--to=gellerich@de.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).