public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/52478] -ftrapv calls the wrong functions in libgcc
Date: Thu, 24 Jul 2014 09:17:00 -0000	[thread overview]
Message-ID: <bug-52478-4-aG80SJeN80@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52478-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52478

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
It seems that the libgcc functions for SImode are present (at least on x86_64),
so sth like

Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c        (revision 212970)
+++ gcc/optabs.c        (working copy)
@@ -5559,13 +5559,17 @@ gen_int_libfunc (optab optable, const ch
                 enum machine_mode mode)
 {
   int maxsize = 2 * BITS_PER_WORD;
+  int minsize = BITS_PER_WORD;

   if (GET_MODE_CLASS (mode) != MODE_INT)
     return;
   if (maxsize < LONG_LONG_TYPE_SIZE)
     maxsize = LONG_LONG_TYPE_SIZE;
-  if (GET_MODE_CLASS (mode) != MODE_INT
-      || GET_MODE_BITSIZE (mode) < BITS_PER_WORD
+  if (minsize > INT_TYPE_SIZE
+      && (trapv_binoptab_p (optable)
+         || trapv_unoptab_p (optable)))
+    minsize = INT_TYPE_SIZE;
+  if (GET_MODE_BITSIZE (mode) < minsize
       || GET_MODE_BITSIZE (mode) > maxsize)
     return;
   gen_libfunc (optable, opname, suffix, mode);
Index: gcc/expr.c
===================================================================
--- gcc/expr.c  (revision 212970)
+++ gcc/expr.c  (working copy)
@@ -9212,7 +9212,9 @@ expand_expr_real_2 (sepops ops, rtx targ
   if (modifier == EXPAND_STACK_PARM)
     target = 0;
   temp = expand_binop (mode, this_optab, op0, op1, target,
-                      unsignedp, OPTAB_LIB_WIDEN);
+                      unsignedp,
+                      trapv_binoptab_p (this_optab)
+                      ? OPTAB_LIB : OPTAB_LIB_WIDEN);
   gcc_assert (temp);
   /* Bitwise operations do not need bitfield reduction as we expect their
      operands being properly truncated.  */

makes the testcase pass.


  parent reply	other threads:[~2014-07-24  9:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04 12:59 [Bug middle-end/52478] New: " burnus at gcc dot gnu.org
2012-03-05 10:19 ` [Bug middle-end/52478] " rguenth at gcc dot gnu.org
2012-03-05 10:43 ` burnus at gcc dot gnu.org
2012-03-05 12:02 ` rguenth at gcc dot gnu.org
2012-10-07 19:15 ` pinskia at gcc dot gnu.org
2014-07-24  9:17 ` rguenth at gcc dot gnu.org [this message]
2014-07-28  8:48 ` rguenth at gcc dot gnu.org
2014-07-28  9:06 ` rguenth at gcc dot gnu.org
2014-07-29 11:11 ` rguenth at gcc dot gnu.org

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=bug-52478-4-aG80SJeN80@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).