public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Haley <aph-gcc@littlepinkcloud.COM>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Jan Hubicka <jh@suse.cz>,
	gcc-patches@gcc.gnu.org,         richard@codesourcery.com
Subject: Re: Lazy construction of libcalls
Date: Sat, 08 Sep 2007 12:44:00 -0000	[thread overview]
Message-ID: <18146.31326.53954.878500@zebedee.pink> (raw)
In-Reply-To: <20070904081644.GB26095@atrey.karlin.mff.cuni.cz>

Jan Hubicka writes:
 > > Jan Hubicka <jh@suse.cz> writes:
 > > >> Jan Hubicka <jh@suse.cz> writes:
 > > >> > While comparing the tables produced by new and old code, I noticed that
 > > >> > "ffs" for SI used to be called "ffssi3" but now it is "ffs".
 > > >> > I believe it was inteded to be called ffs because of:
 > > >> >   optab_handler (ffs_optab, int_mode)->libfunc = init_one_libfunc ("ffs");
 > > >> > that however later get overwriten by initialization code.
 > > >> 
 > > >> Actually, this was deliberate.  All libgccs have word and doubleword
 > > >> ffs functions, but not all C libraries have "ffs".  So we wanted the
 > > >> libgcc versions to take precedence over the C library fallback.  See:
 > > >> 
 > > >>     http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01165.html
 > > >> 
 > > >> for details.
 > > >
 > > > OK, so the initialization of libgcc always overwrite the ffs
 > > > initialization, so simply removing the line above would work?
 > > 
 > > Not for 64-bit targets with a 32-bit int, since __builtin_ffs() takes
 > > an int argument.  We could of course add an SImode libgcc function for
 > > those targets, but the patch above was just supposed to make better
 > > use of what we already had.
 > 
 > Thanks for explanation - I've now added a guard 
 > if (INT_TYPE_SIZE < BITS_PER_WORD)
 > into my local copy that should do what described again. I am re-testing now,
 > OK with that change?

This breaks ARM EABI.  The symptom is that we generate signed instead
of unsigned libcalls for a % b where a and b are usigned ints.

The problem is here in sign_expand_binop(), where we generate a fake
optab:

  /* Try widening to a signed int.  Make a fake signed optab that
     hides any signed insn for direct use.  */
  wide_soptab = *soptab;
  optab_handler (&wide_soptab, mode)->insn_code = CODE_FOR_nothing;
 
We later call expand_binop (mode, &wide_soptab ...  which in turn
calls optab_libfunc (binoptab, mode) which calls optab->libcall_gen()
and inserts the fake optab into the hash table.  This means that the
hash table ->optab points into the stack.  We don't want to do this,
I'm sure.

I suspect the easiest way to fix this is by setting libcall_gen to
NULL in the fake optab.

Andrew.


2007-09-08  Andrew Haley  <aph@redhat.com>

        * optabs.c (sign_expand_binop): Set libcall_gen = NULL in the fake
        signed optab.

Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c        (revision 128099)
+++ gcc/optabs.c        (working copy)
@@ -2234,6 +2234,9 @@
      hides any signed insn for direct use.  */
   wide_soptab = *soptab;
   optab_handler (&wide_soptab, mode)->insn_code = CODE_FOR_nothing;
+  /* We don't want to generate new hash table entries from this fake
+     optab.  */
+  wide_soptab.libcall_gen = NULL;
 
   temp = expand_binop (mode, &wide_soptab, op0, op1, target,
                       unsignedp, OPTAB_WIDEN);

  parent reply	other threads:[~2007-09-08 10:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-21 17:13 Jan Hubicka
2007-08-24 13:44 ` Richard Sandiford
2007-08-24 14:23   ` Jan Hubicka
2007-08-24 14:46     ` Richard Sandiford
2007-09-04  8:16       ` Jan Hubicka
2007-09-04  8:28         ` Richard Guenther
2007-09-19  6:50           ` Kaveh R. GHAZI
2007-09-28  5:48             ` [PING]: fix breakage in c4x ports Kaveh R. GHAZI
2007-10-12 13:15               ` [PING x 2]: " Kaveh R. GHAZI
2007-10-12 13:16                 ` Richard Guenther
2007-09-08 12:44         ` Andrew Haley [this message]
2007-09-08 16:28           ` Lazy construction of libcalls Jan Hubicka
2007-08-24 14:43   ` Jan Hubicka

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=18146.31326.53954.878500@zebedee.pink \
    --to=aph-gcc@littlepinkcloud.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jh@suse.cz \
    --cc=richard@codesourcery.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).