Hi!

I've committed backports of the following patches of mine
to 4.6 branch after bootstrapping/regtesting them on x86_64-linux
and i686-linux:

        Jakub
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-25  Jakub Jelinek  <ja...@redhat.com>

        * printf/printf_fp.c (__quadmath_printf_fp): Use memcpy instead of
        mempcpy.

--- libquadmath/printf/printf_fp.c      (revision 171524)
+++ libquadmath/printf/printf_fp.c      (revision 171525)
@@ -1197,7 +1197,7 @@ __quadmath_printf_fp (struct __quadmath_
            if (*copywc == decimalwc)
              memcpy (cp, decimal, decimal_len), cp += decimal_len;
            else if (*copywc == thousands_sepwc)
-             mempcpy (cp, thousands_sep, thousands_sep_len), cp += 
thousands_sep_len;
+             memcpy (cp, thousands_sep, thousands_sep_len), cp += 
thousands_sep_len;
            else
              *cp++ = (char) *copywc;
        }
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-24  Jakub Jelinek  <ja...@redhat.com>

        PR debug/48204
        * simplify-rtx.c (simplify_const_unary_operation): Call
        real_convert when changing mode class with FLOAT_EXTEND.

        * gcc.dg/dfp/pr48204.c: New test.

--- gcc/simplify-rtx.c  (revision 171422)
+++ gcc/simplify-rtx.c  (revision 171423)
@@ -1526,7 +1526,8 @@ simplify_const_unary_operation (enum rtx
     }
 
   else if (GET_CODE (op) == CONST_DOUBLE
-          && SCALAR_FLOAT_MODE_P (mode))
+          && SCALAR_FLOAT_MODE_P (mode)
+          && SCALAR_FLOAT_MODE_P (GET_MODE (op)))
     {
       REAL_VALUE_TYPE d, t;
       REAL_VALUE_FROM_CONST_DOUBLE (d, op);
@@ -1549,7 +1550,10 @@ simplify_const_unary_operation (enum rtx
          d = real_value_truncate (mode, d);
          break;
        case FLOAT_EXTEND:
-         /* All this does is change the mode.  */
+         /* All this does is change the mode, unless changing
+            mode class.  */
+         if (GET_MODE_CLASS (mode) != GET_MODE_CLASS (GET_MODE (op)))
+           real_convert (&d, mode, &d);
          break;
        case FIX:
          real_arithmetic (&d, FIX_TRUNC_EXPR, &d, NULL);
--- gcc/testsuite/gcc.dg/dfp/pr48204.c  (revision 0)
+++ gcc/testsuite/gcc.dg/dfp/pr48204.c  (revision 171423)
@@ -0,0 +1,10 @@
+/* PR debug/48204 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-fre -g" } 
*/
+
+void
+foo (void)
+{
+  float cf = 3.0f;
+  _Decimal64 d64 = cf;
+}
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-20  Jakub Jelinek  <ja...@redhat.com>

        PR c/42544
        PR c/48197
        * c-common.c (shorten_compare): If primopN is first sign-extended
        to opN and then zero-extended to result type, set primopN to opN.

        * gcc.c-torture/execute/pr42544.c: New test.
        * gcc.c-torture/execute/pr48197.c: New test.

--- gcc/c-family/c-common.c     (revision 171251)
+++ gcc/c-family/c-common.c     (revision 171252)
@@ -3301,6 +3301,20 @@ shorten_compare (tree *op0_ptr, tree *op
   primop0 = get_narrower (op0, &unsignedp0);
   primop1 = get_narrower (op1, &unsignedp1);
 
+  /* If primopN is first sign-extended from primopN's precision to opN's
+     precision, then zero-extended from opN's precision to
+     *restype_ptr precision, shortenings might be invalid.  */
+  if (TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (TREE_TYPE (op0))
+      && TYPE_PRECISION (TREE_TYPE (op0)) < TYPE_PRECISION (*restype_ptr)
+      && !unsignedp0
+      && TYPE_UNSIGNED (TREE_TYPE (op0)))
+    primop0 = op0;
+  if (TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (TREE_TYPE (op1))
+      && TYPE_PRECISION (TREE_TYPE (op1)) < TYPE_PRECISION (*restype_ptr)
+      && !unsignedp1
+      && TYPE_UNSIGNED (TREE_TYPE (op1)))
+    primop1 = op1;
+
   /* Handle the case that OP0 does not *contain* a conversion
      but it *requires* conversion to FINAL_TYPE.  */
 
--- gcc/testsuite/gcc.c-torture/execute/pr48197.c       (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr48197.c       (revision 171252)
@@ -0,0 +1,25 @@
+/* PR c/48197 */
+
+extern void abort (void);
+static int y = 0x8000;
+
+int
+main ()
+{
+  unsigned int x = (short)y;
+  if (sizeof (0LL) == sizeof (0U))
+    return 0;
+  if (0LL > (0U ^ (short)-0x8000))
+    abort ();
+  if (0LL > (0U ^ x))
+    abort ();
+  if (0LL > (0U ^ (short)y))
+    abort ();
+  if ((0U ^ (short)-0x8000) < 0LL)
+    abort ();
+  if ((0U ^ x) < 0LL)
+    abort ();
+  if ((0U ^ (short)y) < 0LL)
+    abort ();
+  return 0;
+}
--- gcc/testsuite/gcc.c-torture/execute/pr42544.c       (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr42544.c       (revision 171252)
@@ -0,0 +1,14 @@
+/* PR c/42544 */
+
+extern void abort (void);
+
+int
+main ()
+{
+  signed short s = -1;
+  if (sizeof (long long) == sizeof (unsigned int))
+    return 0;
+  if ((unsigned int) s >= 0x100000000ULL)
+    abort ();
+  return 0;
+}
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-20  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/48156
        * df-core.c (df_get_bb_dirty): Use df_lr if df_live is NULL,
        assume df and df_lr are not NULL.

        * gcc.dg/pr48156.c: New test.

--- gcc/df-core.c       (revision 171194)
+++ gcc/df-core.c       (revision 171195)
@@ -1,6 +1,6 @@
 /* Allocation for dataflow support routines.
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010 Free Software Foundation, Inc.
+   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
    Originally contributed by Michael P. Hayes
              (m.ha...@elec.canterbury.ac.nz, mha...@redhat.com)
    Major rewrite contributed by Danny Berlin (dber...@dberlin.org)
@@ -1400,10 +1400,9 @@ df_mark_solutions_dirty (void)
 bool
 df_get_bb_dirty (basic_block bb)
 {
-  if (df && df_live)
-    return bitmap_bit_p (df_live->out_of_date_transfer_functions, bb->index);
-  else
-    return false;
+  return bitmap_bit_p ((df_live
+                       ? df_live : df_lr)->out_of_date_transfer_functions,
+                      bb->index);
 }
 
 
--- gcc/testsuite/gcc.dg/pr48156.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr48156.c      (revision 171195)
@@ -0,0 +1,45 @@
+/* PR rtl-optimization/48156 */
+/* { dg-do run } */
+/* { dg-options "-O -fcrossjumping --param min-crossjump-insns=1" } */
+
+extern void abort (void);
+
+static int __attribute__ ((noinline, noclone))
+equals (int s1, int s2)
+{
+  return s1 == s2;
+}
+
+static int __attribute__ ((noinline, noclone))
+bar (void)
+{
+  return 1;
+}
+
+static void __attribute__ ((noinline, noclone))
+baz (int f, int j)
+{
+  if (f != 4 || j != 2)
+    abort ();
+}
+
+void
+foo (int x)
+{
+  int i = 0, j = bar ();
+
+  if (x == 1)
+    i = 2;
+
+  if (j && equals (i, j))
+    baz (8, i);
+  else
+    baz (4, i);
+}
+
+int
+main ()
+{
+  foo (1);
+  return 0;
+}
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-17  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/48141
        * params.def (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES): New.
        * dse.c: Include params.h.
        (active_local_stores_len): New variable.
        (add_wild_read, dse_step1): Clear it when setting active_local_stores
        to NULL.
        (record_store, check_mem_read_rtx): Decrease it when removing
        from the chain.
        (scan_insn): Likewise.  Increase it when adding to chain, if it
        reaches PARAM_MAX_DSE_ACTIVE_LOCAL_STORES limit, set to 1 and
        set active_local_stores to NULL before the addition.
        * Makefile.in (dse.o): Depend on $(PARAMS_H).

--- gcc/dse.c   (revision 171089)
+++ gcc/dse.c   (revision 171090)
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3.  
 #include "optabs.h"
 #include "dbgcnt.h"
 #include "target.h"
+#include "params.h"
 
 /* This file contains three techniques for performing Dead Store
    Elimination (dse).
@@ -387,6 +388,7 @@ static alloc_pool insn_info_pool;
 /* The linked list of stores that are under consideration in this
    basic block.  */
 static insn_info_t active_local_stores;
+static int active_local_stores_len;
 
 struct bb_info
 {
@@ -947,6 +949,7 @@ add_wild_read (bb_info_t bb_info)
     }
   insn_info->wild_read = true;
   active_local_stores = NULL;
+  active_local_stores_len = 0;
 }
 
 
@@ -1537,6 +1540,7 @@ record_store (rtx body, bb_info_t bb_inf
        {
          insn_info_t insn_to_delete = ptr;
 
+         active_local_stores_len--;
          if (last)
            last->next_local_store = ptr->next_local_store;
          else
@@ -2074,6 +2078,7 @@ check_mem_read_rtx (rtx *loc, void *data
              if (dump_file)
                dump_insn_info ("removing from active", i_ptr);
 
+             active_local_stores_len--;
              if (last)
                last->next_local_store = i_ptr->next_local_store;
              else
@@ -2163,6 +2168,7 @@ check_mem_read_rtx (rtx *loc, void *data
              if (dump_file)
                dump_insn_info ("removing from active", i_ptr);
 
+             active_local_stores_len--;
              if (last)
                last->next_local_store = i_ptr->next_local_store;
              else
@@ -2222,6 +2228,7 @@ check_mem_read_rtx (rtx *loc, void *data
              if (dump_file)
                dump_insn_info ("removing from active", i_ptr);
 
+             active_local_stores_len--;
              if (last)
                last->next_local_store = i_ptr->next_local_store;
              else
@@ -2426,6 +2433,7 @@ scan_insn (bb_info_t bb_info, rtx insn)
                  if (dump_file)
                    dump_insn_info ("removing from active", i_ptr);
 
+                 active_local_stores_len--;
                  if (last)
                    last->next_local_store = i_ptr->next_local_store;
                  else
@@ -2453,6 +2461,12 @@ scan_insn (bb_info_t bb_info, rtx insn)
                    fprintf (dump_file, "handling memset as BLKmode store\n");
                  if (mems_found == 1)
                    {
+                     if (active_local_stores_len++
+                         >= PARAM_VALUE (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES))
+                       {
+                         active_local_stores_len = 1;
+                         active_local_stores = NULL;
+                       }
                      insn_info->next_local_store = active_local_stores;
                      active_local_stores = insn_info;
                    }
@@ -2496,6 +2510,12 @@ scan_insn (bb_info_t bb_info, rtx insn)
      it as cannot delete.  This simplifies the processing later.  */
   if (mems_found == 1)
     {
+      if (active_local_stores_len++
+         >= PARAM_VALUE (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES))
+       {
+         active_local_stores_len = 1;
+         active_local_stores = NULL;
+       }
       insn_info->next_local_store = active_local_stores;
       active_local_stores = insn_info;
     }
@@ -2534,6 +2554,7 @@ remove_useless_values (cselib_val *base)
 
       if (del)
        {
+         active_local_stores_len--;
          if (last)
            last->next_local_store = insn_info->next_local_store;
          else
@@ -2584,6 +2605,7 @@ dse_step1 (void)
            = create_alloc_pool ("cse_store_info_pool",
                                 sizeof (struct store_info), 100);
          active_local_stores = NULL;
+         active_local_stores_len = 0;
          cselib_clear_table ();
 
          /* Scan the insns.  */
--- gcc/Makefile.in     (revision 171089)
+++ gcc/Makefile.in     (revision 171090)
@@ -3070,7 +3070,7 @@ dse.o : dse.c $(CONFIG_H) $(SYSTEM_H) co
    $(TREE_H) $(TM_P_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \
    $(RECOG_H) $(EXPR_H) $(DF_H) cselib.h $(DBGCNT_H) $(TIMEVAR_H) \
    $(TREE_PASS_H) alloc-pool.h $(ALIAS_H) dse.h $(OPTABS_H) $(TARGET_H) \
-   $(BITMAP_H)
+   $(BITMAP_H) $(PARAMS_H)
 fwprop.o : fwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H) $(FLAGS_H) $(OBSTACK_H) 
$(BASIC_BLOCK_H) \
    output.h $(DF_H) alloc-pool.h $(TIMEVAR_H) $(TREE_PASS_H) $(TARGET_H) \
--- gcc/params.def      (revision 171089)
+++ gcc/params.def      (revision 171090)
@@ -698,6 +698,12 @@ DEFPARAM(PARAM_MAX_SCHED_READY_INSNS,
         "The maximum number of instructions ready to be issued to be 
considered by the scheduler during the first scheduling pass",
         100, 0, 0)
 
+/* This is the maximum number of active local stores RTL DSE will consider.  */
+DEFPARAM (PARAM_MAX_DSE_ACTIVE_LOCAL_STORES,
+         "max-dse-active-local-stores",
+         "Maximum number of active local stores in RTL dead store elimination",
+         5000, 0, 0)
+
 /* Prefetching and cache-optimizations related parameters.  Default values are
    usually set by machine description.  */
 
2011-03-26  Jakub Jelinek  <ja...@redhat.com>

        Backport from mainline
        2011-03-17  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/48141
        * dse.c (record_store): If no positions are needed in an insn
        that cannot be deleted, at least unchain it from active_local_stores.

        * gcc.dg/pr48141.c: New test.

--- gcc/dse.c   (revision 171088)
+++ gcc/dse.c   (revision 171089)
@@ -1,5 +1,5 @@
 /* RTL dead store elimination.
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    Contributed by Richard Sandiford <rsandi...@codesourcery.com>
@@ -1530,8 +1530,7 @@ record_store (rtx body, bb_info_t bb_inf
 
       /* An insn can be deleted if every position of every one of
         its s_infos is zero.  */
-      if (any_positions_needed_p (s_info)
-         || ptr->cannot_delete)
+      if (any_positions_needed_p (s_info))
        del = false;
 
       if (del)
@@ -1543,7 +1542,8 @@ record_store (rtx body, bb_info_t bb_inf
          else
            active_local_stores = ptr->next_local_store;
 
-         delete_dead_store_insn (insn_to_delete);
+         if (!insn_to_delete->cannot_delete)
+           delete_dead_store_insn (insn_to_delete);
        }
       else
        last = ptr;
--- gcc/testsuite/gcc.dg/pr48141.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr48141.c      (revision 171089)
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/48141 */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+#define A i = 0;
+#define B A A A A A A A A A A
+#define C B B B B B B B B B B
+#define D C C C C C C C C C C
+#define E D D D D D D D D D D
+
+int
+foo (void)
+{
+  volatile int i = 0;
+  E E E E E E E E E E E
+  return 0;
+}

Reply via email to