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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|rguenth at gcc dot gnu.org  |unassigned at gcc dot
                   |                            |gnu.org

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-05 
12:01:23 UTC ---
This seems to be by design, libgcc only provides >= word_mode trapping ops. 
Which
means we'd need to expand this all using inline code:

/* Like gen_libfunc, but verify that integer operation is involved.  */

static void
gen_int_libfunc (optab optable, const char *opname, char suffix,
                 enum machine_mode mode)
{
  int maxsize = 2 * 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
      || mode < word_mode || GET_MODE_BITSIZE (mode) > maxsize)
    return;

oops.

Otherwise a simple

Index: gcc/expr.c
===================================================================
--- gcc/expr.c  (revision 184918)
+++ gcc/expr.c  (working copy)
@@ -8938,7 +8938,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.  */

should have worked.

So, it's a "not implemented thing" currently ... unlike to change until
somebody implements the ftrapv proposal from Joseph.

Reply via email to