Re: [testsuite] Adding target nonpic to g++.dg/tm/pr47746.C

2013-05-24 Thread Alexander Ivchenko
*ping*

2013/4/11 Alexander Ivchenko :
> Hi,
>
> The same motivation as for:
> http://gcc.gnu.org/ml/gcc-cvs/2013-03/msg00786.html
>
> "Since -fpic option is turned on by default in Android we have certain test
> fails. The reason for that is that those tests rely on the
> availability of functions, defined in them
> and with -fpic compiler conservatively assumes that they are
> AVAIL_OVERWRITABLE."
>
> In case of tm we have that in here:
>
> 4461|   /* If we aren't seeing the final version of the function we don't
> 4462|  know what it will contain at runtime.  */
> 4463|   if (cgraph_function_body_availability (node) < AVAIL_AVAILABLE)
> 4464+>return true;
> 4465|
>
> (gdb) p cgraph_function_body_availability (node)
> $54 = AVAIL_OVERWRITABLE
>
> and so we have a testfail for Android. The following patch adds nonpic:
>
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index 943be90..e0a376e 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,7 @@
> +2013-04-11  Alexander Ivchenko  
> +
> +   * g++.dg/tm/pr47746.C: Add target nonpic.
> +
>  2013-04-11  Paolo Carlini  
>
> PR c++/54216
> diff --git a/gcc/testsuite/g++.dg/tm/pr47746.C
> b/gcc/testsuite/g++.dg/tm/pr47746.C
> index 7cd9e10..de85a1d 100644
> --- a/gcc/testsuite/g++.dg/tm/pr47746.C
> +++ b/gcc/testsuite/g++.dg/tm/pr47746.C
> @@ -1,4 +1,4 @@
> -// { dg-do compile }
> +// { dg-do compile { target nonpic } }
>  // { dg-options "-fgnu-tm" }
>
>  class InputStream
>
>
>
> is it OK for trunk and for 4.8?
>
> Thanks
> Alexander


Re: [PATCH, ARM, iWMMXT] Check IWMMXT_GR_REGS in the SECONDARY_RELOAD MACRO

2013-05-24 Thread Chung-Ju Wu
2013/5/24 Xinyu Qi :
> Hi,
>
>   For this simple case, compiled with option -march=iwmmxt -O,
> #define N 64
> signed int b[N];
> signed long long j[N], d[N];
> void foo (void)
> {
>   int i;
>   for (i = 0; i < N; i++)
> j[i] = d[i] << b[i];
> }
> An internal compiler error occurs,
> error: insn does not satisfy its constraints:
> (insn 112 74 75 3 (set (reg:SI 96 wcgr0)
> (mem/c:SI (plus:SI (reg:SI 3 r3 [orig:174 ivtmp.19 ] [174])
> (reg/f:SI 0 r0 [183])) [0 MEM[symbol: b, index: ivtmp.19_14, 
> offset: 0B]+0 S4 A32])) {*iwmmxt_movsi_insn}
>  (nil))
>
> The load address of wmmx wcgr register cannot accept the register offset mode 
> and the reload pass fails to fix it, so that such error happens.
> This issue could be solved by adding check code for IWMMXT_GR_REGS class in 
> the SECONDARY_RELOAD MACRO if TARGET_IWMMXT. Current code only check the 
> IWMMXT_REGS group.
> Patch attached with a new test.
> Pass full dejagnu test. No regression.
>
> Is this fix proper?
> OK for trunk?
>

I cannot approve it.  But here are some comments and hope it helps.


> ChangeLog
> gcc/
> 2013-05-24  Xinyu Qi  
>
> * config/arm/arm.h (SECONDARY_OUTPUT_RELOAD_CLASS): Check 
> IWMMXT_GR_REGS.

This line just ends at 81 column.
How about this one?

2013-05-24  Xinyu Qi  

* config/arm/arm.h (SECONDARY_OUTPUT_RELOAD_CLASS): Check
IWMMXT_GR_REGS register class.
(SECONDARY_INPUT_RELOAD_CLASS): Likewise.

>
> testsuite/
> 2013-05-24  Xinyu Qi  
>
> * gcc.target/arm/mmx-3.c: New test.


> Index: gcc/config/arm/arm.h
> ===
> --- gcc/config/arm/arm.h(revision 199090)
> +++ gcc/config/arm/arm.h(working copy)
> @@ -1280,7 +1280,8 @@
>((TARGET_VFP && TARGET_HARD_FLOAT\
>  && IS_VFP_CLASS (CLASS))\
> ? coproc_secondary_reload_class (MODE, X, FALSE)\
> -   : (TARGET_IWMMXT && (CLASS) == IWMMXT_REGS)\
> +   : (TARGET_IWMMXT && ((CLASS) == IWMMXT_REGS)\
> +|| (CLASS) == IWMMXT_GR_REGS)\

I think it should be

+   : (TARGET_IWMMXT && ((CLASS) == IWMMXT_REGS\
+|| (CLASS) == IWMMXT_GR_REGS))\


> ? coproc_secondary_reload_class (MODE, X, TRUE)\
> : TARGET_32BIT\
> ? (((MODE) == HImode && ! arm_arch4 && true_regnum (X) == -1) \
> @@ -1293,7 +1294,8 @@
>((TARGET_VFP && TARGET_HARD_FLOAT\
>  && IS_VFP_CLASS (CLASS))\
>  ? coproc_secondary_reload_class (MODE, X, FALSE) :\
> -(TARGET_IWMMXT && (CLASS) == IWMMXT_REGS) ?\
> +(TARGET_IWMMXT && ((CLASS) == IWMMXT_REGS\
> +   || (CLASS) == IWMMXT_GR_REGS)) ?\
>  coproc_secondary_reload_class (MODE, X, TRUE) :\
> (TARGET_32BIT ?\
>  (((CLASS) == IWMMXT_REGS || (CLASS) == IWMMXT_GR_REGS)\

It seems that you didn't CC arm maintainer.
Let me do this for you. :)


Best regards,
jasonwucj


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Thu, May 23, 2013 at 11:54:05PM +0200, Rainer Orth wrote:
> > Agreed, that seems the best course of action if that's an option.
> 
> I just remembered that we aren't there yet even on mainline:
> 
> * This snippet
> 
>   http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01255.html
> 
>   is necessary to avoid bootstrap failure on Solaris 9.
> 
> * We'll need to link every C++ program with -lrt on Solaris, as
>   mentioned in the same message.  I suppose the best way to do this is
>   along the lines of libgfortran.spec, rather than duplicate the
>   necessary configury between g++ and libstdc++.  This might prove
>   pretty invasive for the testsuite, though, and delay the 4.8.1 release
>   quite a bit.

Ugh, that makes =auto pretty much unbackportable, but it seems Solaris is
the only problematic OS here.  The goal of
_ZNSt6chrono12steady_clock3nowEv@@GLIBCXX_3.4.19
already in 4.8.1 was to allow Linux users (and with partial backport of
=auto not including Solaris perhaps also FreeBSD/NetBSD/OpenBSD) to let
users that get C++ core language feature completeness also use this
(Jonathan/Benjamin, is that right?).

So, let's talk about other options, is constexpr/const on
std::chrono::steady_clock::is_steady
required by the standard (as in, could we export
_ZNSt6chrono12steady_clock9is_steadyE@@GLIBCXX_3.4.19
and let the library say which case it is, it would be constexpr when
we know for sure, and a static variable otherwise)?
But looking at C++11 draft, in [time.clock.steady]
it even says that is_steady is true (then we are violating the standard
even when we represent steady_clock as typedef system_clock steady_clock;).

Thus, what about this version (just slightly modified, headers remain the
same, but we export _ZNSt6chrono12steady_clock3nowEv@@GLIBCXX_3.4.19
even if monotonic clock isn't supported, it will just be work the same as
_ZNSt6chrono12system_clock3nowEv@@GLIBCXX_3.4.11 .  Programs compiled
against headers of the same libstdc++ as will be linked in dynamically
won't see a change, because they will never use this symbol of monotonic
clocks weren't determined to be there at configure time.  And we have a
fallback for the unlikely matching of newer headers with older libstdc++,
it will work roughly as before (in that steady_clock::now () will not be
steady), just with the tiny exception that in that case the code could
see that steady_clock::is_steady is true rather than false (but, can't
the code assume it from the standard anyway)?

I've also added the #ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
guards in gnu.ver.

Jakub
2013-05-24  Jakub Jelinek  

* src/c++11/chrono.cc: If _GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL,
include unistd.h and sys/syscall.h.  If _GLIBCXX_COMPATIBILITY_CXX0X,
don't define system_clock::is_steady, system_clock::now() and
steady_clock::is_steady.
(std::chrono::system_clock::now()): If
_GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL, call
syscall (SYS_clock_gettime, ...) instead of clock_gettime (...).
(std::chrono::system_clock::now()): Likewise.  Add weak attribute
if _GLIBCXX_COMPATIBILITY_CXX0X and compatibility-chrono.cc will
be non-empty.
* src/Makefile.am (cxx11_sources): Add compatibility-chrono.cc.
(compatibility-chrono.lo, compatibility-chrono.o): New goals.
* src/c++11/compatibility-chrono.cc: New file.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): On linux*, check for
syscall (SYS_clock_gettime, CLOCK_MONOTONIC, &tp).
* testsuite/util/testsuite_abi.cc (check_version): Add
GLIBCXX_3.4.20 version and make it the latest.
* config/abi/pre/gnu.ver (_ZNSt6chrono12steady_clock3nowEv): Export
also @@GLIBCXX_3.4.19.  Move all symbols so far added for GCC 4.9 to
@@GLIBCXX_3.4.20 instead.
* config/abi/post/i386-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Regenerated.
* config.h.in: Regenerated.
* src/Makefile.in: Regenerated.
* configure: Regenerated.

--- libstdc++-v3/src/c++11/chrono.cc.jj 2013-02-04 18:15:15.078395533 +0100
+++ libstdc++-v3/src/c++11/chrono.cc2013-05-23 18:06:40.562825017 +0200
@@ -22,7 +22,20 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
+#include 
+
+#ifndef 

Re: SUBREGs in move2add_note_store (Was: Re: RFA: fix rtl-optimization/56833)

2013-05-24 Thread Eric Botcazou
> I've found it is good to have also one mode to invalidate a register for
> all uses; it seems natural to use VOIDmode for that, and then we can use
> BLKmode for all but the first hard register of a multi-hard-reg register.

OK, that sounds sensible.

> I have attached the patch that makes the reload_cse_move2add sub-pass work
> the way it think it should be; it'll take some time to test this properly,
> though.

Thanks for your efforts.  Here's a preliminary review:

+/* Record that REG is being set to a value with the mode of REG.  */
+
+static void
+move2add_record_mode (rtx reg)
[...]
+  for (i = nregs; --i > 0; )
+reg_mode[regno + i] = BLKmode;

+/* Check if REGNO contains a valid value in MODE.  */
+
+static bool
+move2add_valid_value_p (int regno, enum machine_mode mode)
[...]
+  for (i = hard_regno_nregs[regno][mode] - 1; i > 0; i--)
+if (reg_mode[i] != BLKmode)
+  return false;

I think that a 'regno' is missing in the second hunk.  And can you use the 
same idiom for the loop in both cases (same initial value and iteration)?


@@ -1787,8 +1848,7 @@ move2add_use_add3_insn (rtx reg, rtx sym
   SET_SRC (pat) = plus_expr;
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-if (reg_set_luid[i] > move2add_last_label_luid
-   && reg_mode[i] == GET_MODE (reg)
+if (move2add_valid_value_p (i, GET_MODE (reg))
&& reg_base_reg[i] < 0
&& reg_symbol_ref[i] != NULL_RTX
&& rtx_equal_p (sym, reg_symbol_ref[i]))

Note that you're weakening the mode equality test here.


@@ -2045,7 +2099,10 @@ reload_cse_move2add (rtx first)
  /* Reset the information about this register.  */
  int regno = REGNO (XEXP (note, 0));
  if (regno < FIRST_PSEUDO_REGISTER)
-   reg_set_luid[regno] = 0;
+   {
+ move2add_record_mode (XEXP (note, 0));
+ reg_set_luid[regno] = 0;
+   }
}
}
   note_stores (PATTERN (insn), move2add_note_store, insn);
@@ -2082,7 +2139,7 @@ reload_cse_move2add (rtx first)
{
  if (call_used_regs[i])
/* Reset the information about this register.  */
-   reg_set_luid[i] = 0;
+   reg_mode[i] = VOIDmode;
}
}

@@ -2262,17 +2288,17 @@ move2add_note_store (rtx dst, const_rtx
[...]

+invalidate:
+  /* Invalidate the contents of the register.  */
+  reg_set_luid[regno] = 0;
+  move2add_record_mode (dst);

The intent is the same, why don't we have the same code?


-- 
Eric Botcazou


Re: Fix PR tree-optimization/57322

2013-05-24 Thread Eric Botcazou
> 2013-05-19   Easwaran Raman  
> 
> PR tree-optimization/57322
> * (build_and_add_sum): If a BB is empty, set the UID of the
> statement added to the BB to be 1.

Missing filename in the ChangeLog.

-- 
Eric Botcazou


Re: PR tree-optimization/57337

2013-05-24 Thread Richard Biener
On Thu, May 23, 2013 at 7:26 PM, Easwaran Raman  wrote:
> This addresses the case where UID alone is not sufficient to figure
> out which statement appears earlier in  a BB. Bootstraps and no test
> regressions in x86_64 on linux. Ok for trunk?

Why not simply conservatively use gimple_uid (a) <= gimple_uid (b)
in not_dominated_by?

Richard.



> Thanks,
> Easwaran
>
>
> 2013-05-23  Easwaran Raman  
>
> PR tree-optimization/57337
> * tree-ssa-reassoc.c (appears_later_in_bb): New function.
> (find_insert_point): Correctly identify the insertion point
> when two statements with the same UID is compared.
>
> Index: gcc/tree-ssa-reassoc.c
> ===
> --- gcc/tree-ssa-reassoc.c  (revision 199211)
> +++ gcc/tree-ssa-reassoc.c  (working copy)
> @@ -2866,6 +2866,31 @@ not_dominated_by (gimple a, gimple b)
>
>  }
>
> +/* Among STMT1 and STMT2, return the statement that appears later. Both
> +   statements are in same BB and have the same UID.  */
> +
> +static gimple
> +appears_later_in_bb (gimple stmt1, gimple stmt2)
> +{
> +  unsigned uid = gimple_uid (stmt1);
> +  gimple_stmt_iterator gsi = gsi_for_stmt (stmt1);
> +  gsi_next (&gsi);
> +  if (gsi_end_p (gsi))
> +return stmt1;
> +  for (; !gsi_end_p (gsi); gsi_next (&gsi))
> +{
> +  gimple stmt = gsi_stmt (gsi);
> +
> +  /* If STMT has a different UID than STMT1 and we haven't seen
> + STMT2 during traversal, we know STMT1 appears later.  */
> +  if (gimple_uid (stmt) != uid)
> +return stmt1;
> +  else if (stmt == stmt2)
> +return stmt2;
> +}
> +  gcc_unreachable ();
> +}
> +
>  /* Find the statement after which STMT must be moved so that the
> dependency from DEP_STMT to STMT is maintained.  */
>
> @@ -2875,7 +2900,11 @@ find_insert_point (gimple stmt, gimple dep_stmt)
>gimple insert_stmt = stmt;
>if (dep_stmt == NULL)
>  return stmt;
> -  if (not_dominated_by (insert_stmt, dep_stmt))
> +  if (gimple_uid (insert_stmt) == gimple_uid (dep_stmt)
> +  && gimple_bb (insert_stmt) == gimple_bb (dep_stmt)
> +  && insert_stmt != dep_stmt)
> +insert_stmt = appears_later_in_bb (insert_stmt, dep_stmt);
> +  else if (not_dominated_by (insert_stmt, dep_stmt))
>  insert_stmt = dep_stmt;
>return insert_stmt;
>  }


Re: Use unsigned(-1) for lshift

2013-05-24 Thread Richard Biener
On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:
> Hello,
>
> this is a simple patch to reduce a bit the noise in PR57324 (undefined
> behavior flagged by clang). I only handled some of the most obvious ones.
> Passes bootstrap+testsuite on x86_64-linux-gnu.

Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
and nonnegative
value, and E1 * 2^E2 is representable in the result type, then that is the
resulting value; otherwise, the behavior is undefined."

While seriously underspecified for signed negative values (always undefined?!
or well-defined?!), I wonder why CLang requires

> -  *hv &= ~((HOST_WIDE_INT) (-1) << (prec - count -
> HOST_BITS_PER_WIDE_INT));
> +  *hv &= ~((unsigned HOST_WIDE_INT) (-1)
> +  << (prec - count - HOST_BITS_PER_WIDE_INT));

here.

That is, isn't this a bug in CLang?

Richard.



>
> 2013-05-24  Marc Glisse  
>
> PR other/57324
> * expmed.c (expand_smod_pow2): Use an unsigned -1 for lshift.
> * fold-const.c (fold_unary_loc): Likewise.
> * double-int.c (rshift_double, lshift_double): Likewise.
> * cse.c (cse_insn): Likewise.
> * tree.c (integer_pow2p, tree_log2, tree_floor_log2): Likewise.
> * tree-ssa-structalias.c (UNKNOWN_OFFSET): Shift 1 instead of -1.
>
> --
> Marc Glisse
> Index: gcc/double-int.c
> ===
> --- gcc/double-int.c(revision 199256)
> +++ gcc/double-int.c(working copy)
> @@ -264,21 +264,22 @@ rshift_double (unsigned HOST_WIDE_INT l1
>
>if (count >= prec)
>  {
>*hv = signmask;
>*lv = signmask;
>  }
>else if ((prec - count) >= HOST_BITS_PER_DOUBLE_INT)
>  ;
>else if ((prec - count) >= HOST_BITS_PER_WIDE_INT)
>  {
> -  *hv &= ~((HOST_WIDE_INT) (-1) << (prec - count -
> HOST_BITS_PER_WIDE_INT));
> +  *hv &= ~((unsigned HOST_WIDE_INT) (-1)
> +  << (prec - count - HOST_BITS_PER_WIDE_INT));
>*hv |= signmask << (prec - count - HOST_BITS_PER_WIDE_INT);
>  }
>else
>  {
>*hv = signmask;
>*lv &= ~((unsigned HOST_WIDE_INT) (-1) << (prec - count));
>*lv |= signmask << (prec - count);
>  }
>  }
>
> @@ -321,21 +322,21 @@ lshift_double (unsigned HOST_WIDE_INT l1
>
>signmask = -((prec > HOST_BITS_PER_WIDE_INT
> ? ((unsigned HOST_WIDE_INT) *hv
>>> (prec - HOST_BITS_PER_WIDE_INT - 1))
> : (*lv >> (prec - 1))) & 1);
>
>if (prec >= HOST_BITS_PER_DOUBLE_INT)
>  ;
>else if (prec >= HOST_BITS_PER_WIDE_INT)
>  {
> -  *hv &= ~((HOST_WIDE_INT) (-1) << (prec - HOST_BITS_PER_WIDE_INT));
> +  *hv &= ~((unsigned HOST_WIDE_INT) -1 << (prec -
> HOST_BITS_PER_WIDE_INT));
>*hv |= signmask << (prec - HOST_BITS_PER_WIDE_INT);
>  }
>else
>  {
>*hv = signmask;
>*lv &= ~((unsigned HOST_WIDE_INT) (-1) << prec);
>*lv |= signmask << prec;
>  }
>  }
>
> Index: gcc/tree-ssa-structalias.c
> ===
> --- gcc/tree-ssa-structalias.c  (revision 199256)
> +++ gcc/tree-ssa-structalias.c  (working copy)
> @@ -475,21 +475,21 @@ struct constraint_expr
>
>/* Offset, in bits, of this constraint from the beginning of
>   variables it ends up referring to.
>
>   IOW, in a deref constraint, we would deref, get the result set,
>   then add OFFSET to each member.   */
>HOST_WIDE_INT offset;
>  };
>
>  /* Use 0x8000... as special unknown offset.  */
> -#define UNKNOWN_OFFSET ((HOST_WIDE_INT)-1 << (HOST_BITS_PER_WIDE_INT-1))
> +#define UNKNOWN_OFFSET ((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT-1))
>
>  typedef struct constraint_expr ce_s;
>  static void get_constraint_for_1 (tree, vec *, bool, bool);
>  static void get_constraint_for (tree, vec *);
>  static void get_constraint_for_rhs (tree, vec *);
>  static void do_deref (vec *);
>
>  /* Our set constraints are made up of two constraint expressions, one
> LHS, and one RHS.
>
> Index: gcc/cse.c
> ===
> --- gcc/cse.c   (revision 199256)
> +++ gcc/cse.c   (working copy)
> @@ -5374,21 +5374,21 @@ cse_insn (rtx insn)
>  may not equal what was stored, due to truncation.  */
>
>if (GET_CODE (SET_DEST (sets[i].rtl)) == ZERO_EXTRACT)
> {
>   rtx width = XEXP (SET_DEST (sets[i].rtl), 1);
>
>   if (src_const != 0 && CONST_INT_P (src_const)
>   && CONST_INT_P (width)
>   && INTVAL (width) < HOST_BITS_PER_WIDE_INT
>   && ! (INTVAL (src_const)
> -   & ((HOST_WIDE_INT) (-1) << INTVAL (width
> +   & ((unsigned HOST_WIDE_INT) (-1) << INTVAL (width
> /* Exception: if the value is constant,
>and it won't be truncated, record it.  */
> ;
>   else
> {
>   /* Th

Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jonathan Wakely
On 23 May 2013 21:56, Rainer Orth wrote:
>
> Right, it only got enable by defaulting --enable-libstdcxx-time to auto.

I think it would have been enabled previously with
--enable-libstdcxx-time=rt, but it wasn't tested and so didn't make it
into the linker script at the same time as the GNU symbol did.


Re: Remove global state from gcc/tracer.c

2013-05-24 Thread Richard Biener
On Thu, May 23, 2013 at 11:42 PM, Jeff Law  wrote:
> On 05/23/2013 02:59 PM, Jakub Jelinek wrote:
>>
>> On Thu, May 23, 2013 at 02:44:48PM -0600, Jeff Law wrote:
>>>
>>> On 05/23/2013 02:31 PM, Richard Henderson wrote:

 I think we need more weigh in from other maintainers on this, rather
 than
 iterating a 5th time today...
>>>
>>> This seems like an awful lot of pain.
>>>
>>> I don't think we should be looking to generate different code for
>>> library vs executable GCC.
>>>
>>> I think we should look for *clean* first, then we can look at what
>>> we could change if the compile-time performance isn't what we want.
>>>
>>> Lots of C++ code manages to pass around the implicit this pointer
>>> and use it appropriately without that being a significant source of
>>> performance concerns.  I suspect GCC would be the same in that
>>> regard. The cost of passing around & using that pointer is dwarfed
>>> by all the other lameness we have.
>>
>>
>> I'm afraid we don't have the luxury of slowing the compiler too much.
>
> Nor do we have the luxury of continuing to not deal with these long term
> issues.  Nor do we have the luxury of creating something so (*&@#$ ugly that
> nobody is willing to work on it again in the future.   Particularly when
> there's no evidence it's going to be measurably slower.
>
>
>
>>
>> Anyway, I don't see how a single this would help with all the global
>> state,
>> because there are various levels of global state.  The tracer changes show
>> just the easiest one, non-GTY pass that that is internal to the file,
>> starts living at the start of the pass and can be forgotten at the end of
>> the pass.
>
> Agreed, but we need to start somewhere and passes of this nature seem like a
> reasonable place to me
>
>
>
>   But, often pass has some of its global state, and calls functions
>>
>> from other files that access different global state (cfun, crtl,
>> current_function_decl, lots of other things), some files have global state
>> preserved across multiple passes, etc.  Before we start changing anything,
>> we need a firm plan for everything, otherwise we end up with a useless
>> partial transformation.  Some global state data is accessed only
>> occassionally, but other is accessed all the time (cfun being a very good
>> example here).
>
> I don't disagree in principle WRT partial transformations.  But I also
> believe that there is value in cleaning up the the simple stuff, even in
> isolation.
>
> To take your specific examples:
>
>   * Global state is global state needs to be available via
>   a global context pointer of some kind regardless of how we
>   handle pass-local data.
>
>   * pass-local state that spans passes.  I'd like to see an
>   example, but my gut feeling is such things are probably
>   going to either become global state or die.  They'll have
>   to be handled on a case by case basis.
>
> In both cases, David's changes don't make those problems any easier or any
> harder.  He merely encapsulates pass-local data where it's easy to do so
> right now.  It's just a cleaner design/implementation and I'd like to see it
> pursued.

Without looking at the actual patch in question I'd say that changing
things in a way that is clearly defined where we'd be thread safe is
a good thing.  For example after the frontend finished, or after the
point where LTO would have run, or for all IPA analysis/transform phases
(who usually iterate over all function bodies).  Ideally we'd be able to work
on multiple functions at once.

The very first step in that direction would be to kill current_pass and have
the pass manager pass in context (containing the struct function to work on
for example, replacing uses of cfun) to the execute function of scalar passes.
And then just conentrate on getting rid of (implicit) 'cfun' uses in passes
(let them flag themselves with "I'm safe w/o cfun" and have the pass manager
just NULL that).  A lot of interfaces got a _fn variant already.

Then of course interesting things such as dumpfiles pop up - a pass writes
to a single dump-file, so multiple instances of that pass cannot run in parallel
without disrupting that.  A way out is to run in a pipelining mode instead,
thus have only a single pass instance at a given time but have multiple
functions being processed by different passes in parallel.  That even avoids
the need to cleanup state in passes themselves, it just needs caretaking
of the global cfun like state.

Richard.

> Jeff


Re: [tree-ssa] fix for PR57385

2013-05-24 Thread Richard Biener
On Fri, May 24, 2013 at 12:23 AM, Alexander Ivchenko  wrote:
> Hi,
>
> The following patch fixes PR57385
> (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57385)
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 51e7b9e..cca61e7 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2013-05-24  Alexander Ivchenko  
> +
> +   PR tree-ssa/57385
> +   * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Check
> +   that index is not negative.
> +
>  2013-05-23  Richard Henderson  
>
> PR target/56742
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index b1895fb..730e62f 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-05-24  Alexander Ivchenko  
> +
> +   PR tree-ssa/57385
> +   * gcc.dg/tree-ssa/pr57385.c: New test.
> +
>  2013-05-23  Christian Bruel  
>
> PR debug/57351
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> new file mode 100644
> index 000..a04a998
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +
> +int c;
> +
> +void foo(int f)
> +{
> +  int wbi=-1;
> +  c = (f ? "012346":"01345:6008")[wbi];
> +}
> diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
> index 49d61b0..0e7a74c 100644
> --- a/gcc/tree-ssa-sccvn.c
> +++ b/gcc/tree-ssa-sccvn.c
> @@ -1294,6 +1294,7 @@ fully_constant_vn_reference_p (vn_reference_t ref)
>   == TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0->op0
>   && GET_MODE_CLASS (TYPE_MODE (op->type)) == MODE_INT
>   && GET_MODE_SIZE (TYPE_MODE (op->type)) == 1
> + && tree_int_cst_sgn (op->op0) >= 0
>   && compare_tree_int (op->op0, TREE_STRING_LENGTH (arg0->op0)) < 0)
> return build_int_cst_type (op->type,
>(TREE_STRING_POINTER (arg0->op0)
>
>
>
>  Tested and bootsraped on x86-64 linux.
> Is it ok for trunk? If yes, should we backport it to 4.8?

Ok for trunk and 4.8 after 4.8.1 is out.

Thanks,
Richard.

>
> thanks,
> Alexander


[Ada] Use discriminant subtype constraints in derivation

2013-05-24 Thread Eric Botcazou
With the attached change, the compiler willl now take into account the subtype 
constraints added by renaming discriminants in the derivation of untagged 
discriminated types to determine the size of mutable objects of the derived 
types, instead of using the same size as for the root type.

Tested on x86_64-suse-linux, applied on the mainline.


2013-05-24  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Constify
a handful of local variables.
For a derived untagged type that renames discriminants, change the type
of the stored discriminants to a subtype with the bounds of the type
of the visible discriminants.
(build_subst_list): Rename local variable.


2013-05-24  Eric Botcazou  

* gnat.dg/derived_type4.adb: New test.


-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 199275)
+++ gcc-interface/decl.c	(working copy)
@@ -2913,10 +2913,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
   {
 	Node_Id full_definition = Declaration_Node (gnat_entity);
 	Node_Id record_definition = Type_Definition (full_definition);
+	Node_Id gnat_constr;
 	Entity_Id gnat_field;
-	tree gnu_field, gnu_field_list = NULL_TREE, gnu_get_parent;
+	tree gnu_field, gnu_field_list = NULL_TREE;
+	tree gnu_get_parent;
 	/* Set PACKED in keeping with gnat_to_gnu_field.  */
-	int packed
+	const int packed
 	  = Is_Packed (gnat_entity)
 	? 1
 	: Component_Alignment (gnat_entity) == Calign_Storage_Unit
@@ -2926,13 +2928,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		 && Known_RM_Size (gnat_entity)))
 		? -2
 		: 0;
-	bool has_discr = Has_Discriminants (gnat_entity);
-	bool has_rep = Has_Specified_Layout (gnat_entity);
-	bool all_rep = has_rep;
-	bool is_extension
+	const bool has_discr = Has_Discriminants (gnat_entity);
+	const bool has_rep = Has_Specified_Layout (gnat_entity);
+	const bool is_extension
 	  = (Is_Tagged_Type (gnat_entity)
 	 && Nkind (record_definition) == N_Derived_Type_Definition);
-	bool is_unchecked_union = Is_Unchecked_Union (gnat_entity);
+	const bool is_unchecked_union = Is_Unchecked_Union (gnat_entity);
+	bool all_rep = has_rep;
 
 	/* See if all fields have a rep clause.  Stop when we find one
 	   that doesn't.  */
@@ -3171,6 +3173,51 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		}
 	}
 
+	/* If we have a derived untagged type that renames discriminants in
+	   the root type, the (stored) discriminants are a just copy of the
+	   discriminants of the root type.  This means that any constraints
+	   added by the renaming in the derivation are disregarded as far
+	   as the layout of the derived type is concerned.  To rescue them,
+	   we change the type of the (stored) discriminants to a subtype
+	   with the bounds of the type of the visible discriminants.  */
+	if (has_discr
+	&& !is_extension
+	&& Stored_Constraint (gnat_entity) != No_Elist)
+	  for (gnat_constr = First_Elmt (Stored_Constraint (gnat_entity));
+	   gnat_constr != No_Elmt;
+	   gnat_constr = Next_Elmt (gnat_constr))
+	if (Nkind (Node (gnat_constr)) == N_Identifier
+		/* Ignore access discriminants.  */
+		&& !Is_Access_Type (Etype (Node (gnat_constr)))
+		&& Ekind (Entity (Node (gnat_constr))) == E_Discriminant)
+	  {
+		Entity_Id gnat_discr = Entity (Node (gnat_constr));
+		tree gnu_discr_type = gnat_to_gnu_type (Etype (gnat_discr));
+		tree gnu_ref
+		  = gnat_to_gnu_entity (Original_Record_Component (gnat_discr),
+	NULL_TREE, 0);
+
+		/* GNU_REF must be an expression using a PLACEHOLDER_EXPR built
+		   just above for one of the stored discriminants.  */
+		gcc_assert (TREE_TYPE (TREE_OPERAND (gnu_ref, 0)) == gnu_type);
+
+		if (gnu_discr_type != TREE_TYPE (gnu_ref))
+		  {
+		const unsigned prec = TYPE_PRECISION (TREE_TYPE (gnu_ref));
+		tree gnu_subtype
+		  = TYPE_UNSIGNED (TREE_TYPE (gnu_ref))
+		? make_unsigned_type (prec) : make_signed_type (prec);
+		TREE_TYPE (gnu_subtype) = TREE_TYPE (gnu_ref);
+		TYPE_EXTRA_SUBTYPE_P (gnu_subtype) = 1;
+		SET_TYPE_RM_MIN_VALUE (gnu_subtype,
+	   TYPE_MIN_VALUE (gnu_discr_type));
+		SET_TYPE_RM_MAX_VALUE (gnu_subtype,
+	   TYPE_MAX_VALUE (gnu_discr_type));
+		TREE_TYPE (gnu_ref)
+		  = TREE_TYPE (TREE_OPERAND (gnu_ref, 1)) = gnu_subtype;
+		  }
+	  }
+
 	/* Add the fields into the record type and finish it up.  */
 	components_to_record (gnu_type, Component_List (record_definition),
 			  gnu_field_list, packed, definition, false,
@@ -5969,7 +6016,7 @@ elaborate_entity (Entity_Id gnat_entity)
 	   Present (gnat_field);
 	   gnat_field = Next_Discriminant (gnat_field),
 	   gnat_discriminant_expr = Next_Elmt (gnat_discriminant_expr))
-	/* ??? For now, ignore access discriminants.  */
+	/* Ignore access discriminants.  */
 	if (!Is_Access_Type (Etype (Node (gnat_discriminant_expr
 	  elaborate_e

Re: Use unsigned(-1) for lshift

2013-05-24 Thread Marc Glisse

On Fri, 24 May 2013, Richard Biener wrote:


On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:

Hello,

this is a simple patch to reduce a bit the noise in PR57324 (undefined
behavior flagged by clang). I only handled some of the most obvious ones.
Passes bootstrap+testsuite on x86_64-linux-gnu.


Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
and nonnegative
value, and E1 * 2^E2 is representable in the result type, then that is the
resulting value; otherwise, the behavior is undefined."


I guess if the architecture only has logical shifts and uses another 
representation than 2's complement...



While seriously underspecified for signed negative values (always undefined?!
or well-defined?!), I wonder why CLang requires


-  *hv &= ~((HOST_WIDE_INT) (-1) << (prec - count -
HOST_BITS_PER_WIDE_INT));
+  *hv &= ~((unsigned HOST_WIDE_INT) (-1)
+  << (prec - count - HOST_BITS_PER_WIDE_INT));


here.

That is, isn't this a bug in CLang?


Note that my set of changes may not exactly match clang's report. Since 
that was done on 4.8, I relied on grep quite a bit, and there didn't seem 
to be any harm in adding unsigned there. If we consider that the standard 
says that any lshift of a negative number is undefined, why do you find 
this particular change surprising?


--
Marc Glisse


Re: [Patch wwwdocs] gcc-4.9 changes: address sanitizer on ARM

2013-05-24 Thread Gerald Pfeifer
On Thu, 23 May 2013, Christophe Lyon wrote:
> This patch mentions Address Sanitizer on ARM in the gcc-4.9/changes.html 
> pages. (and re-enables the "General Optimizer Improvements" section)
> 
> Is it OK to commit?

Looks good to me, thanks!

Gerald


Re: Use unsigned(-1) for lshift

2013-05-24 Thread Richard Biener
On Fri, May 24, 2013 at 10:33 AM, Marc Glisse  wrote:
> On Fri, 24 May 2013, Richard Biener wrote:
>
>> On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:
>>>
>>> Hello,
>>>
>>> this is a simple patch to reduce a bit the noise in PR57324 (undefined
>>> behavior flagged by clang). I only handled some of the most obvious ones.
>>> Passes bootstrap+testsuite on x86_64-linux-gnu.
>>
>>
>> Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
>> and nonnegative
>> value, and E1 * 2^E2 is representable in the result type, then that is the
>> resulting value; otherwise, the behavior is undefined."
>
>
> I guess if the architecture only has logical shifts and uses another
> representation than 2's complement...
>
>
>> While seriously underspecified for signed negative values (always
>> undefined?!
>> or well-defined?!), I wonder why CLang requires
>>
>>> -  *hv &= ~((HOST_WIDE_INT) (-1) << (prec - count -
>>> HOST_BITS_PER_WIDE_INT));
>>> +  *hv &= ~((unsigned HOST_WIDE_INT) (-1)
>>> +  << (prec - count - HOST_BITS_PER_WIDE_INT));
>>
>>
>> here.
>>
>> That is, isn't this a bug in CLang?
>
>
> Note that my set of changes may not exactly match clang's report. Since that
> was done on 4.8, I relied on grep quite a bit, and there didn't seem to be
> any harm in adding unsigned there. If we consider that the standard says
> that any lshift of a negative number is undefined, why do you find this
> particular change surprising?

I'm not dure what the standard says here - I'd equally well may interpret
the standard in that all left-shifts of negative values are well-defined
(there must be a reason for the pattern to use -1 << instead of 1 <<).

Richard.

> --
> Marc Glisse


Re: SUBREGs in move2add_note_store (Was: Re: RFA: fix rtl-optimization/56833)

2013-05-24 Thread Joern Rennecke

Quoting Eric Botcazou :


+static bool
+move2add_valid_value_p (int regno, enum machine_mode mode)
[...]
+  for (i = hard_regno_nregs[regno][mode] - 1; i > 0; i--)
+if (reg_mode[i] != BLKmode)
+  return false;

I think that a 'regno' is missing in the second hunk.


Huh?  Could you be more specific?
If you mean I should check reg_mode[regno], that is tested a few lines above.


 And can you use the
same idiom for the loop in both cases (same initial value and iteration)?


Sure.  I rembered that Jeff prefered .. - 1; i > 0; i--), but forgot I had
a second instance of ; --i > 0; ).


@@ -1787,8 +1848,7 @@ move2add_use_add3_insn (rtx reg, rtx sym
   SET_SRC (pat) = plus_expr;

   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-if (reg_set_luid[i] > move2add_last_label_luid
-   && reg_mode[i] == GET_MODE (reg)
+if (move2add_valid_value_p (i, GET_MODE (reg))
&& reg_base_reg[i] < 0
&& reg_symbol_ref[i] != NULL_RTX
&& rtx_equal_p (sym, reg_symbol_ref[i]))

Note that you're weakening the mode equality test here.


Weakening inasmuch as it allows noop truncation, strengthening inasmuch
as it checks that all part of a multi-hard-reg reg are up to date
(which is necessary because I dropped some checks to only allow single
regs).  Overall, it makes the logic more consistent.


@@ -2045,7 +2099,10 @@ reload_cse_move2add (rtx first)
   /* Reset the information about this register.  */
   int regno = REGNO (XEXP (note, 0));
   if (regno < FIRST_PSEUDO_REGISTER)
-reg_set_luid[regno] = 0;
+{
+  move2add_record_mode (XEXP (note, 0));
+  reg_set_luid[regno] = 0;
+}
 }
 }
   note_stores (PATTERN (insn), move2add_note_store, insn);


See comment on third hunk of this set below


@@ -2082,7 +2139,7 @@ reload_cse_move2add (rtx first)
  {
  if (call_used_regs[i])
/* Reset the information about this register.  */
-   reg_set_luid[i] = 0;
+   reg_mode[i] = VOIDmode;


This is for a single hard register.
Setting the mode to VOIDmode invalidates all uses.

 > @@ -2262,17 +2288,17 @@ move2add_note_store (rtx dst, const_rtx

[...]

+invalidate:
+  /* Invalidate the contents of the register.  */
+  reg_set_luid[regno] = 0;
+  move2add_record_mode (dst);

The intent is the same, why don't we have the same code?


move2add_record_mode (dst) invalidates all but the first reg.
I left the invalidation of the first reg set reg_set_luid on the theory
that this causes less churn (albeit the code is moved, too).

Now, on second thought, I should really use reg_mode[regno] VOIDmode
for the first reg here instead, to make sure this reg ceases to be
tracked as part of a multi-hard-reg register starting at an earlier regnum.###


Re: Use unsigned(-1) for lshift

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 10:15:29AM +0200, Richard Biener wrote:
> On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:
> > Hello,
> >
> > this is a simple patch to reduce a bit the noise in PR57324 (undefined
> > behavior flagged by clang). I only handled some of the most obvious ones.
> > Passes bootstrap+testsuite on x86_64-linux-gnu.
> 
> Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
> and nonnegative
> value, and E1 * 2^E2 is representable in the result type, then that is the
> resulting value; otherwise, the behavior is undefined."
> 
> While seriously underspecified for signed negative values (always undefined?!
> or well-defined?!), I wonder why CLang requires

By strict reading of the standard, left shift of negative signed value by
any amount is undefined behavior in ISO C99 (no idea if it hasn't been
changed later on, Joseph?).
In C++98, in [expr.shift] it doesn't seem to mention E1 << E2 where E1 has
signed type at all, the is implementation defined sentence only in the
second paragraph, so one would expect that it applies to >> only.
C++11 [expr.shift] already has the wording of C99 (thus making it undefined
behavior?).

BTW, we have HOST_WIDE_INT_1 and HOST_WIDE_INT_C(X) macros, don't we want
also HOST_WIDE_INT_m1 for HOST_WIDE_INT_C(-1) and HOST_WIDE_INT_UC(X)
for HOST_WIDE_INT_C(X##U) (or whatever works for __int64) and
HOST_WIDE_INT_1U, HOST_WIDE_INT_m1U ?  It would be more compact and could
make code more readable.

Jakub


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Rainer Orth
Jonathan Wakely  writes:

> On 23 May 2013 21:56, Rainer Orth wrote:
>>
>> Right, it only got enable by defaulting --enable-libstdcxx-time to auto.
>
> I think it would have been enabled previously with
> --enable-libstdcxx-time=rt, but it wasn't tested and so didn't make it
> into the linker script at the same time as the GNU symbol did.

Of course, but I only test with default options.
--enable-libstdcxx-time should probably have been documented as a
possibly ABI-breaking option.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Daniel Krügler
2013/5/24 Jakub Jelinek :
> So, let's talk about other options, is constexpr/const on
> std::chrono::steady_clock::is_steady
> required by the standard (as in, could we export
> _ZNSt6chrono12steady_clock9is_steadyE@@GLIBCXX_3.4.19
> and let the library say which case it is, it would be constexpr when
> we know for sure, and a static variable otherwise)?
> But looking at C++11 draft, in [time.clock.steady]
> it even says that is_steady is true (then we are violating the standard
> even when we represent steady_clock as typedef system_clock steady_clock;).

Yes, steady_clock::is_steady needs to be true and to be usable within
constant expressions.

- Daniel


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 09:57:05AM +0200, Jakub Jelinek wrote:
> Thus, what about this version (just slightly modified, headers remain the
> same, but we export _ZNSt6chrono12steady_clock3nowEv@@GLIBCXX_3.4.19
> even if monotonic clock isn't supported, it will just be work the same as
> _ZNSt6chrono12system_clock3nowEv@@GLIBCXX_3.4.11 .  Programs compiled
> against headers of the same libstdc++ as will be linked in dynamically
> won't see a change, because they will never use this symbol of monotonic
> clocks weren't determined to be there at configure time.  And we have a
> fallback for the unlikely matching of newer headers with older libstdc++,
> it will work roughly as before (in that steady_clock::now () will not be
> steady), just with the tiny exception that in that case the code could
> see that steady_clock::is_steady is true rather than false (but, can't
> the code assume it from the standard anyway)?
> 
> I've also added the #ifdef HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
> guards in gnu.ver.

Oops, posted too early, while that worked on Linux due to
_GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL, it didn't work when
_GLIBCXX_USE_CLOCK_MONOTONIC wasn't defined, the return of the other clock
now() result resulted in error.

So here is once more updated version that works even when
_GLIBCXX_USE_CLOCK_MONOTONIC isn't defined.

Jakub
2013-05-24  Jakub Jelinek  

* src/c++11/chrono.cc: If _GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL,
include unistd.h and sys/syscall.h.  If _GLIBCXX_COMPATIBILITY_CXX0X,
don't define system_clock::is_steady, system_clock::now() and
steady_clock::is_steady.
(std::chrono::system_clock::now()): If
_GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL, call
syscall (SYS_clock_gettime, ...) instead of clock_gettime (...).
(std::chrono::system_clock::now()): Likewise.  Add weak attribute
if _GLIBCXX_COMPATIBILITY_CXX0X and compatibility-chrono.cc will
be non-empty.
* src/Makefile.am (cxx11_sources): Add compatibility-chrono.cc.
(compatibility-chrono.lo, compatibility-chrono.o): New goals.
* src/c++11/compatibility-chrono.cc: New file.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): On linux*, check for
syscall (SYS_clock_gettime, CLOCK_MONOTONIC, &tp).
* testsuite/util/testsuite_abi.cc (check_version): Add
GLIBCXX_3.4.20 version and make it the latest.
* config/abi/pre/gnu.ver (_ZNSt6chrono12steady_clock3nowEv): Export
also @@GLIBCXX_3.4.19.  Move all symbols so far added for GCC 4.9 to
@@GLIBCXX_3.4.20 instead.
* config/abi/post/i386-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Regenerated.
* config.h.in: Regenerated.
* src/Makefile.in: Regenerated.
* configure: Regenerated.

--- libstdc++-v3/src/c++11/chrono.cc.jj 2013-02-04 18:15:15.078395533 +0100
+++ libstdc++-v3/src/c++11/chrono.cc2013-05-23 18:06:40.562825017 +0200
@@ -22,7 +22,20 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
+#include 
+
+#ifndef _GLIBCXX_USE_CLOCK_MONOTONIC
+// If !_GLIBCXX_USE_CLOCK_MONOTONIC, std::chrono::steady_clock
+// is just a typedef to std::chrono::system_clock, for ABI compatibility
+// force it not to be a typedef now and export it anyway.  Programs
+// using the headers where it is a typedef will actually just use
+// std::chrono::system_clock instead, and this remains here just a fallback.
+#define _GLIBCXX_USE_CLOCK_MONOTONIC
+#include 
+#undef _GLIBCXX_USE_CLOCK_MONOTONIC
+#else
 #include 
+#endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
@@ -32,13 +45,18 @@
  defined(_GLIBCXX_USE_GETTIMEOFDAY)
 #include 
 #endif
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL
+#include 
+#include 
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   namespace chrono
   {
   _GLIBCXX_BEGIN_NAMESPACE_VERSION
- 
+
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
 constexpr bool system_clock::is_steady;
 
 system_clock::time_point
@@ -47,7 +65,11 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 #ifdef _GLIBCXX_USE_CLOCK_REALTIME
   timespec tp;
   // -EINVAL, -EFAULT
+#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL
+  syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp);
+#else
   clock_gettime(CLOCK_REALTIME, &tp);
+#endif
   

Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Rainer Orth
Jakub Jelinek  writes:

> On Thu, May 23, 2013 at 11:54:05PM +0200, Rainer Orth wrote:
>> > Agreed, that seems the best course of action if that's an option.
>> 
>> I just remembered that we aren't there yet even on mainline:
>> 
>> * This snippet
>> 
>>   http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01255.html
>> 
>>   is necessary to avoid bootstrap failure on Solaris 9.
>> 
>> * We'll need to link every C++ program with -lrt on Solaris, as
>>   mentioned in the same message.  I suppose the best way to do this is
>>   along the lines of libgfortran.spec, rather than duplicate the
>>   necessary configury between g++ and libstdc++.  This might prove
>>   pretty invasive for the testsuite, though, and delay the 4.8.1 release
>>   quite a bit.
>
> Ugh, that makes =auto pretty much unbackportable, but it seems Solaris is
> the only problematic OS here.  The goal of
> _ZNSt6chrono12steady_clock3nowEv@@GLIBCXX_3.4.19
> already in 4.8.1 was to allow Linux users (and with partial backport of
> =auto not including Solaris perhaps also FreeBSD/NetBSD/OpenBSD) to let
> users that get C++ core language feature completeness also use this
> (Jonathan/Benjamin, is that right?).

It occured to me that there might be a far less intrusive option to still
allow a Solaris backport: instead of going the libstdc++.spec route
(which I still think is the correct way forward), statically handle -lrt
addition in g++spec.c, controlled by a macro defined only in config/sol2.h.

Such a patch could be added to mainline and 4.8 branch now, and mainline
later changed to use libstdc++.spec instead.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [libgfortran, build] Use -z ignore instead of --as-needed on Solaris

2013-05-24 Thread Rainer Orth
Hi Tobias,

> Rainer Orth wrote:
>> how should we proceed with this patch now, given the questions above?
>> Install as is, although it doesn't seem really beneficial, or drop it?
>
> I would install it. Actually, did you get a libquadmath dependence on
> Solaris or not?

I do, both with Solaris ld and gld 2.23.1.

> On Linux - or to be more precise: with binutils newer than 2013-03-18 - 
> you also shouldn't get a dependence. See
> http://sourceware.org/bugzilla/show_bug.cgi?id=12549 for details.

No wonder I do see the dependency even on Linux: I usually only test
with binutils releases, and that patch will only show up in gld 2.24.

Ok, I'll go ahead and install the patch since it certainly does no harm.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [tree-ssa] fix for PR57385

2013-05-24 Thread Kirill Yukhin
Adding back community

On Fri, May 24, 2013 at 1:15 PM, Kirill Yukhin  wrote:
>>
>> Ok for trunk and 4.8 after 4.8.1 is out.
>>
>
> Checked in to trunk:
> http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00803.html (+
> http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00804.html for missed test).
> And 4.8 branch: http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00805.html
>
> Thanks, K


[Ada] Add support for pragma No_Inline

2013-05-24 Thread Eric Botcazou
This is the gigi bits to enable support for pragma No_Inline in the Ada 
compiler.  Nothing more to say, except that specifying also pragma Inline 
yields a warning and specifying also pragma Inline_Always is an error.

Tested on x86_64-suse-linux, applied on the mainline.


2013-05-24  Eric Botcazou  

* gcc-interface/gigi.h (enum inline_status_t): New type.
(create_subprog_decl): Adjust prototype.
* gcc-interface/decl.c (gnat_to_gnu_entity) : Adjust
calls to create_subprog_decl.
(get_minimal_subprog_decl): Likewise.
* gcc-interface/trans.c (gigi): Likewise.
(build_raise_check): Likewise.
(establish_gnat_vms_condition_handler): Likewise.
(Compilation_Unit_to_gnu): Likewise.
(gnat_to_gnu): Likewise.
* gcc-interface/utils.c (create_subprog_decl): Change inline_flag
parameter to inline_status and implement for suppressed inlining.


2013-05-24  Eric Botcazou  

* gnat.dg/specs/noinline1.ads: New test.
* gnat.dg/noinline2.ad[sb]: Likewise.
* gnat.dg/specs/noinline3.ads: Likewise.
* gnat.dg/specs/noinline3_pkg.ad[sb]: New helper.


-- 
Eric Botcazou-- { dg-do compile }
-- { dg-options "-O2 -fdump-tree-optimized" }

package body Noinline2 is

  function Inner (A, B : Integer) return Integer;
  pragma No_Inline (Inner);

  function Inner (A, B : Integer) return Integer is
  begin
return A + B;
  end;

  function F (A, B : Integer) return Integer is
  begin
return Inner (A, B) + Inner (A, -B);
  end;

end Noinline2;

-- { dg-final { scan-tree-dump-times "noinline2.inner" 2 "optimized"  } }
-- { dg-final { cleanup-tree-dump "optimized" } }package Noinline2 is

  function F (A, B : Integer) return Integer;

end Noinline2;-- { dg-do compile }

package Noinline1 is

  procedure Proc1;
  pragma Inline (Proc1);
  pragma No_Inline (Proc1); -- { dg-warning "both specified" }

  procedure Proc2;
  pragma No_Inline (Proc2);
  pragma Inline (Proc2); -- { dg-warning "both specified" }

  procedure Proc3;
  pragma Inline_Always (Proc3);
  pragma No_Inline (Proc3); -- { dg-error "mutually exclusive" }

  procedure Proc4;
  pragma No_Inline (Proc4);
  pragma Inline_Always (Proc4); -- { dg-error "mutually exclusive" }

end Noinline1;-- { dg-do compile }
-- { dg-options "-O2 -fdump-tree-optimized" }

with Noinline3_Pkg;

package Noinline3 is new Noinline3_Pkg (0);

-- { dg-final { scan-tree-dump-times "noinline3.inner" 2 "optimized"  } }
-- { dg-final { cleanup-tree-dump "optimized" } }package body Noinline3_Pkg is

  function Inner (A, B : Integer) return Integer;
  pragma No_Inline (Inner);

  function Inner (A, B : Integer) return Integer is
  begin
return A + B;
  end;

  function F (A, B : Integer) return Integer is
  begin
return Inner (A, B) + Inner (A, -B);
  end;

end Noinline3_Pkg;-- { dg-excess-errors "cannot generate code" }

generic

  I : Integer;

package Noinline3_Pkg is

  function F (A, B : Integer) return Integer;

end Noinline3_Pkg;Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 199275)
+++ gcc-interface/utils.c	(working copy)
@@ -6,7 +6,7 @@
  *  *
  *  C Implementation File   *
  *  *
- *  Copyright (C) 1992-2012, Free Software Foundation, Inc. *
+ *  Copyright (C) 1992-2013, Free Software Foundation, Inc. *
  *  *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -2621,14 +2621,14 @@ create_label_decl (tree label_name, Node
node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of
PARM_DECL nodes chained through the DECL_CHAIN field).
 
-   INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, ARTIFICIAL_FLAG and ATTR_LIST are
+   INLINE_STATUS, PUBLIC_FLAG, EXTERN_FLAG, ARTIFICIAL_FLAG and ATTR_LIST are
used to set the appropriate fields in the FUNCTION_DECL.  GNAT_NODE is
used for the position of the decl.  */
 
 tree
 create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type,
-		 tree param_decl_list, bool inline_flag, bool public_flag,
-		 bool extern_flag, bool artificial_flag,
+ 		 tree param_decl_list, enum inline_status_t inline_status,
+		 bool public_flag, bool extern_flag, bool artificial_flag,
 		 struct attrib *attr_list, Node_Id gnat_node)
 {
   tree subprog_decl = build_decl (input_location, FUNCTION_DECL, subprog_name,
@@ -2642,7 +2642,7 @@ create_subprog_decl (tree subprog_name,
  function in the current unit since it is private to the other unit.
  We could inline the nested function as well but it's probab

[Ada] Coordinate front-end and middle-end floating-point settings

2013-05-24 Thread Eric Botcazou
This (partially) coordinates the floating-point settings of the front-end and
the middle-end for the Ada compiler:
  - if Machine_Overflows is set to True, -ftrapping-math is enabled in the
compiler; otherwise, it is disabled (unless overridden by the user).
  - if Signed_Zeros is set to True, -fsigned-zeros  is enabled in the
compiler; otherwise, it is disabled (unless overridden by the user).

Tested on x86_64-suse-linux, applied on the mainline.


2013-05-24  Eric Botcazou  

* gcc-interface/gigi.h (gnat_init_gcc_fp): Declare.
* gcc-interface/trans.c (gigi): Call it.
* gcc-interface/misc.c (gnat_init_gcc_fp): New function.


-- 
Eric BotcazouIndex: gcc-interface/gigi.h
===
--- gcc-interface/gigi.h	(revision 199286)
+++ gcc-interface/gigi.h	(working copy)
@@ -502,7 +502,13 @@ extern tree get_block_jmpbuf_decl (void)
for location information and flag propagation.  */
 extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
 
+/* Initialize the GCC support for exception handling.  */
 extern void gnat_init_gcc_eh (void);
+
+/* Initialize the GCC support for floating-point operations.  */
+extern void gnat_init_gcc_fp (void);
+
+/* Install the builtin functions we might need.  */
 extern void gnat_install_builtins (void);
 
 /* Return an integer type with the number of bits of precision given by
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 199286)
+++ gcc-interface/trans.c	(working copy)
@@ -677,6 +677,9 @@ gigi (Node_Id gnat_root, int max_gnat_no
   if (Exception_Mechanism == Back_End_Exceptions)
 gnat_init_gcc_eh ();
 
+  /* Initialize the GCC support for FP operations.  */
+  gnat_init_gcc_fp ();
+
   /* Now translate the compilation unit proper.  */
   Compilation_Unit_to_gnu (gnat_root);
 
Index: gcc-interface/misc.c
===
--- gcc-interface/misc.c	(revision 199275)
+++ gcc-interface/misc.c	(working copy)
@@ -6,7 +6,7 @@
  *  *
  *   C Implementation File  *
  *  *
- *  Copyright (C) 1992-2012, Free Software Foundation, Inc. *
+ *  Copyright (C) 1992-2013, Free Software Foundation, Inc. *
  *  *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -346,9 +346,7 @@ gnat_init (void)
   return true;
 }
 
-/* If we are using the GCC mechanism to process exception handling, we
-   have to register the personality routine for Ada and to initialize
-   various language dependent hooks.  */
+/* Initialize the GCC support for exception handling.  */
 
 void
 gnat_init_gcc_eh (void)
@@ -381,6 +379,28 @@ gnat_init_gcc_eh (void)
   init_eh ();
 }
 
+/* Initialize the GCC support for floating-point operations.  */
+
+void
+gnat_init_gcc_fp (void)
+{
+  /* Disable FP optimizations that ignore the signedness of zero if
+ S'Signed_Zeros is True, but don't override the user if not.  */
+  if (Signed_Zeros_On_Target)
+flag_signed_zeros = 1;
+  else if (!global_options_set.x_flag_signed_zeros)
+flag_signed_zeros = 0;
+
+  /* Assume that FP operations can trap if S'Machine_Overflow is True,
+ but don't override the user if not.
+
+ ??? Alpha/VMS enables FP traps without declaring it.  */
+  if (Machine_Overflows_On_Target || TARGET_ABI_OPEN_VMS)
+flag_trapping_math = 1;
+  else if (!global_options_set.x_flag_trapping_math)
+flag_trapping_math = 0;
+}
+
 /* Print language-specific items in declaration NODE.  */
 
 static void

Re: [Patch, Fortran] Deallocate CLASS(...),INTENT(OUT),allocatable arrays

2013-05-24 Thread Tobias Burnus

On May 22, 2013 23:28Tobias Burnus wrote:

A rather simple patch found while testing the draft finalization patch.

For a "class(...), allocatable, intent(out)" dummy argument, the 
actual argument has to be deallocated. That worked for scalar 
polymorphic vars, but not for polymorphic arrays.


Actually, it turned out to be a bit more complicated: I forgot to test 
whether resetting the _vtab worked. Result (as to be expected): It 
didn't. I also found out that DEALLOCATE also didn't properly reset the 
_vtab. That's now fixed (and tested for) in the attached follow up patch.


(Recall that the standard mandates that an unallocated polymorphic 
variable has the declared type.)



Build and regtested on x86-64-gnu-linux.
OK for the trunk?


Tobias
2013-05-22  Tobias Burnus  

	* trans-expr.c (gfc_conv_procedure_call): Deallocate
	polymorphic arrays for allocatable intent(out) dummies.
	(gfc_reset_vptr): New function, moved from trans-stmt.c
	and extended.
	* trans-stmt.c (reset_vptr): Remove.
	(gfc_trans_deallocate): Update calls.
	* trans.h (gfc_reset_vptr): New prototype.

2013-05-22  Tobias Burnus  

	* gfortran.dg/class_array_16.f90: New.

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index f8d99fd..650f829 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -214,6 +214,55 @@ gfc_vtable_final_get (tree decl)
 #undef VTABLE_FINAL_FIELD
 
 
+/* Reset the vptr to the declared type, e.g. after deallocation.  */
+
+void
+gfc_reset_vptr (stmtblock_t *block, gfc_expr *e)
+{
+  gfc_expr *rhs, *lhs = gfc_copy_expr (e);
+  gfc_symbol *vtab;
+  tree tmp;
+  gfc_ref *ref;
+
+  /* If we have a class array, we need go back to the class
+ container. */
+  if (lhs->ref && lhs->ref->next && !lhs->ref->next->next
+  && lhs->ref->next->type == REF_ARRAY
+  && lhs->ref->next->u.ar.type == AR_FULL
+  && lhs->ref->type == REF_COMPONENT
+  && strcmp (lhs->ref->u.c.component->name, "_data") == 0)
+{
+  gfc_free_ref_list (lhs->ref);
+  lhs->ref = NULL;
+}
+  else
+for (ref = lhs->ref; ref; ref = ref->next)
+  if (ref->next && ref->next->next && !ref->next->next->next
+	  && ref->next->next->type == REF_ARRAY
+	  && ref->next->next->u.ar.type == AR_FULL
+	  && ref->next->type == REF_COMPONENT
+	  && strcmp (ref->next->u.c.component->name, "_data") == 0)
+	{
+	  gfc_free_ref_list (ref->next);
+	  ref->next = NULL;
+	}
+
+  gfc_add_vptr_component (lhs);
+
+  if (UNLIMITED_POLY (e))
+rhs = gfc_get_null_expr (NULL);
+  else
+{
+  vtab = gfc_find_derived_vtab (e->ts.u.derived);
+  rhs = gfc_lval_expr_from_sym (vtab);
+}
+  tmp = gfc_trans_pointer_assignment (lhs, rhs);
+  gfc_add_expr_to_block (block, tmp);
+  gfc_free_expr (lhs);
+  gfc_free_expr (rhs);
+}
+
+
 /* Obtain the vptr of the last class reference in an expression.
Return NULL_TREE if no class reference is found.  */
 
@@ -4334,6 +4383,49 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	{
 	  /* Pass a class array.  */
 	  gfc_conv_expr_descriptor (&parmse, e);
+
+	  /* If an ALLOCATABLE dummy argument has INTENT(OUT) and is
+		 allocated on entry, it must be deallocated.  */
+	  if (fsym->attr.intent == INTENT_OUT
+		  && CLASS_DATA (fsym)->attr.allocatable)
+		{
+		  stmtblock_t block;
+		  tree ptr;
+
+		  gfc_init_block  (&block);
+		  ptr = parmse.expr;
+		  ptr = gfc_class_data_get (ptr);
+
+		  tmp = gfc_deallocate_with_status (ptr, NULL_TREE,
+		NULL_TREE, NULL_TREE,
+		NULL_TREE, true, e,
+		false);
+		  gfc_add_expr_to_block (&block, tmp);
+		  tmp = fold_build2_loc (input_location, MODIFY_EXPR,
+	 void_type_node, ptr,
+	 null_pointer_node);
+		  gfc_add_expr_to_block (&block, tmp);
+		  gfc_reset_vptr (&block, e);
+
+		  if (fsym->attr.optional
+		  && e->expr_type == EXPR_VARIABLE
+		  && (!e->ref
+			  || (e->ref->type == REF_ARRAY
+			  && !e->ref->u.ar.type != AR_FULL))
+		  && e->symtree->n.sym->attr.optional)
+		{
+		  tmp = fold_build3_loc (input_location, COND_EXPR,
+void_type_node,
+gfc_conv_expr_present (e->symtree->n.sym),
+gfc_finish_block (&block),
+build_empty_stmt (input_location));
+		}
+		  else
+		tmp = gfc_finish_block (&block);
+
+		  gfc_add_expr_to_block (&se->pre, tmp);
+}
+
 	  /* The conversion does not repackage the reference to a class
 	 array - _data descriptor.  */
 	  gfc_conv_class_to_class (&parmse, e, fsym->ts, false,
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 6c5f557..7812934 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -5339,30 +5339,6 @@ gfc_trans_allocate (gfc_code * code)
 }
 
 
-/* Reset the vptr after deallocation.  */
-
-static void
-reset_vptr (stmtblock_t *block, gfc_expr *e)
-{
-  gfc_expr *rhs, *lhs = gfc_copy_expr (e);
-  gfc_symbol *vtab;
-  tree tmp;
-
-  if (UNLIMITED_POLY (e))
-rhs = gfc_get_null_expr 

[C++ testcases, added] PR 25503 & PR 26572

2013-05-24 Thread Paolo Carlini

Hi,

both issues already fixed. Committed to mainline.

Thanks,
Paolo.

/
2013-05-24  Paolo Carlini  

PR c++/26572
* g++.dg/template/error51.C: New.

2013-05-24  Paolo Carlini  

PR c++/25503
* g++.dg/template/bitfield2.C: New.
Index: g++.dg/template/bitfield2.C
===
--- g++.dg/template/bitfield2.C (revision 0)
+++ g++.dg/template/bitfield2.C (working copy)
@@ -0,0 +1,16 @@
+// PR c++/25503
+
+template
+struct Test
+{
+  Test()
+  {
+typedef struct StaticAssert {unsigned condition : (N); } XXX; // { 
dg-error "zero width" }
+  }
+};
+
+int
+main()
+{
+  Test<0> T;
+}
Index: g++.dg/template/error51.C
===
--- g++.dg/template/error51.C   (revision 0)
+++ g++.dg/template/error51.C   (working copy)
@@ -0,0 +1,9 @@
+// PR c++/26572
+
+template void foo()
+{
+  struct A;// { dg-error "declaration" }
+  struct B : A {}; // { dg-error "invalid use of incomplete" }
+}
+
+template void foo<0>();


RE: [PATCH][gensupport] Add optional attributes field to define_cond_exec

2013-05-24 Thread Kyrylo Tkachov
Hi Michael,

> > - What about define_insn_and_split? Currently, we can define
> "predicable"
> > for a define_insn_and_split,
> Yes, you're right. Currently define_subst cannot be applied to
> define_insn_and_split. That's not implemented yet because I didn't
> see
> a real usages of define_substs with these (though I'm not saying
> nobody uses it) - in absence of use cases I wasn't able to design a
> proper syntax for it. If you have any ideas of how that could be
> done
> in a pretty way, please let me know:)
> 
> As for your second concern:
> > - What about predication on a per-alternative basis (set_attr
> "predicable"
> > "yes,no,yes")?
> Currently, cond_exec actually could be a more compact way of doing
> this. But in general, define_subst is able to substitute it (as
> Richard said, it's a superset of define_cond_exec). Here is an
> example
> of how that could be achieved (maybe, it's not optimal in terms of
> lines of code):
> Suppose we have:
> (define_insn "arm_load_exclusive"
>   [(set (match_operand:SI 0 "s_register_operand" "=r,r")
> (zero_extend:SI
>   (unspec_volatile:NARROW
> [(match_operand:NARROW 1 "mem_noofs_operand" "Ua,m")]
> VUNSPEC_LL)))]
>   "TARGET_HAVE_LDREXBH"
>   "ldrex%?\t%0, %C1"
>   [(set_attr "predicable" "yes,no")])
> (I added a second alternative to the define_insn from your example)
> 
> We could add several subst-attributes, as following:
> (define_subst_attr "constraint_operand1" "ds_predicable" "=r,r"
> "=r")
> (define_subst_attr "constraint_operand2" "ds_predicable" "=Ua,m"
> "Ua")
> And then rewrite the original pattern:
> (define_insn "arm_load_exclusive"
>   [(set (match_operand:SI 0 "s_register_operand"
> "")
> (zero_extend:SI
>   (unspec_volatile:NARROW
> [(match_operand:NARROW 1 "mem_noofs_operand"
> "")]
> VUNSPEC_LL)))]
>   "TARGET_HAVE_LDREXBH"
>   "ldrex%?\t%0, %C1"
>   []) ;; We don't need this attr for define_subst
> 
> Define_subst (I didn't copy it here) will expand this to the next
> two patterns:
> ;; First pattern (exactly like original), define_subst not-applied
> (define_insn "arm_load_exclusive"
>   [(set (match_operand:SI 0 "s_register_operand" "=r,r")
> (zero_extend:SI
>   (unspec_volatile:NARROW
> [(match_operand:NARROW 1 "mem_noofs_operand" "Ua,m")]
> VUNSPEC_LL)))]
>   "TARGET_HAVE_LDREXBH"
>   "ldrex%?\t%0, %C1"
>   [])
> ;; Second pattern, with applied define_subst
> (define_insn "arm_load_exclusive"
>   [(cond_exec
>   (match_operator 1 "arm_comparison_operator"
>  [(match_operand 2 "cc_register" "")
>   (const_int 0)])
>   (set
> (match_operand:SI 0 "s_register_operand" "=r")
> (zero_extend:SI
>   (unspec_volatile:NARROW
> [(match_operand:NARROW 1 "mem_noofs_operand" "m")]
> VUNSPEC_LL)))]
>   "TARGET_HAVE_LDREXBH"
>   "ldrex%?\t%0, %C1"
>   [])
> 
> So, the main idea here is to control how many and what alternatives
> which pattern would have - and define_subst allows to do that.
> 
> The only problem here is that we might need many subst-attributes.

Thanks for the explanation.

Unfortunately, that is a strong point against define_subst in my case,
since on arm we have more than 400 predicable patterns, of we which we
might want to modify dozens to perform this cond_exec restriction.
And creating custom subst-attributes for each one would really make
things hard to manage/maintain.

> But I think that problem could also be solved if, as Richard
> suggested, define_cond_exec would be expanded in gensupport - we
> might generate needed attributes there.

So, when a subst-attribute is encountered in a pattern, a substitute is
triggered for the whole pattern (in our case, the cond_exec version is
created). This includes
the alternatives that we might not want predicated. Creating
subst-attributes for each operands' constraint string seems like a bit
of a hack to me,
considering that we have a define_cond_exec construct used specifically
for creating the cond_exec variants by just setting the "predicable"
attribute each alternative
i.e. not touching the patterns themselves.

With my proposed modification to define_cond_exec, if we want to
restrict the cond_exec variant in the way I described, we only add
another set_attr to a pattern, without
moving around their constraint strings.

I'm not sure I see how define_subst could be modified to allow for this
functionality without impacting the current readability of the md
patterns (not to mention the semantics of define_subst itself).

> Thus, define_cond_exec would be a
> kind of 'syntax sugar' for such cases.

From what I can see, define_cond_exec has some extra machinery to allow
for per-alternative predication (with ce_enabled and nonce_enabled) that
I don't think can/should
be easily replicated in define_subst.

According to the documentation, define_subst was created to facilitate
simple transformation

[SH] PR 6526

2013-05-24 Thread Oleg Endo
Hello,

I'd like to fix this ancient PR.
The attached patch picks up the suggested changes mentioned in comment
#3 to avoid changing the FPSCR.FR bit in the sdivsi3_i4 and udivsi3_i4
library functions.  As mentioned in the PR, this makes integer division
a bit slower when using -mdiv=call-fp, but it allows better utilization
of the SH4 matrix multiplication feature.
I've also added SH4A versions of the library functions which utilize the
fpchg instruction.


Tested on rev 199102 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m4/-mb/-mdiv=call-fp,-m4-single/-mb/-mdiv=call-fp,-m4a/-mb/-mdiv=call-fp,
-m4a-single/-mb/-mdiv=call-fp,-m4/-ml/-mdiv=call-fp,
-m4-single/-ml/-mdiv=call-fp,-m4a/-ml/-mdiv=call-fp,
-m4a-single/-ml/-mdiv=call-fp}"

and no new failures.

OK for trunk?

Cheers,
Oleg


libgcc/ChangeLog:

PR target/6526
* config/sh/lib1funcs.S (sdivsi3_i4, udivsi3_i4): Do not change 
bits other than FPSCR.PR and FPSCR.SZ.  Add SH4A implementation.


testsuite/ChangeLog:

PR target/6526
* gcc.target/sh/pr6526.c: New.
Index: libgcc/config/sh/lib1funcs.S
===
--- libgcc/config/sh/lib1funcs.S	(revision 199109)
+++ libgcc/config/sh/lib1funcs.S	(working copy)
@@ -1003,11 +1003,17 @@
 	ENDFUNC(GLOBAL(mulsi3))
 #endif
 #endif /* ! __SH5__ */
+
+/*--
+  32 bit signed integer division that uses FPU double precision division.  */
+
 #ifdef L_sdivsi3_i4
 	.title "SH DIVIDE"
-!! 4 byte integer Divide code for the Renesas SH
+
 #if defined (__SH4__) || defined (__SH2A__)
-!! args in r4 and r5, result in fpul, clobber dr0, dr2
+/* This variant is used when FPSCR.PR = 1 (double precision) is the default
+   setting.
+   Args in r4 and r5, result in fpul, clobber dr0, dr2.  */
 
 	.global	GLOBAL(sdivsi3_i4)
 	HIDDEN_FUNC(GLOBAL(sdivsi3_i4))
@@ -1021,8 +1027,13 @@
 	ftrc dr0,fpul
 
 	ENDFUNC(GLOBAL(sdivsi3_i4))
+
 #elif defined (__SH2A_SINGLE__) || defined (__SH2A_SINGLE_ONLY__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__) || (defined (__SH5__) && ! defined __SH4_NOFPU__)
-!! args in r4 and r5, result in fpul, clobber r2, dr0, dr2
+/* This variant is used when FPSCR.PR = 0 (sigle precision) is the default
+   setting.
+   Args in r4 and r5, result in fpul, clobber r2, dr0, dr2.
+   For this to work, we must temporarily switch the FPU do double precision,
+   but we better do not touch FPSCR.FR.  See PR 6526.  */
 
 #if ! __SH5__ || __SH5__ == 32
 #if __SH5__
@@ -1031,24 +1042,43 @@
 	.global	GLOBAL(sdivsi3_i4)
 	HIDDEN_FUNC(GLOBAL(sdivsi3_i4))
 GLOBAL(sdivsi3_i4):
-	sts.l fpscr,@-r15
-	mov #8,r2
-	swap.w r2,r2
-	lds r2,fpscr
-	lds r4,fpul
-	float fpul,dr0
-	lds r5,fpul
-	float fpul,dr2
-	fdiv dr2,dr0
-	ftrc dr0,fpul
+
+#ifndef __SH4A__
+	mov.l	r3,@-r15
+	sts	fpscr,r2
+	mov	#8,r3
+	swap.w	r3,r3		// r3 = 1 << 19 (FPSCR.PR bit)
+	or	r2,r3
+	lds	r3,fpscr	// Set FPSCR.PR = 1.
+	lds	r4,fpul
+	float	fpul,dr0
+	lds	r5,fpul
+	float	fpul,dr2
+	fdiv	dr2,dr0
+	ftrc	dr0,fpul
+	lds	r2,fpscr
 	rts
-	lds.l @r15+,fpscr
+	mov.l	@r15+,r3
+#else
+/* On SH4A we can use the fpchg instruction to flip the FPSCR.PR bit.  */
+	fpchg
+	lds	r4,fpul
+	float	fpul,dr0
+	lds	r5,fpul
+	float	fpul,dr2
+	fdiv	dr2,dr0
+	ftrc	dr0,fpul
+	rts
+	fpchg	
 
+#endif /* __SH4A__  */
+
 	ENDFUNC(GLOBAL(sdivsi3_i4))
 #endif /* ! __SH5__ || __SH5__ == 32 */
 #endif /* ! __SH4__ || __SH2A__  */
-#endif
+#endif /* L_sdivsi3_i4  */
 
+//--
 #ifdef L_sdivsi3
 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
sh2e/sh3e code.  */
@@ -1367,54 +1397,60 @@
 	mov	#0,r0
 
 	ENDFUNC(GLOBAL(sdivsi3))
-#endif /* ! __SHMEDIA__ */
-#endif
+#endif /* ! __SHMEDIA__  */
+#endif /* L_sdivsi3  */
+
+/*--
+  32 bit unsigned integer division that uses FPU double precision division.  */
+
 #ifdef L_udivsi3_i4
+	.title "SH DIVIDE"
 
-	.title "SH DIVIDE"
-!! 4 byte integer Divide code for the Renesas SH
 #if defined (__SH4__) || defined (__SH2A__)
-!! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4,
-!! and t bit
+/* This variant is used when FPSCR.PR = 1 (double precision) is the default
+   setting.
+   Args in r4 and r5, result in fpul,
+   clobber r0, r1, r4, r5, dr0, dr2, dr4, and t bit  */
 
 	.global	GLOBAL(udivsi3_i4)
 	HIDDEN_FUNC(GLOBAL(udivsi3_i4))
 GLOBAL(udivsi3_i4):
-	mov #1,r1
-	cmp/hi r1,r5
-	bf trivial
-	rotr r1
-	xor r1,r4
-	lds r4,fpul
-	mova L1,r0
+	mov	#1,r1
+	cmp/hi	r1,r5
+	bf/s	trivial
+	rotr	r1
+	xor	r1,r4
+	lds	r4,fpul
+	mova	L1,r0
 #ifdef FMOVD_WORKS
-	fmov.d @r0+,dr4
+	fmov.d	@r0+,dr4
 #else
-	fmov.s @r0+,DR40
-	fmov.s @r0,DR41
+	fmov.s	@r0+,DR40
+	fmov.s	@r0,DR41
 #endif
-	float fpul,dr0
-	xor r1,r5
-	lds r5,fpul
-	float fpul,dr2
-	fadd dr4,dr0
-	fadd dr4,dr2
-	fdiv dr2,dr0
+	

Re: [PATCH][gensupport] Add optional attributes field to define_cond_exec

2013-05-24 Thread Michael Zolotukhin
> Unfortunately, that is a strong point against define_subst in my case,
> since on arm we have more than 400 predicable patterns, of we which we
> might want to modify dozens to perform this cond_exec restriction.
> And creating custom subst-attributes for each one would really make
> things hard to manage/maintain.
That's definitely a reason:)

> With my proposed modification to define_cond_exec, if we want to
> restrict the cond_exec variant in the way I described, we only add
> another set_attr to a pattern, without
> moving around their constraint strings.
>
> I'm not sure I see how define_subst could be modified to allow for this
> functionality without impacting the current readability of the md
> patterns (not to mention the semantics of define_subst itself).

Let me check my understanding of your solution. You suggest to add
(set_attr "control_var" "yes,no")
to every define_insn in which we want to disable second alternative in
predicated pattern, right?
Then, when cond_exec has processed the initial pattern, we get two
patterns: in the first one (not-predicated) we have 'predicated'
attribute set to its default value 'no' and in the second pattern
(predicated) this attribute is set to 'yes'. Basing on this, 'enabled'
is computed for each pattern. It equals 'yes,yes' for the first one
and 'yes,no' for the second one.
So, what you need is to have an attribute to distinguish predicated
pattern from not-predicated one, correct?

If that vision is correct, it could be easily done with define_subst
(and without tons of new subst-attributes, as I suggested before:) ):
Just add one subst attribute
(define_subst_attr "subst_predicated" "ds_predicable" "no" "yes")
and add it to define_insn pattern:
(define_insn ...
[(set_attr "predicable" "yes")
 (set_attr "control_attr" "yes,")])
I think that'll do the trick.

Everything else is remaining as you suggested (I mean proper use of
'control_attr' in 'enabled' attribute).


> Thanks,
> Kyrill
Thanks, Michael


On 24 May 2013 14:11, Kyrylo Tkachov  wrote:
> Hi Michael,
>
>> > - What about define_insn_and_split? Currently, we can define
>> "predicable"
>> > for a define_insn_and_split,
>> Yes, you're right. Currently define_subst cannot be applied to
>> define_insn_and_split. That's not implemented yet because I didn't
>> see
>> a real usages of define_substs with these (though I'm not saying
>> nobody uses it) - in absence of use cases I wasn't able to design a
>> proper syntax for it. If you have any ideas of how that could be
>> done
>> in a pretty way, please let me know:)
>>
>> As for your second concern:
>> > - What about predication on a per-alternative basis (set_attr
>> "predicable"
>> > "yes,no,yes")?
>> Currently, cond_exec actually could be a more compact way of doing
>> this. But in general, define_subst is able to substitute it (as
>> Richard said, it's a superset of define_cond_exec). Here is an
>> example
>> of how that could be achieved (maybe, it's not optimal in terms of
>> lines of code):
>> Suppose we have:
>> (define_insn "arm_load_exclusive"
>>   [(set (match_operand:SI 0 "s_register_operand" "=r,r")
>> (zero_extend:SI
>>   (unspec_volatile:NARROW
>> [(match_operand:NARROW 1 "mem_noofs_operand" "Ua,m")]
>> VUNSPEC_LL)))]
>>   "TARGET_HAVE_LDREXBH"
>>   "ldrex%?\t%0, %C1"
>>   [(set_attr "predicable" "yes,no")])
>> (I added a second alternative to the define_insn from your example)
>>
>> We could add several subst-attributes, as following:
>> (define_subst_attr "constraint_operand1" "ds_predicable" "=r,r"
>> "=r")
>> (define_subst_attr "constraint_operand2" "ds_predicable" "=Ua,m"
>> "Ua")
>> And then rewrite the original pattern:
>> (define_insn "arm_load_exclusive"
>>   [(set (match_operand:SI 0 "s_register_operand"
>> "")
>> (zero_extend:SI
>>   (unspec_volatile:NARROW
>> [(match_operand:NARROW 1 "mem_noofs_operand"
>> "")]
>> VUNSPEC_LL)))]
>>   "TARGET_HAVE_LDREXBH"
>>   "ldrex%?\t%0, %C1"
>>   []) ;; We don't need this attr for define_subst
>>
>> Define_subst (I didn't copy it here) will expand this to the next
>> two patterns:
>> ;; First pattern (exactly like original), define_subst not-applied
>> (define_insn "arm_load_exclusive"
>>   [(set (match_operand:SI 0 "s_register_operand" "=r,r")
>> (zero_extend:SI
>>   (unspec_volatile:NARROW
>> [(match_operand:NARROW 1 "mem_noofs_operand" "Ua,m")]
>> VUNSPEC_LL)))]
>>   "TARGET_HAVE_LDREXBH"
>>   "ldrex%?\t%0, %C1"
>>   [])
>> ;; Second pattern, with applied define_subst
>> (define_insn "arm_load_exclusive"
>>   [(cond_exec
>>   (match_operator 1 "arm_comparison_operator"
>>  [(match_operand 2 "cc_register" "")
>>   (const_int 0)])
>>   (set
>> (match_operand:SI 0 "s_register_operand" "=r")
>> (zero_extend:SI
>>   (unspec_volatile:NARROW
>> [(match_operand:NARROW 1 "mem_noofs_operand" "m")]
>> VUNSPE

[PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Andrew Hsieh
Bionic prior to Gingerbread doesn't support sincos*, but upstream GCC
enables sincos optimization for OPTION_BIONIC unconditionally since
4.6.  I'd like to propose a new flag -foptimize-sincos for NDK to
maintain backward compatibility.

1. For BIONIC: sincos optimization is disabled by default.  Apps built
for Gingerbread+ or AOSP platform build which uses the same compiler
as NDK, can add -foptimize-sincos to enhance performance.  (although
it's likely that only benchmarks may benefit)

2. Other C libs aren't affected.  sincos optimization is enabled for
GLIBC and disabled for othres, regardless of this flag.


Index: gcc/common.opt
===
--- gcc/common.opt (revision 199277)
+++ gcc/common.opt (working copy)
@@ -1591,6 +1591,10 @@
 Common Report Var(flag_optimize_sibling_calls) Optimization
 Optimize sibling and tail recursive calls

+foptimize-sincos
+Common Report Var(flag_optimize_sincos) Optimization
+Optimize calls to sin() and cos() with the same argument to sincos()
+
 fpartial-inlining
 Common Report Var(flag_partial_inlining)
 Perform partial inlining
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 199277)
+++ gcc/doc/invoke.texi (working copy)
@@ -388,7 +388,7 @@
 -fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol
 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
 -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls @gol
--fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
+-foptimize-sincos -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
 -fprefetch-loop-arrays -fprofile-report @gol
 -fprofile-correction -fprofile-dir=@var{path} -fprofile-generate @gol
 -fprofile-generate=@var{path} @gol
@@ -6586,6 +6586,7 @@
 -fipa-profile @gol
 -fipa-reference @gol
 -fmerge-constants
+-foptimize-sincos @gol
 -fsplit-wide-types @gol
 -ftree-bit-ccp @gol
 -ftree-builtin-call-dce @gol
@@ -6772,6 +6773,12 @@

 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.

+@item -foptimize-sincos
+@opindex foptimize-sincos
+Optimize calls to sin() and cos() with the same argument to sincos()
+
+Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
+
 @item -fno-inline
 @opindex fno-inline
 Do not expand any functions inline apart from those marked with
Index: gcc/config/linux.h
===
--- gcc/config/linux.h (revision 199277)
+++ gcc/config/linux.h (working copy)
@@ -102,7 +102,7 @@

 /* Whether we have sincos that follows the GNU extension.  */
 #undef TARGET_HAS_SINCOS
-#define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC)
+#define TARGET_HAS_SINCOS (OPTION_GLIBC || (OPTION_BIONIC &&
flag_optimize_sincos))

 /* Whether we have Bionic libc runtime */
 #undef TARGET_HAS_BIONIC


[PATCH] Fix PR57287

2013-05-24 Thread Richard Biener

After spending some time to try retaining some abnormal SSA name
uninitialized uses I gave up and just punt like below.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

Richard.

2013-05-24  Richard Biener  

PR tree-optimization/57287
* tree-ssa-uninit.c (compute_uninit_opnds_pos): Disregard
all SSA names that occur in abnormal PHIs.

* gcc.dg/pr57287.c: New testcase.

Index: gcc/tree-ssa-uninit.c
===
--- gcc/tree-ssa-uninit.c   (revision 199284)
+++ gcc/tree-ssa-uninit.c   (working copy)
@@ -165,17 +165,12 @@ compute_uninit_opnds_pos (gimple phi)
   && uninit_undefined_value_p (op)
   && !can_skip_redundant_opnd (op, phi))
{
- /* Ignore SSA_NAMEs on abnormal edges to setjmp
-or nonlocal goto receiver.  */
   if (cfun->has_nonlocal_label || cfun->calls_setjmp)
{
- edge e = gimple_phi_arg_edge (phi, i);
- if (e->flags & EDGE_ABNORMAL)
-   {
- gimple last = last_stmt (e->src);
- if (last && stmt_can_make_abnormal_goto (last))
-   continue;
-   }
+ /* Ignore SSA_NAMEs that appear on abnormal edges
+somewhere.  */
+ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op))
+   continue;
}
  MASK_SET_BIT (uninit_opnds, i);
}
Index: gcc/testsuite/gcc.dg/pr57287.c
===
--- gcc/testsuite/gcc.dg/pr57287.c  (revision 0)
+++ gcc/testsuite/gcc.dg/pr57287.c  (working copy)
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+#include 
+
+jmp_buf buf;
+
+void foo (int);
+void bar (int) __attribute__((leaf));
+
+void enumerate_locals (int indent)
+{
+  foo (0);
+  while (indent--)
+{
+  int local_indent = 8 + (8 * indent);
+  if (local_indent != 8)
+   {
+ setjmp (buf);
+ bar (local_indent);  /* { dg-bogus "may be used uninitialized" "" } */
+   }
+}
+  foo (1);
+}


RE: [PATCH][gensupport] Add optional attributes field to define_cond_exec

2013-05-24 Thread Kyrylo Tkachov
> > Unfortunately, that is a strong point against define_subst in my
> case,
> > since on arm we have more than 400 predicable patterns, of we
> which we
> > might want to modify dozens to perform this cond_exec
> restriction.
> > And creating custom subst-attributes for each one would really
> make
> > things hard to manage/maintain.
> That's definitely a reason:)
> 
> > With my proposed modification to define_cond_exec, if we want to
> > restrict the cond_exec variant in the way I described, we only
> add
> > another set_attr to a pattern, without
> > moving around their constraint strings.
> >
> > I'm not sure I see how define_subst could be modified to allow
> for this
> > functionality without impacting the current readability of the md
> > patterns (not to mention the semantics of define_subst itself).
> 
> Let me check my understanding of your solution. You suggest to add
> (set_attr "control_var" "yes,no")
> to every define_insn in which we want to disable second alternative
> in
> predicated pattern, right?

Crucially, I want to disable the second alternative in the predicated
pattern on a non-static condition (i.e. a flag, I used
TARGET_RESTRICT_CE in previous examples)

> Then, when cond_exec has processed the initial pattern, we get two
> patterns: in the first one (not-predicated) we have 'predicated'
> attribute set to its default value 'no' and in the second pattern
> (predicated) this attribute is set to 'yes'. Basing on this,
> 'enabled'
> is computed for each pattern. It equals 'yes,yes' for the first one
> and 'yes,no' for the second one.
> So, what you need is to have an attribute to distinguish predicated
> pattern from not-predicated one, correct?

Yes, that's right :)

> 
> If that vision is correct, it could be easily done with
> define_subst
> (and without tons of new subst-attributes, as I suggested before:)
> ):
> Just add one subst attribute
> (define_subst_attr "subst_predicated" "ds_predicable" "no" "yes")
> and add it to define_insn pattern:
> (define_insn ...
> [(set_attr "predicable" "yes")
>  (set_attr "control_attr" "yes,")])

So, "predicable" only has some implicit meaning when define_cond_exec is
used, so we might as well remove that (set_attr "predicable" ...) if we
are going to replace define_cond_exec with a define_subst.

> I think that'll do the trick.

Almost, there is one problem however. What if I want the second
alternative to never be predicated?
The purpose of control_attr in my scheme is to disable the cond_exec
version when a particular flag is set (I used TARGET_RESTRICT_CE as an
example earlier in this thread), not to disable predication of
that  alternative forever, that's what "predicable" is for.

As things stand now, if "predicable" is set to "no" for a particular
alternative, the value of control_attr is irrelevant, that alternative
will never have a cond_exec version. In your scheme, however, 
the presence of  triggers the creation of cond_exec
variants for all of the alternatives, even the ones that we don't want
to cond_exec.

Another variant of your suggestion would be:
[(set_attr "predicated" "")
 (set_attr "control_attr" "yes,no")])

which would set "predicated" to "yes" in the cond_exec version and "no"
in the original, thus distinguishing between them. control_attr would
then be used in the definition of "enabled" to disable the 
cond_exec version when a certain flag is set. This is what I want, but
again there's a problem with non-predicable alternatives.
What if I also had a 3rd alternative that was not predicable at all?
(set_attr "predicable" "yes,yes,no").
The presence of  would force the creation of a
cond_exec variant for that alternative and disabling that would require
another attribute like this:

[(set_attr "predicated" "")
 (set_attr "control_attr" "yes,no,no") <<< 3rd value is irrelevant
 (set_attr "predicable_valid" "yes,yes,no")])

and an extra rule in "enabled" that disables an alternative when
"predicated" is "yes" and "predicable_valid" is "no", which again adds
lots of superfluous churn to the md patterns.

(Sorry if this is a bit of a ramble, I'm just trying to find a solution
that will have the least impact on the md patterns :) )
Thanks,
Kyrill

> 
> Everything else is remaining as you suggested (I mean proper use of
> 'control_attr' in 'enabled' attribute).
> 
> 
> > Thanks,
> > Kyrill
> Thanks, Michael
> 
> 
> On 24 May 2013 14:11, Kyrylo Tkachov 
> wrote:
> > Hi Michael,
> >
> >> > - What about define_insn_and_split? Currently, we can define
> >> "predicable"
> >> > for a define_insn_and_split,
> >> Yes, you're right. Currently define_subst cannot be applied to
> >> define_insn_and_split. That's not implemented yet because I
> didn't
> >> see
> >> a real usages of define_substs with these (though I'm not saying
> >> nobody uses it) - in absence of use cases I wasn't able to
> design a
> >> proper syntax for it. If you have any ideas of how that could be
> >> done
> >> in a pretty way, please let me know:)
> >>
> >> As

Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Richard Biener
On Fri, May 24, 2013 at 12:53 PM, Andrew Hsieh  wrote:
> Bionic prior to Gingerbread doesn't support sincos*, but upstream GCC
> enables sincos optimization for OPTION_BIONIC unconditionally since
> 4.6.  I'd like to propose a new flag -foptimize-sincos for NDK to
> maintain backward compatibility.
>
> 1. For BIONIC: sincos optimization is disabled by default.  Apps built
> for Gingerbread+ or AOSP platform build which uses the same compiler
> as NDK, can add -foptimize-sincos to enhance performance.  (although
> it's likely that only benchmarks may benefit)
>
> 2. Other C libs aren't affected.  sincos optimization is enabled for
> GLIBC and disabled for othres, regardless of this flag.

That's a pretty awful option name for one that makes us assume the target
C library has a sincos function.

I'd rather think about a way to specify, for all known builtins, whether GCC
should generate calls to such function where they are not in the source
program.  That is, similar to how we have -f[no-]builtin-FOO introduce
-f[no-]libc-FOO (with a better name for 'libc'?).  That way there would be
a way to specify that -floop-distribute-patterns should not produce calls
to memset () for example.

Richard.

> 
> Index: gcc/common.opt
> ===
> --- gcc/common.opt (revision 199277)
> +++ gcc/common.opt (working copy)
> @@ -1591,6 +1591,10 @@
>  Common Report Var(flag_optimize_sibling_calls) Optimization
>  Optimize sibling and tail recursive calls
>
> +foptimize-sincos
> +Common Report Var(flag_optimize_sincos) Optimization
> +Optimize calls to sin() and cos() with the same argument to sincos()
> +
>  fpartial-inlining
>  Common Report Var(flag_partial_inlining)
>  Perform partial inlining
> Index: gcc/doc/invoke.texi
> ===
> --- gcc/doc/invoke.texi (revision 199277)
> +++ gcc/doc/invoke.texi (working copy)
> @@ -388,7 +388,7 @@
>  -fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol
>  -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
>  -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls @gol
> --fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
> +-foptimize-sincos -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
>  -fprefetch-loop-arrays -fprofile-report @gol
>  -fprofile-correction -fprofile-dir=@var{path} -fprofile-generate @gol
>  -fprofile-generate=@var{path} @gol
> @@ -6586,6 +6586,7 @@
>  -fipa-profile @gol
>  -fipa-reference @gol
>  -fmerge-constants
> +-foptimize-sincos @gol
>  -fsplit-wide-types @gol
>  -ftree-bit-ccp @gol
>  -ftree-builtin-call-dce @gol
> @@ -6772,6 +6773,12 @@
>
>  Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
>
> +@item -foptimize-sincos
> +@opindex foptimize-sincos
> +Optimize calls to sin() and cos() with the same argument to sincos()
> +
> +Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
> +
>  @item -fno-inline
>  @opindex fno-inline
>  Do not expand any functions inline apart from those marked with
> Index: gcc/config/linux.h
> ===
> --- gcc/config/linux.h (revision 199277)
> +++ gcc/config/linux.h (working copy)
> @@ -102,7 +102,7 @@
>
>  /* Whether we have sincos that follows the GNU extension.  */
>  #undef TARGET_HAS_SINCOS
> -#define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC)
> +#define TARGET_HAS_SINCOS (OPTION_GLIBC || (OPTION_BIONIC &&
> flag_optimize_sincos))
>
>  /* Whether we have Bionic libc runtime */
>  #undef TARGET_HAS_BIONIC


Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 02:10:18PM +0200, Richard Biener wrote:
> That's a pretty awful option name for one that makes us assume the target
> C library has a sincos function.
> 
> I'd rather think about a way to specify, for all known builtins, whether GCC
> should generate calls to such function where they are not in the source
> program.  That is, similar to how we have -f[no-]builtin-FOO introduce
> -f[no-]libc-FOO (with a better name for 'libc'?).  That way there would be
> a way to specify that -floop-distribute-patterns should not produce calls
> to memset () for example.

Yeah.  Or we could be more aggressive at producing stpcpy, mempcpy etc.
calls where it could be beneficial and have a way to disable that.
What we currently do for stpcpy is c/c-decl.c (merge_decl) and
cp/decl.c (duplicate_decls) has code that if not -fno-builtin-stpcpy and
a compatible prototype is seen for stpcpy, then we allow it to be generated
implicitly (set_builtin_decl_implicit_p (fncode, true);).
Yeah, we could do the same for sincos, I bet most of the people don't
prototype sin or cos themselves but include , but in all cases
it means the compiler will do it only if stpcpy resp. sincos is actually
prototyped in the headers (right feature test macros for that).

Jakub


Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Alexander Ivchenko
Richard, the target hook (libc_has_function) for what you described is
waiting for a review:
http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01201.html

However, it doesn't have command line options support.

Alexander


2013/5/24 Richard Biener :
> On Fri, May 24, 2013 at 12:53 PM, Andrew Hsieh  wrote:
>> Bionic prior to Gingerbread doesn't support sincos*, but upstream GCC
>> enables sincos optimization for OPTION_BIONIC unconditionally since
>> 4.6.  I'd like to propose a new flag -foptimize-sincos for NDK to
>> maintain backward compatibility.
>>
>> 1. For BIONIC: sincos optimization is disabled by default.  Apps built
>> for Gingerbread+ or AOSP platform build which uses the same compiler
>> as NDK, can add -foptimize-sincos to enhance performance.  (although
>> it's likely that only benchmarks may benefit)
>>
>> 2. Other C libs aren't affected.  sincos optimization is enabled for
>> GLIBC and disabled for othres, regardless of this flag.
>
> That's a pretty awful option name for one that makes us assume the target
> C library has a sincos function.
>
> I'd rather think about a way to specify, for all known builtins, whether GCC
> should generate calls to such function where they are not in the source
> program.  That is, similar to how we have -f[no-]builtin-FOO introduce
> -f[no-]libc-FOO (with a better name for 'libc'?).  That way there would be
> a way to specify that -floop-distribute-patterns should not produce calls
> to memset () for example.
>
> Richard.
>
>> 
>> Index: gcc/common.opt
>> ===
>> --- gcc/common.opt (revision 199277)
>> +++ gcc/common.opt (working copy)
>> @@ -1591,6 +1591,10 @@
>>  Common Report Var(flag_optimize_sibling_calls) Optimization
>>  Optimize sibling and tail recursive calls
>>
>> +foptimize-sincos
>> +Common Report Var(flag_optimize_sincos) Optimization
>> +Optimize calls to sin() and cos() with the same argument to sincos()
>> +
>>  fpartial-inlining
>>  Common Report Var(flag_partial_inlining)
>>  Perform partial inlining
>> Index: gcc/doc/invoke.texi
>> ===
>> --- gcc/doc/invoke.texi (revision 199277)
>> +++ gcc/doc/invoke.texi (working copy)
>> @@ -388,7 +388,7 @@
>>  -fno-sched-interblock -fno-sched-spec -fno-signed-zeros @gol
>>  -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
>>  -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls @gol
>> --fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
>> +-foptimize-sincos -fpartial-inlining -fpeel-loops -fpredictive-commoning 
>> @gol
>>  -fprefetch-loop-arrays -fprofile-report @gol
>>  -fprofile-correction -fprofile-dir=@var{path} -fprofile-generate @gol
>>  -fprofile-generate=@var{path} @gol
>> @@ -6586,6 +6586,7 @@
>>  -fipa-profile @gol
>>  -fipa-reference @gol
>>  -fmerge-constants
>> +-foptimize-sincos @gol
>>  -fsplit-wide-types @gol
>>  -ftree-bit-ccp @gol
>>  -ftree-builtin-call-dce @gol
>> @@ -6772,6 +6773,12 @@
>>
>>  Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
>>
>> +@item -foptimize-sincos
>> +@opindex foptimize-sincos
>> +Optimize calls to sin() and cos() with the same argument to sincos()
>> +
>> +Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
>> +
>>  @item -fno-inline
>>  @opindex fno-inline
>>  Do not expand any functions inline apart from those marked with
>> Index: gcc/config/linux.h
>> ===
>> --- gcc/config/linux.h (revision 199277)
>> +++ gcc/config/linux.h (working copy)
>> @@ -102,7 +102,7 @@
>>
>>  /* Whether we have sincos that follows the GNU extension.  */
>>  #undef TARGET_HAS_SINCOS
>> -#define TARGET_HAS_SINCOS (OPTION_GLIBC || OPTION_BIONIC)
>> +#define TARGET_HAS_SINCOS (OPTION_GLIBC || (OPTION_BIONIC &&
>> flag_optimize_sincos))
>>
>>  /* Whether we have Bionic libc runtime */
>>  #undef TARGET_HAS_BIONIC


[PATCH] Fix PR57396

2013-05-24 Thread Richard Biener

Predictive commoning thinks that { a, +, a + 1 } and { 2 * a, +, a + 1 }
are just 1 iteration apart because when verifying if the difference
between a and 2*a is a multiple of a + 1 it falls into the trap
of double_int_constant_multiple_p returning true (but not initializing
a multiplier) for the question whether 0 is a multiple of 1
(the opposite question, whether 1 is a multiple of 0 is false of course).
But it fails to set mult to zero in this case and the caller doesn't
check for that.

Fixed by changing the semantics of double_int_constant_multiple_p
to also record a zero as multiplier if VAL == 0.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Zdenek, does this look ok?  double_int_constant_multiple_p seems to
be only used from aff_combination_constant_multiple_p.

Thanks,
Richard.

2013-05-24  Richard Biener  

PR tree-optimization/57396
* tree-affine.c (double_int_constant_multiple_p): Properly
return false for val == 0 and div != 0.

* gfortran.fortran-torture/execute/pr57396.f90: New testcase.

Index: gcc/tree-affine.c
===
*** gcc/tree-affine.c   (revision 199284)
--- gcc/tree-affine.c   (working copy)
*** free_affine_expand_cache (struct pointer
*** 736,746 
  }
  
  /* If VAL != CST * DIV for any constant CST, returns false.
!Otherwise, if VAL != 0 (and hence CST != 0), and *MULT_SET is true,
!additionally compares CST and MULT, and if they are different,
!returns false.  Finally, if neither of these two cases occur,
!true is returned, and if CST != 0, CST is stored to MULT and
!MULT_SET is set to true.  */
  
  static bool
  double_int_constant_multiple_p (double_int val, double_int div,
--- 736,745 
  }
  
  /* If VAL != CST * DIV for any constant CST, returns false.
!Otherwise, if *MULT_SET is true, additionally compares CST and MULT,
!and if they are different, returns false.  Finally, if neither of these
!two cases occur, true is returned, and CST is stored to MULT and MULT_SET
!is set to true.  */
  
  static bool
  double_int_constant_multiple_p (double_int val, double_int div,
*** double_int_constant_multiple_p (double_i
*** 749,755 
double_int rem, cst;
  
if (val.is_zero ())
! return true;
  
if (div.is_zero ())
  return false;
--- 748,760 
double_int rem, cst;
  
if (val.is_zero ())
! {
!   if (*mult_set && !mult->is_zero ())
!   return false;
!   *mult_set = true;
!   *mult = double_int_zero;
!   return true;
! }
  
if (div.is_zero ())
  return false;
Index: gcc/testsuite/gfortran.fortran-torture/execute/pr57396.f90
===
*** gcc/testsuite/gfortran.fortran-torture/execute/pr57396.f90  (revision 0)
--- gcc/testsuite/gfortran.fortran-torture/execute/pr57396.f90  (working copy)
***
*** 0 
--- 1,33 
+ module testmod
+   implicit none
+ 
+   contains
+ 
+   subroutine foo(n)
+ integer, intent(in) :: n
+ real :: r(0:n,-n:n), a(0:n,-n:n), dj
+ integer :: k, j
+ 
+ ! initialize with some dummy values
+ do j = -n, n
+   a(:, j) = j
+   r(:,j) = j + 1
+ end do
+ 
+ ! here be dragons
+ do k = 0, n
+   dj = r(k, k - 2) * a(k, k - 2)
+   r(k,k) = a(k, k - 1) * dj
+ enddo
+ 
+ if (r(0,0) .ne. -2.) call abort
+ 
+   end subroutine
+ 
+ end module
+ 
+ program test
+   use testmod
+   implicit none
+   call foo(5)
+ end program


Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Richard Biener
On Fri, May 24, 2013 at 2:18 PM, Jakub Jelinek  wrote:
> On Fri, May 24, 2013 at 02:10:18PM +0200, Richard Biener wrote:
>> That's a pretty awful option name for one that makes us assume the target
>> C library has a sincos function.
>>
>> I'd rather think about a way to specify, for all known builtins, whether GCC
>> should generate calls to such function where they are not in the source
>> program.  That is, similar to how we have -f[no-]builtin-FOO introduce
>> -f[no-]libc-FOO (with a better name for 'libc'?).  That way there would be
>> a way to specify that -floop-distribute-patterns should not produce calls
>> to memset () for example.
>
> Yeah.  Or we could be more aggressive at producing stpcpy, mempcpy etc.
> calls where it could be beneficial and have a way to disable that.
> What we currently do for stpcpy is c/c-decl.c (merge_decl) and
> cp/decl.c (duplicate_decls) has code that if not -fno-builtin-stpcpy and
> a compatible prototype is seen for stpcpy, then we allow it to be generated
> implicitly (set_builtin_decl_implicit_p (fncode, true);).

But for example memset/memcpy always have that set, even if no prototype
is in the source.  So, is that decl_implicit_p really supposed to tell us
whether we've seen a compatible prototype?

> Yeah, we could do the same for sincos, I bet most of the people don't
> prototype sin or cos themselves but include , but in all cases
> it means the compiler will do it only if stpcpy resp. sincos is actually
> prototyped in the headers (right feature test macros for that).

Right, that would be good enough for C and C++ - but what to do for Fortran?

Richard.

> Jakub


[C++ Patch] PR 19618

2013-05-24 Thread Paolo Carlini

Hi,

I think we can resolve this very old issue too: we don't warn at all for 
bitfields of size exceeding the type when it's bool or enum. I have no 
idea why historically we decided to not do that, but certainly all the 
modern compilers I have at hand do warn, by default, thus it seems safe 
to at least pedwarn, or even simply warn, if you like.


Patch booted and tested x86_64-linux.

Thanks,
Paolo.

//
/cp
2013-05-24  Paolo Carlini  

PR c++/19618
* class.c (check_bitfield_decl): Pedwarn for bool and enum bitfields
with width exceeding the type.

/testsuite
2013-05-24  Paolo Carlini  

PR c++/19618
* g++.dg/expr/bitfield12.C: New.
* g++.dg/expr/bitfield1.C: Adjust.
* g++.dg/expr/bitfield3.C: Likewise.
* g++.dg/expr/bitfield4.C: Likewise.
* g++.dg/expr/bitfield5.C: Likewise.
* g++.dg/expr/bitfield6.C: Likewise.
* g++.old-deja/g++.jason/bool2.C: Likewise.
Index: cp/class.c
===
--- cp/class.c  (revision 199287)
+++ cp/class.c  (working copy)
@@ -3140,10 +3140,15 @@ check_bitfield_decl (tree field)
  error ("zero width for bit-field %q+D", field);
  w = error_mark_node;
}
-  else if (compare_tree_int (w, TYPE_PRECISION (type)) > 0
-  && TREE_CODE (type) != ENUMERAL_TYPE
-  && TREE_CODE (type) != BOOLEAN_TYPE)
-   warning (0, "width of %q+D exceeds its type", field);
+  else if (compare_tree_int (w, TYPE_PRECISION (type)) > 0)
+   {
+ if (TREE_CODE (type) == ENUMERAL_TYPE
+ || TREE_CODE (type) == BOOLEAN_TYPE)
+   pedwarn (input_location, OPT_Wpedantic,
+"width of %q+D exceeds its type", field);
+ else
+   warning (0, "width of %q+D exceeds its type", field);
+   }
   else if (TREE_CODE (type) == ENUMERAL_TYPE
   && (0 > (compare_tree_int
(w, TYPE_PRECISION (ENUM_UNDERLYING_TYPE (type))
Index: testsuite/g++.dg/expr/bitfield1.C
===
--- testsuite/g++.dg/expr/bitfield1.C   (revision 199288)
+++ testsuite/g++.dg/expr/bitfield1.C   (working copy)
@@ -1,4 +1,5 @@
 // PR c++/27505
+// { dg-options "" }
 
 struct s {
   bool field:8;
Index: testsuite/g++.dg/expr/bitfield12.C
===
--- testsuite/g++.dg/expr/bitfield12.C  (revision 0)
+++ testsuite/g++.dg/expr/bitfield12.C  (working copy)
@@ -0,0 +1,11 @@
+// PR c++/19618
+
+struct bset1 {
+  bool bit : 93111;// { dg-error "exceeds" }
+};
+
+enum E {};
+
+struct bset2 {
+  E bit : 93111;   // { dg-error "exceeds" }
+};
Index: testsuite/g++.dg/expr/bitfield3.C
===
--- testsuite/g++.dg/expr/bitfield3.C   (revision 199288)
+++ testsuite/g++.dg/expr/bitfield3.C   (working copy)
@@ -1,4 +1,5 @@
 // PR c++/30274
+// { dg-options "" }
 
 struct S {
   bool x : 4;
Index: testsuite/g++.dg/expr/bitfield4.C
===
--- testsuite/g++.dg/expr/bitfield4.C   (revision 199288)
+++ testsuite/g++.dg/expr/bitfield4.C   (working copy)
@@ -1,5 +1,6 @@
 // PR c++/30274
 // { dg-do link }
+// { dg-options "" }
 
 struct S {
   bool x : 4;
Index: testsuite/g++.dg/expr/bitfield5.C
===
--- testsuite/g++.dg/expr/bitfield5.C   (revision 199288)
+++ testsuite/g++.dg/expr/bitfield5.C   (working copy)
@@ -1,5 +1,6 @@
 // PR c++/30274
 // { dg-do run }
+// { dg-options "" }
 
 struct S {
   bool x : 4;
Index: testsuite/g++.dg/expr/bitfield6.C
===
--- testsuite/g++.dg/expr/bitfield6.C   (revision 199288)
+++ testsuite/g++.dg/expr/bitfield6.C   (working copy)
@@ -1,4 +1,5 @@
 // PR c++/30274
+// { dg-options "" }
 
 struct S {
   bool x : 4;
Index: testsuite/g++.old-deja/g++.jason/bool2.C
===
--- testsuite/g++.old-deja/g++.jason/bool2.C(revision 199287)
+++ testsuite/g++.old-deja/g++.jason/bool2.C(working copy)
@@ -1,4 +1,5 @@
 // { dg-do run  }
+// { dg-options "" }
 // Make sure that bool bitfields promote to int properly.
 
 struct F {


[PING][PATCH,ARM] Fix PR56732 - backport to gcc 4.8

2013-05-24 Thread Greta Yorsh
This patch (trunk r198547)
http://gcc.gnu.org/ml/gcc-patches/2013-05/msg00061.html
fixes an ICE in gcc 4.8:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732

Ok to backport to 4.8 branch?

Thanks,
Greta

> -Original Message-
> From: Richard Earnshaw
> Sent: 02 May 2013 15:45
> To: Greta Yorsh
> Cc: GCC Patches; Ramana Radhakrishnan; diffg...@gmail.com;
> enrico.sch...@informatik.tu-chemnitz.de; mi...@it.uu.se
> Subject: Re: [PATCH,ARM] Fix PR56732
> 
> On 02/05/13 13:52, Greta Yorsh wrote:
> > Epilogue in RTL (r188743) generated for naked functions adds simple
> return
> > jump insn and causes an ICE, as described here:
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732
> >
> > There is a missing check of really_return argument in
> arm_expand_epilogue.
> > This patch adds the missing check and a new test.
> >
> > No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb.
> > Bootstrap successful on Cortex-A15 and no regression.
> >
> > Ok for trunk?
> >
> > Thanks,
> > Greta
> >
> > gcc/ChangeLog
> >
> > 2013-05-02  Greta Yorsh  
> >
> > PR target/56732
> > * config/arm/arm.c (arm_expand_epilogue): Check really_return
> before
> > generating simple_return for naked functions.
> >
> > gcc/testsuite/ChangeLog
> >
> > 2013-05-02  Greta Yorsh  
> >
> > PR target/56732
> > * gcc.target/arm/pr56732-1.c: New test.
> >
> >
> OK.
> 
> R.





Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 02:23:45PM +0200, Richard Biener wrote:
> But for example memset/memcpy always have that set, even if no prototype
> is in the source.  So, is that decl_implicit_p really supposed to tell us
> whether we've seen a compatible prototype?

decl_implicit_p isn't whether we've seen a compatible prototype, but whether
it is ok for the compiler to make calls to that function, even when there
were none in the source.  Usually this comes from how we define the builtin
in builtins.def, whether it is a standard required function or some
extension beyond the standard.  And for stpcpy right now we are using this
way (kind of hack).

> Right, that would be good enough for C and C++ - but what to do for Fortran?

Sure.  So what about have a -f{,no-}builtin-implicit-{builtin_name}
with the default as is right now, that would just tweak decl_implicit_p if
decl_explicit_p is true.

Jakub


Re: [PING][PATCH,ARM] Fix PR56732 - backport to gcc 4.8

2013-05-24 Thread Ramana Radhakrishnan

On 05/24/13 13:26, Greta Yorsh wrote:

This patch (trunk r198547)
http://gcc.gnu.org/ml/gcc-patches/2013-05/msg00061.html
fixes an ICE in gcc 4.8:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56732

Ok to backport to 4.8 branch?



Ok.

regards
Ramana



Thanks,
Greta

gcc/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* config/arm/arm.c (arm_expand_epilogue): Check really_return

before

generating simple_return for naked functions.

gcc/testsuite/ChangeLog

2013-05-02  Greta Yorsh  

PR target/56732
* gcc.target/arm/pr56732-1.c: New test.



OK.

R.








Re: [PATCH,bionic] Add -foptimize-sincos

2013-05-24 Thread Richard Biener
On Fri, May 24, 2013 at 2:28 PM, Jakub Jelinek  wrote:
> On Fri, May 24, 2013 at 02:23:45PM +0200, Richard Biener wrote:
>> But for example memset/memcpy always have that set, even if no prototype
>> is in the source.  So, is that decl_implicit_p really supposed to tell us
>> whether we've seen a compatible prototype?
>
> decl_implicit_p isn't whether we've seen a compatible prototype, but whether
> it is ok for the compiler to make calls to that function, even when there
> were none in the source.  Usually this comes from how we define the builtin
> in builtins.def, whether it is a standard required function or some
> extension beyond the standard.  And for stpcpy right now we are using this
> way (kind of hack).
>
>> Right, that would be good enough for C and C++ - but what to do for Fortran?
>
> Sure.  So what about have a -f{,no-}builtin-implicit-{builtin_name}
> with the default as is right now, that would just tweak decl_implicit_p if
> decl_explicit_p is true.

That works for me.  We could still have a way for targets to override the
default here.

Richard.

> Jakub


Re: [PATCH][gensupport] Add optional attributes field to define_cond_exec

2013-05-24 Thread Michael Zolotukhin
> As things stand now, if "predicable" is set to "no" for a particular
> alternative, the value of control_attr is irrelevant, that alternative
> will never have a cond_exec version. In your scheme, however,
> the presence of  triggers the creation of cond_exec
> variants for all of the alternatives, even the ones that we don't want
> to cond_exec.
Well, that's not quite right. Internally, define_cond_exec works
pretty similar to define_subst. It can't be applied to one alternative
and not applied to another - it works on the entire pattern. What it
does to distinguish alternatives basing on 'predicable' attribute is
to properly set attribute 'ce_enabled'.

Here is a small example (you could try it yourself by invoking
genmddump which is located in build directory):
-EXAMPLE 1-
(define_attr "predicable" "no,yes" (const_string "no"))
(define_insn "aaa"
 [(set (match_operand:SI 0 "register_operand" "=r,m,x")
   (match_operand:SI 1 "register_operand" "r,m,x"))]
 ""
 "add %0 %1"
 [(set_attr "predicable" "yes,no,yes")])

(define_cond_exec
  [(match_operator 0 "arm_comparison_operator"
[(match_operand 1 "cc_register" "")
 (const_int 0)])]
  "TARGET_32BIT"
  "")
- END OF EXAMPLE 1-

And here is what the compiler has after expanding all patterns (it is
output of genmddump):
;; built-in: -1
(define_attr ("nonce_enabled") ("no,yes") (const_string ("yes")))
;; built-in: -1
(define_attr ("ce_enabled") ("no,yes") (const_string ("yes")))
;; a.md: 1
(define_attr ("predicable") ("no,yes") (const_string ("no")))
;; a.md: 3
(define_insn ("aaa")
 [ (set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
(match_operand:SI 1 ("register_operand") ("r,m,x")))
] ("") ("add %0 %1")
 [ (set_attr ("predicable") ("yes,no,yes")) ])

;; a.md: 3
(define_insn ("*p aaa")
 [ (cond_exec (match_operator 2 ("arm_comparison_operator")
 [(match_operand 3 ("cc_register") (""))
(const_int 0 [0]) ])
(set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
(match_operand:SI 1 ("register_operand") ("r,m,x"
] ("TARGET_32BIT") ("add %0 %1")
 [ (set_attr ("ce_enabled") ("yes,no,yes")) ])

As you might see, it doesn't distinguish alternatives at all - it just
fills 'ce_enabled' attribute with proper values.
Here is a second example, which is actually pretty similar to the
first one, but it's done with define_subst:
-EXAMPLE 2-
(define_subst_attr "at" "ce_subst" "yes" "no")

(define_insn "aaa"
 [(set (match_operand:SI 0 "register_operand" "=r,m,x")
   (match_operand:SI 1 "register_operand" "r,m,x"))]
 ""
 "add %0 %1"
 [(set_attr "ce_enabled" "yes,,yes")])

(define_subst "ce_subst"
 [(match_operand 0)]
  "TARGET_32BIT"
  [(cond_exec (match_operator 1 "arm_comparison_operator"
[(match_operand 2 "cc_register" "")
 (const_int 0)])
   (match_dup 0))])
-END OF EXAMPLE 2-

Here is what compiler has after expanding patterns:
;; c.md: 1
(define_attr ("ce_subst") ("no,yes")  (const_string ("no")))
;; c.md: 3
(define_insn ("aaa")
 [   (set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
(match_operand:SI 1 ("register_operand") ("r,m,x")))
] ("") ("add %0 %1")
 [   (set_attr ("ce_enabled") ("yes,yes,yes"))])

;; c.md: 3
(define_insn ("aaa")
 [(cond_exec (match_operator 2 ("arm_comparison_operator")
 [(match_operand 3 ("cc_register") (""))
(const_int 0 [0])])
(set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
(match_operand:SI 1 ("register_operand") ("r,m,x"
] ("TARGET_32BIT") ("add %0 %1")
 [(set_attr ("ce_enabled") ("yes,no,yes"))
  (set_attr ("ce_subst") ("no")) ])

You might notice that the output is almost the same (actually, all
differences could be eliminated except adding new attribute by subst
to substed-pattern). So currently I don't see why define_subst can't
by used instead of define_cond_exec in your case.

Hope these examples could help.

Thanks, Michael

On 24 May 2013 15:39, Kyrylo Tkachov  wrote:
>> > Unfortunately, that is a strong point against define_subst in my
>> case,
>> > since on arm we have more than 400 predicable patterns, of we
>> which we
>> > might want to modify dozens to perform this cond_exec
>> restriction.
>> > And creating custom subst-attributes for each one would really
>> make
>> > things hard to manage/maintain.
>> That's definitely a reason:)
>>
>> > With my proposed modification to define_cond_exec, if we want to
>> > restrict the cond_exec variant in the way I described, we only
>> add
>> > another set_attr to a pattern, without
>> > moving around their constraint strings.
>> >
>> > I'm not sure I see how define_subst could be modified to allow
>> for this
>> > functionality without impacting the current readability of the md
>> > patterns (not to mention the semantics of define_subst itself).
>>
>> Let me check my understanding of your s

Re: Fix PR 53743 and other -freorder-blocks-and-partition failures

2013-05-24 Thread Steven Bosscher
On Thu, May 23, 2013 at 5:35 PM, Jeff Law wrote:
> Thanks.  I wasn't aware of that wiki page.  I'll be reading it today :-)

The .odp attachment is actually a bit more informative, you should
take a look at that too, if you have the time.

Comments welcome, so I can include that in the new .texi version I'll
put together this weekend :-)

Ciao!
Steven


[gomp4] Initial support for accelerator support parsing

2013-05-24 Thread Jakub Jelinek
Hi!

This patch contains C++ parser changes etc. to handle
#pragma omp {teams,target {,data,update},distribute} parsing
all the way through till omp lowering (it bombs badly in omp expansion,
but already omp lowering will need to be tought out).
Things not handled yet are #pragma omp declare target/#pragma omp end
declare target (I assume we can handle it by automatically adding
"omp target" attribute to vars/functions in there) and there is no support
for array sections yet (also relevant for OMP_CLAUSE_DEPEND).

Say:

void baz (float *, float *, int);

float
foo (int x)
{
  float b[1024], c[1024], s = 0;
  int i;
  baz (b, c, x);
  #pragma omp target map(to: b, c)
#pragma omp parallel for reduction(+:s)
  for (i = 0; i < x; i++)
s += b[i] * c[i];
  return s;
}

float
bar (int x, int y, int z)
{
  float b[1024], c[1024], s = 0;
  int i, j;
  baz (b, c, x);
  #pragma omp target data map(to: b)
  {
#pragma omp target map(to: c)
  #pragma omp teams num_teams(y) num_threads(z) reduction(+:s)
#pragma omp distribute dist_schedule(static, 4) collapse(1)
  for (j=0; j < x; j += y)
#pragma omp parallel for reduction(+:s)
  for (i = j; i < j + y; i++)
s += b[i] * c[i];
#pragma omp target update from(b, c)
  }
  return s;
}

now parses with g++ -S -fopenmp -fdump-tree-all and shows dump up to
*.cfg (crash during ompexp).

Comments on this before I commit it to gomp-4_0-branch?

2013-05-24  Jakub Jelinek  

* tree.def (OMP_TEAMS, OMP_TARGET_DATA, OMP_TARGET,
OMP_TARGET_UPDATE): New tree codes.
* tree-cfg.c (make_edges): Handle GIMPLE_OMP_TARGET
and GIMPLE_OMP_TEAMS.
* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_DIST_SCHEDULE.
* gimple-low.c (lower_stmt): Handle GIMPLE_OMP_TARGET
and GIMPLE_OMP_TEAMS.
* tree.h (OMP_TEAMS_BODY, OMP_TEAMS_CLAUSES, OMP_TARGET_DATA_BODY,
OMP_TARGET_DATA_CLAUSES, OMP_TARGET_BODY, OMP_TARGET_CLAUSES,
OMP_TARGET_UPDATE_CLAUSES): Define.
* tree-nested.c (convert_nonlocal_reference_stmt,
convert_local_reference_stmt, convert_gimple_call): Handle
GIMPLE_OMP_TARGET and GIMPLE_OMP_TEAMS.
* tree-inline.c (estimate_num_insns): Likewise.
(remap_gimple_stmt): Likewise.  Adjust gimple_build_omp_for
caller.
* gimple.def: Adjust comments describing OMP_CLAUSEs.
(GIMPLE_OMP_TARGET, GIMPLE_OMP_TEAMS): New GIMPLE stmts.
* tree-parloops.c (create_parallel_loop): Adjust gimple_build_omp_for
caller.
* tree-pretty-print.c (dump_generic_node): Handle OMP_TEAMS,
OMP_TARGET, OMP_TARGET_DATA and OMP_TARGET_UPDATE.
* gimple.h (GF_OMP_TARGET_KIND_MASK, GF_OMP_TARGET_KIND_REGION,
GF_OMP_TARGET_KIND_DATA, GF_OMP_TARGET_KIND_UPDATE): New.
(gimple_build_omp_for): Add kind argument to prototype.
(gimple_build_omp_target, gimple_build_omp_teams): New prototypes.
(gimple_has_substatements): Handle GIMPLE_OMP_TARGET and
GIMPLE_OMP_TEAMS.
(gimple_omp_subcode): Change GIMPLE_OMP_SINGLE to GIMPLE_OMP_TEAMS.
(gimple_omp_target_clauses, gimple_omp_target_clauses_ptr,
gimple_omp_target_set_clauses, gimple_omp_target_kind,
gimple_omp_target_set_kind, gimple_omp_teams_clauses,
gimple_omp_teams_clauses_ptr, gimple_omp_teams_set_clauses): New
inline functions.
(gimple_return_set_retval): Handle GIMPLE_OMP_TARGET and
GIMPLE_OMP_TEAMS.
* gimple.c (gimple_build_omp_for): Add kind argument, call
gimple_omp_for_set_kind.
(gimple_build_omp_target, gimple_build_omp_teams): New functions.
(walk_gimple_op, walk_gimple_stmt, gimple_copy): Handle
GIMPLE_OMP_TARGET and GIMPLE_OMP_TEAMS.
* gimple-pretty-print.c (dump_gimple_omp_target,
dump_gimple_omp_teams): New functions.
(pp_gimple_stmt_1): Handle GIMPLE_OMP_TARGET and GIMPLE_OMP_TEAMS.
* gimplify.c (enum gimplify_omp_var_data): Add GOVD_MAP.
(enum omp_region_type): Add ORT_TEAMS, ORT_TARGET and ORT_TARGET_DATA.
(omp_add_variable): Add temporary assertions.
(omp_notice_threadprivate_variable): Complain if threadprivate vars
appear in target region.
(omp_notice_variable): ORT_TARGET, ORT_TARGET_DATA and ORT_TEAMS
handling.
(omp_check_private): Ignore ORT_TARGET and ORT_TARGET_DATA regions.
(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_MAP, OMP_CLAUSE_TO,
OMP_CLAUSE_FROM, OMP_CLAUSE_NUM_TEAMS, OMP_CLAUSE_DIST_SCHEDULE
and OMP_CLAUSE_DEVICE.
(gimplify_adjust_omp_clauses): Likewise.
(gimplify_adjust_omp_clauses_1): Handle GOVD_MAP.  Fix up
check for privatization by also testing for GOVD_LINEAR.
(gimplify_omp_for): Adjust gimple_build_omp_for caller.
Clear *expr_p.
(gimplify_omp_workshare): Handle also OMP_TARGET, OMP_T

Re: [PATCH] Fix PR57396

2013-05-24 Thread Zdenek Dvorak
Hi,

> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Zdenek, does this look ok?  double_int_constant_multiple_p seems to
> be only used from aff_combination_constant_multiple_p.

yes,

Zdenek


Re: C++ PATCH for c++/57388 (ICE with ref-qualifier)

2013-05-24 Thread Jakub Jelinek
On Thu, May 23, 2013 at 04:50:34PM -0400, Jason Merrill wrote:
> This is a simple oversight in the ref-qualifier code.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.  Jakub, is this OK for 4.8.1?

Ok, thanks.

> commit 0914d39b7335966f5d828c1b4225beb2e5448755
> Author: Jason Merrill 
> Date:   Thu May 23 14:01:27 2013 -0400
> 
>   PR c++/57388
>   * tree.c (build_ref_qualified_type): Clear
>   FUNCTION_RVALUE_QUALIFIED for lvalue ref-qualifier.

Jakub


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 11:00:26AM +0200, Rainer Orth wrote:
> Jakub Jelinek  writes:
> 
> > On Thu, May 23, 2013 at 11:54:05PM +0200, Rainer Orth wrote:
> >> > Agreed, that seems the best course of action if that's an option.
> >> 
> >> I just remembered that we aren't there yet even on mainline:
> >> 
> >> * This snippet
> >> 
> >>   http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01255.html
> >> 
> >>   is necessary to avoid bootstrap failure on Solaris 9.
> >> 
> >> * We'll need to link every C++ program with -lrt on Solaris, as
> >>   mentioned in the same message.  I suppose the best way to do this is
> >>   along the lines of libgfortran.spec, rather than duplicate the
> >>   necessary configury between g++ and libstdc++.  This might prove
> >>   pretty invasive for the testsuite, though, and delay the 4.8.1 release
> >>   quite a bit.
> >
> > Ugh, that makes =auto pretty much unbackportable, but it seems Solaris is
> > the only problematic OS here.  The goal of
> > _ZNSt6chrono12steady_clock3nowEv@@GLIBCXX_3.4.19
> > already in 4.8.1 was to allow Linux users (and with partial backport of
> > =auto not including Solaris perhaps also FreeBSD/NetBSD/OpenBSD) to let
> > users that get C++ core language feature completeness also use this
> > (Jonathan/Benjamin, is that right?).
> 
> It occured to me that there might be a far less intrusive option to still
> allow a Solaris backport: instead of going the libstdc++.spec route
> (which I still think is the correct way forward), statically handle -lrt
> addition in g++spec.c, controlled by a macro defined only in config/sol2.h.
> 
> Such a patch could be added to mainline and 4.8 branch now, and mainline
> later changed to use libstdc++.spec instead.

I think a switch from not linking libstdc++ against -lrt to linking against
that is quite heavy change for the branch.  Do you see why the latest patch
I've posted today wouldn't work well on Solaris?

Jakub


Re: Fix PR 53743 and other -freorder-blocks-and-partition failures

2013-05-24 Thread Jan Hubicka
> On Thu, May 23, 2013 at 5:35 PM, Jeff Law wrote:
> > Thanks.  I wasn't aware of that wiki page.  I'll be reading it today :-)
> 
> The .odp attachment is actually a bit more informative, you should
> take a look at that too, if you have the time.
> 
> Comments welcome, so I can include that in the new .texi version I'll
> put together this weekend :-)

Thanks for writting this down ;)

note that the CFG infrastructure also existed in reg-stack.c and flow.c, not 
only
in Haifa.  The original idea behind CFG code was to unify those implementations
into something more generally useful and one developed by Rth for liveness was
taken a as the winner to rule them all.

http://www.ucw.cz/~hubicka/papers/proj.pdf
has some more historical notes, too ;)
Honza
> 
> Ciao!
> Steven


Re: [PATCH] Do not allow non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs

2013-05-24 Thread Martin Jambor
Hi,

On Thu, May 23, 2013 at 11:38:10AM +0200, Richard Biener wrote:
> On Thu, 23 May 2013, Eric Botcazou wrote:
> 
> > > earlier this week I asked on IRC whether we could have non-top-level
> > > BIT_FIELD_REFs and Richi said that we could.  However, when I later
> > > looked at SRA code, quite apparently it is not designed to handle
> > > non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs.  So in
> > > order to test whether that assumption is OK, I added the following
> > > into the gimple verifier and ran bootstrap and testsuite of all
> > > languages including Ada and ObjC++ on x86_64.  It survived, which
> > > makes me wondering whether we do not want it in trunk.
> > 
> > This looks plausible to me, but I think that you ought to verify the real 
> > assumption instead, which is that the type of the 3 nodes is always scalar.
> > The non-toplevelness of the nodes is merely a consequence of this property.
> 
> Yeah.  But please put the verification into tree-cfg.c:verify_expr
> instead.
> 

Like this?  Also bootstrapped and tested on x86_64-linux.

Thanks,

Martin


2013-05-23  Martin Jambor  

* tree-cfg.c (verify_expr): Verify that BIT_FIELD_REFs, IMAGPART_EXPRs
and REALPART_EXPRs have scalar type.

Index: src/gcc/tree-cfg.c
===
--- src.orig/gcc/tree-cfg.c
+++ src/gcc/tree-cfg.c
@@ -2669,10 +2669,17 @@ verify_expr (tree *tp, int *walk_subtree
 
 case REALPART_EXPR:
 case IMAGPART_EXPR:
+case BIT_FIELD_REF:
+  if (!is_gimple_reg_type (TREE_TYPE (t)))
+   {
+ error ("non-scalar BIT_FIELD_REF, IMAGPART_EXPR or REALPART_EXPR");
+ return t;
+   }
+
+  /* Fall-through.  */
 case COMPONENT_REF:
 case ARRAY_REF:
 case ARRAY_RANGE_REF:
-case BIT_FIELD_REF:
 case VIEW_CONVERT_EXPR:
   /* We have a nest of references.  Verify that each of the operands
 that determine where to reference is either a constant or a variable,
 


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Rainer Orth
Jakub Jelinek  writes:

>> It occured to me that there might be a far less intrusive option to still
>> allow a Solaris backport: instead of going the libstdc++.spec route
>> (which I still think is the correct way forward), statically handle -lrt
>> addition in g++spec.c, controlled by a macro defined only in config/sol2.h.
>> 
>> Such a patch could be added to mainline and 4.8 branch now, and mainline
>> later changed to use libstdc++.spec instead.
>
> I think a switch from not linking libstdc++ against -lrt to linking against
> that is quite heavy change for the branch.  Do you see why the latest patch

I'm not so sure: to me, that's just an implementation detail.

> I've posted today wouldn't work well on Solaris?

It should work on the 4.8 branch (I'll include it in my bootstraps this
weekend), but on mainline the failures due to missing nanosleep/-lrt
will remain.

I've just successfully bootstrapped the following patch on
i386-pc-solaris2.10 and x86_64-unknown-linux-gnu.  It fixes the
libstdc++ testsuite failures I'd reported before.

Rainer


2013-05-24  Rainer Orth  

gcc/cp:
* g++spec.c (TIMELIB): Define.
(WITHLIBC, SKIPOPT): Adjust values.
(lang_specific_driver): Add TIME_LIBRARY if not passed explicitly.

gcc:
* config/sol2.h (TIME_LIBRARY): Define.

# HG changeset patch
# Parent d6881ec042d3a6328b763cbf0f38e61bdbb64d79
Add -lrt on Solaris

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -194,6 +194,9 @@ along with GCC; see the file COPYING3.  
 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
 #endif
 
+/* C++11 programs need -lrt for nanosleep.  */
+#define TIME_LIBRARY "rt"
+
 #ifndef USE_GLD
 /* The default MFLIB_SPEC is GNU ld specific.  */
 #define MFLIB_SPEC ""
diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
--- a/gcc/cp/g++spec.c
+++ b/gcc/cp/g++spec.c
@@ -28,10 +28,12 @@ along with GCC; see the file COPYING3.  
 #define LANGSPEC	(1<<1)
 /* This bit is set if they did `-lm' or `-lmath'.  */
 #define MATHLIB		(1<<2)
+/* This bit is set if they did `-lrt' or equivalent.  */
+#define TIMELIB		(1<<3)
 /* This bit is set if they did `-lc'.  */
-#define WITHLIBC	(1<<3)
+#define WITHLIBC	(1<<4)
 /* Skip this option.  */
-#define SKIPOPT		(1<<4)
+#define SKIPOPT		(1<<5)
 
 #ifndef MATH_LIBRARY
 #define MATH_LIBRARY "m"
@@ -40,6 +42,10 @@ along with GCC; see the file COPYING3.  
 #define MATH_LIBRARY_PROFILE MATH_LIBRARY
 #endif
 
+#ifndef TIME_LIBRARY
+#define TIME_LIBRARY ""
+#endif
+
 #ifndef LIBSTDCXX
 #define LIBSTDCXX "stdc++"
 #endif
@@ -83,16 +89,22 @@ lang_specific_driver (struct cl_decoded_
   /* "-lm" or "-lmath" if it appears on the command line.  */
   const struct cl_decoded_option *saw_math = NULL;
 
+  /* "-lrt" or eqivalent if it appears on the command line.  */
+  const struct cl_decoded_option *saw_time = NULL;
+
   /* "-lc" if it appears on the command line.  */
   const struct cl_decoded_option *saw_libc = NULL;
 
   /* An array used to flag each argument that needs a bit set for
- LANGSPEC, MATHLIB, or WITHLIBC.  */
+ LANGSPEC, MATHLIB, TIMELIB, or WITHLIBC.  */
   int *args;
 
   /* By default, we throw on the math library if we have one.  */
   int need_math = (MATH_LIBRARY[0] != '\0');
 
+  /* By default, we throw on the time library if we have one.  */
+  int need_time = (TIME_LIBRARY[0] != '\0');
+
   /* True if we saw -static.  */
   int static_link = 0;
 
@@ -136,6 +148,11 @@ lang_specific_driver (struct cl_decoded_
 	  args[i] |= MATHLIB;
 	  need_math = 0;
 	}
+	  else if (strcmp (arg, TIME_LIBRARY) == 0)
+	{
+	  args[i] |= TIMELIB;
+	  need_time = 0;
+	}
 	  else if (strcmp (arg, "c") == 0)
 	args[i] |= WITHLIBC;
 	  else
@@ -268,6 +285,12 @@ lang_specific_driver (struct cl_decoded_
 	  saw_math = &decoded_options[i];
 	}
 
+  if (!saw_time && (args[i] & TIMELIB) && library > 0)
+	{
+	  --j;
+	  saw_time = &decoded_options[i];
+	}
+
   if (!saw_libc && (args[i] & WITHLIBC) && library > 0)
 	{
 	  --j;
@@ -352,6 +375,15 @@ lang_specific_driver (struct cl_decoded_
   added_libraries++;
   j++;
 }
+  if (saw_time)
+new_decoded_options[j++] = *saw_time;
+  else if (library > 0 && need_time)
+{
+  generate_option (OPT_l, TIME_LIBRARY, 1, CL_DRIVER,
+		   &new_decoded_options[j]);
+  added_libraries++;
+  j++;
+}
   if (saw_libc)
 new_decoded_options[j++] = *saw_libc;
   if (shared_libgcc && !static_link)

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [C++ Patch] PR 19618

2013-05-24 Thread Jason Merrill
Why would we want to pedwarn?  As far as I can tell, the standard 
doesn't say this is ill-formed.  9.6 says,


"The value of the integral constant expression may be larger than the 
number of bits in the object representation (3.9) of the bit-field’s 
type; in such cases the extra bits are used as padding bits and do not 
participate in the value representation (3.9) of the bit-field."


and

"A bool value can successfully be stored in a bit-field of any nonzero 
size."


I'm sure that lots of users would complain about the compiler starting 
to reject bool bitfields of 2-8 bits.


I'm not opposed to warning about excessive size for bool and enum here, 
but the warning should be based on TYPE_SIZE rather than TYPE_PRECISION.


Jason



Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 03:35:15PM +0200, Rainer Orth wrote:
> > I've posted today wouldn't work well on Solaris?
> 
> It should work on the 4.8 branch (I'll include it in my bootstraps this
> weekend), but on mainline the failures due to missing nanosleep/-lrt
> will remain.

Thanks.  Please make sure to use
http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01456.html
rather than the earlier broken patch.

Yeah, the patch isn't meant to fix the pre-existing issues on the trunk
on Solaris, it is just about the ABI thing plus enablement to do the
real thing on Linux using syscall function; but, with the ABI change
either the =auto changes for Solaris can be safely reverted, or
your patch applied, whatever else.

Note that for 4.8.1 this is kind of urgent, because it is blocking 4.8.1-rc2
and thus also 4.8.1 release, so the sooner this gets resolved, the better.

Jonathan/Benjamin, could you please review the patch in the mean time,
so that if it works well for Rainer, it can be applied immediately and
4.8.1-rc2 rolled, even during the weekend?

Jakub


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Rainer Orth
Jakub Jelinek  writes:

> On Fri, May 24, 2013 at 03:35:15PM +0200, Rainer Orth wrote:
>> > I've posted today wouldn't work well on Solaris?
>> 
>> It should work on the 4.8 branch (I'll include it in my bootstraps this
>> weekend), but on mainline the failures due to missing nanosleep/-lrt
>> will remain.
>
> Thanks.  Please make sure to use
> http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01456.html
> rather than the earlier broken patch.

Yep, I'd seen that.

> Yeah, the patch isn't meant to fix the pre-existing issues on the trunk
> on Solaris, it is just about the ABI thing plus enablement to do the
> real thing on Linux using syscall function; but, with the ABI change
> either the =auto changes for Solaris can be safely reverted, or
> your patch applied, whatever else.
>
> Note that for 4.8.1 this is kind of urgent, because it is blocking 4.8.1-rc2
> and thus also 4.8.1 release, so the sooner this gets resolved, the better.

I've now fired off the various Solaris bootstraps.  It may take until
tomorrow that I can report final results.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jonathan Wakely
On 24 May 2013 14:40, Jakub Jelinek wrote:
>
> Note that for 4.8.1 this is kind of urgent, because it is blocking 4.8.1-rc2
> and thus also 4.8.1 release, so the sooner this gets resolved, the better.

Sorry about that, I didn't realise the trunk change would affect 4.8.1

> Jonathan/Benjamin, could you please review the patch in the mean time,
> so that if it works well for Rainer, it can be applied immediately and
> 4.8.1-rc2 rolled, even during the weekend?


In the fallback for steady_clock::now() would it be easier to just
call system_clock::now() instead of duplicating its logic?

i.e .replace:

+#elif defined(_GLIBCXX_USE_CLOCK_REALTIME)
+  timespec tp;
+  // -EINVAL, -EFAULT
+  clock_gettime(CLOCK_REALTIME, &tp);
+  return time_point(duration(chrono::seconds(tp.tv_sec)
+ + chrono::nanoseconds(tp.tv_nsec)));
+#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
+  timeval tv;
+  // EINVAL, EFAULT
+  gettimeofday(&tv, 0);
+  return time_point(duration(chrono::seconds(tv.tv_sec)
+ + chrono::microseconds(tv.tv_usec)));
+#else
+  std::time_t __sec = std::time(0);
+  return system_clock::from_time_t(__sec);
 #endif

with

#else
return system_clock::now();
#endif

I'm also wondering if

+  AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL, 1,
+  [ Defined if clock_gettime syscall has monotonic clock support. ])

should be renamed to _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL because it is
defined when the syscall has CLOCK_REALTIME and clock_MONOTONIC
support.

Otherwise the patch is OK.


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 02:56:24PM +0100, Jonathan Wakely wrote:
> > Jonathan/Benjamin, could you please review the patch in the mean time,
> > so that if it works well for Rainer, it can be applied immediately and
> > 4.8.1-rc2 rolled, even during the weekend?
> 
> 
> In the fallback for steady_clock::now() would it be easier to just
> call system_clock::now() instead of duplicating its logic?

Yeah, that is what I've tried in
http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01440.html
but it failed horribly, because the return type from both the static methods
is different (system_clock::time_point (aka chrono::time_point) in the first case,
steady_clock::time_point (aka chrono::time_point)
in the latter).  And there is no conversion in between the two.

Perhaps I'd have to do something like:
  return time_point(system_clock::now().time_since_epoch());
?  Can try that.

> I'm also wondering if
> 
> +  AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC_SYSCALL, 1,
> +  [ Defined if clock_gettime syscall has monotonic clock support. ])
> 
> should be renamed to _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL because it is
> defined when the syscall has CLOCK_REALTIME and clock_MONOTONIC
> support.

Yeah, that is a good suggestion, will change it.

Jakub


Re: Use unsigned(-1) for lshift

2013-05-24 Thread Marc Glisse

On Fri, 24 May 2013, Jakub Jelinek wrote:


On Fri, May 24, 2013 at 10:15:29AM +0200, Richard Biener wrote:

On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:

Hello,

this is a simple patch to reduce a bit the noise in PR57324 (undefined
behavior flagged by clang). I only handled some of the most obvious ones.
Passes bootstrap+testsuite on x86_64-linux-gnu.


Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
and nonnegative
value, and E1 * 2^E2 is representable in the result type, then that is the
resulting value; otherwise, the behavior is undefined."

While seriously underspecified for signed negative values (always undefined?!
or well-defined?!), I wonder why CLang requires


By strict reading of the standard, left shift of negative signed value by
any amount is undefined behavior in ISO C99 (no idea if it hasn't been
changed later on, Joseph?).
In C++98, in [expr.shift] it doesn't seem to mention E1 << E2 where E1 has
signed type at all, the is implementation defined sentence only in the
second paragraph, so one would expect that it applies to >> only.
C++11 [expr.shift] already has the wording of C99 (thus making it undefined
behavior?).

BTW, we have HOST_WIDE_INT_1 and HOST_WIDE_INT_C(X) macros, don't we want
also HOST_WIDE_INT_m1 for HOST_WIDE_INT_C(-1) and HOST_WIDE_INT_UC(X)
for HOST_WIDE_INT_C(X##U) (or whatever works for __int64) and
HOST_WIDE_INT_1U, HOST_WIDE_INT_m1U ?  It would be more compact and could
make code more readable.


Something like this?
It passed bootstrap on x86_64-linux-gnu, the testsuite is running. As
far as a google search tells me, Ui64 should be ok as a suffix, but I
haven't tested it.

2013-05-24  Marc Glisse  

PR other/57324
* hwint.h (HOST_WIDE_INT_UC, HOST_WIDE_INT_1U, HOST_WIDE_INT_M1,
HOST_WIDE_INT_M1U): New macros.
* fold-const.c (sign_bit_p, build_range_check, fold_unary_loc,
fold_binary_loc, fold_ternary_loc): Use the new macros. Use an
unsigned -1 for lshift.
* cse.c (cse_insn): Likewise.
* double-int.c (rshift_double, lshift_double): Likewise.
* builtins.c (fold_builtin_bitop): Likewise.
* combine.c (force_to_mode): Likewise.
* tree.c (integer_pow2p, tree_log2, tree_floor_log2): Likewise.
* simplify-rtx.c (simplify_const_unary_operation,
simplify_const_binary_operation): Likewise.
* tree-stdarg.c (reachable_at_most_once, va_list_counter_bump,
va_list_ptr_read, check_va_list_escapes): Likewise.
* rtlanal.c (nonzero_bits1): Likewise.
* expmed.c (expand_smod_pow2): Likewise.
* tree-ssa-structalias.c (UNKNOWN_OFFSET): Shift 1 instead of -1.

--
Marc GlisseIndex: builtins.c
===
--- builtins.c  (revision 199289)
+++ builtins.c  (working copy)
@@ -8089,28 +8089,27 @@ fold_builtin_bitop (tree fndecl, tree ar
 
   type = TREE_TYPE (arg);
   width = TYPE_PRECISION (type);
   lo = TREE_INT_CST_LOW (arg);
 
   /* Clear all the bits that are beyond the type's precision.  */
   if (width > HOST_BITS_PER_WIDE_INT)
{
  hi = TREE_INT_CST_HIGH (arg);
  if (width < HOST_BITS_PER_DOUBLE_INT)
-   hi &= ~((unsigned HOST_WIDE_INT) (-1)
-   << (width - HOST_BITS_PER_WIDE_INT));
+   hi &= ~(HOST_WIDE_INT_M1U << (width - HOST_BITS_PER_WIDE_INT));
}
   else
{
  hi = 0;
  if (width < HOST_BITS_PER_WIDE_INT)
-   lo &= ~((unsigned HOST_WIDE_INT) (-1) << width);
+   lo &= ~(HOST_WIDE_INT_M1U << width);
}
 
   switch (DECL_FUNCTION_CODE (fndecl))
{
CASE_INT_FN (BUILT_IN_FFS):
  if (lo != 0)
result = ffs_hwi (lo);
  else if (hi != 0)
result = HOST_BITS_PER_WIDE_INT + ffs_hwi (hi);
  else
@@ -8133,27 +8132,27 @@ fold_builtin_bitop (tree fndecl, tree ar
result = HOST_BITS_PER_WIDE_INT + ctz_hwi (hi);
  else if (! CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), result))
result = width;
  break;
 
CASE_INT_FN (BUILT_IN_CLRSB):
  if (width > HOST_BITS_PER_WIDE_INT
  && (hi & ((unsigned HOST_WIDE_INT) 1
<< (width - HOST_BITS_PER_WIDE_INT - 1))) != 0)
{
- hi = ~hi & ~((unsigned HOST_WIDE_INT) (-1)
+ hi = ~hi & ~(HOST_WIDE_INT_M1U
   << (width - HOST_BITS_PER_WIDE_INT - 1));
  lo = ~lo;
}
  else if (width <= HOST_BITS_PER_WIDE_INT
   && (lo & ((unsigned HOST_WIDE_INT) 1 << (width - 1))) != 0)
-   lo = ~lo & ~((unsigned HOST_WIDE_INT) (-1) << (width - 1));
+   lo = ~lo & ~(HOST_WIDE_INT_M1U << (width - 1));
  if (hi != 0)
result = width - floor_log2 (hi) - 2 - HOST_BITS_PER_WIDE_INT;
  else if (lo != 0)
result = width - flo

Re: C++ PATCH for c++/56930 (wrong -Wconversion warning with sizeof)

2013-05-24 Thread Jason Merrill

On 05/24/2013 01:53 AM, David Edelsohn wrote:

Also, you are not updating testsuite/ChangeLog.


http://gcc.gnu.org/codingconventions.html#ChangeLogs says "There is no 
established convention on when ChangeLog entries are to be made for 
testsuite changes."


I prefer not to mess with testsuite/ChangeLog for testcasess.

Jason



Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jonathan Wakely
On 24 May 2013 15:07, Jakub Jelinek  wrote:
> On Fri, May 24, 2013 at 02:56:24PM +0100, Jonathan Wakely wrote:
>> > Jonathan/Benjamin, could you please review the patch in the mean time,
>> > so that if it works well for Rainer, it can be applied immediately and
>> > 4.8.1-rc2 rolled, even during the weekend?
>>
>>
>> In the fallback for steady_clock::now() would it be easier to just
>> call system_clock::now() instead of duplicating its logic?
>
> Yeah, that is what I've tried in
> http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01440.html
> but it failed horribly, because the return type from both the static methods
> is different (system_clock::time_point (aka chrono::time_point duration>) in the first case,
> steady_clock::time_point (aka chrono::time_point)
> in the latter).  And there is no conversion in between the two.

Ah of course, sorry.

> Perhaps I'd have to do something like:
>   return time_point(system_clock::now().time_since_epoch());
> ?  Can try that.

Yes, they share the same epoch so that should work.


C++ PATCH for c++/57391 (bootstrap fail on AIX)

2013-05-24 Thread Jason Merrill
When FMA_EXPR was added to potential_constant_expression_1, it wasn't 
added to cxx_eval_constant_expression at the same time...


Regression tested x86_64-pc-linux-gnu, applying to trunk.  David, can 
you verify that this fixes bootstrap on AIX?
commit a78fee4d0a9c2a353637f239c6ac189227248491
Author: Jason Merrill 
Date:   Fri May 24 09:52:10 2013 -0400

	PR c++/57391
	* semantics.c (cxx_eval_constant_expression): Handle FMA_EXPR.
	(cxx_eval_trinary_expression): Rename from cxx_eval_vec_perm_expr.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c115d23..c1385c1 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7776,37 +7776,32 @@ non_const_var_error (tree r)
 }
 }
 
-/* Evaluate VEC_PERM_EXPR (v1, v2, mask).  */
+/* Subroutine of cxx_eval_constant_expression.
+   Like cxx_eval_unary_expression, except for trinary expressions.  */
+
 static tree
-cxx_eval_vec_perm_expr (const constexpr_call *call, tree t, 
-			bool allow_non_constant, bool addr,
-			bool *non_constant_p, bool *overflow_p)
+cxx_eval_trinary_expression (const constexpr_call *call, tree t,
+			 bool allow_non_constant, bool addr,
+			 bool *non_constant_p, bool *overflow_p)
 {
   int i;
   tree args[3];
   tree val;
-  tree elttype = TREE_TYPE (t);
 
   for (i = 0; i < 3; i++)
 {
   args[i] = cxx_eval_constant_expression (call, TREE_OPERAND (t, i),
 	  allow_non_constant, addr,
 	  non_constant_p, overflow_p);
-  if (*non_constant_p)
-  	goto fail;
+  VERIFY_CONSTANT (args[i]);
 }
 
-  gcc_assert (TREE_CODE (TREE_TYPE (args[0])) == VECTOR_TYPE);
-  gcc_assert (TREE_CODE (TREE_TYPE (args[1])) == VECTOR_TYPE);
-  gcc_assert (TREE_CODE (TREE_TYPE (args[2])) == VECTOR_TYPE);
-
-  val = fold_ternary_loc (EXPR_LOCATION (t), VEC_PERM_EXPR, elttype, 
+  val = fold_ternary_loc (EXPR_LOCATION (t), TREE_CODE (t), TREE_TYPE (t),
 			  args[0], args[1], args[2]);
-  if (val != NULL_TREE)
-return val;
-
- fail:
-  return t;
+  if (val == NULL_TREE)
+return t;
+  VERIFY_CONSTANT (val);
+  return val;
 }
 
 /* Attempt to reduce the expression T to a constant value.
@@ -8106,9 +8101,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
 			 non_constant_p, overflow_p);
   break;
 
+case FMA_EXPR:
 case VEC_PERM_EXPR:
-  r = cxx_eval_vec_perm_expr (call, t, allow_non_constant, addr,
-  non_constant_p, overflow_p);
+  r = cxx_eval_trinary_expression (call, t, allow_non_constant, addr,
+   non_constant_p, overflow_p);
   break;
 
 case CONVERT_EXPR:


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 04:07:48PM +0200, Jakub Jelinek wrote:
> On Fri, May 24, 2013 at 02:56:24PM +0100, Jonathan Wakely wrote:
> > > Jonathan/Benjamin, could you please review the patch in the mean time,
> > > so that if it works well for Rainer, it can be applied immediately and
> > > 4.8.1-rc2 rolled, even during the weekend?
> > 
> > 
> > In the fallback for steady_clock::now() would it be easier to just
> > call system_clock::now() instead of duplicating its logic?
> 
> Yeah, that is what I've tried in
> http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01440.html
> but it failed horribly, because the return type from both the static methods
> is different (system_clock::time_point (aka chrono::time_point duration>) in the first case,
> steady_clock::time_point (aka chrono::time_point)
> in the latter).  And there is no conversion in between the two.
> 
> Perhaps I'd have to do something like:
>   return time_point(system_clock::now().time_since_epoch());
> ?  Can try that.

Ah, but the duration can be different depending on macros.

Jakub


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jonathan Wakely
On 24 May 2013 15:16, Jakub Jelinek  wrote:
> On Fri, May 24, 2013 at 04:07:48PM +0200, Jakub Jelinek wrote:
>> On Fri, May 24, 2013 at 02:56:24PM +0100, Jonathan Wakely wrote:
>> > > Jonathan/Benjamin, could you please review the patch in the mean time,
>> > > so that if it works well for Rainer, it can be applied immediately and
>> > > 4.8.1-rc2 rolled, even during the weekend?
>> >
>> >
>> > In the fallback for steady_clock::now() would it be easier to just
>> > call system_clock::now() instead of duplicating its logic?
>>
>> Yeah, that is what I've tried in
>> http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01440.html
>> but it failed horribly, because the return type from both the static methods
>> is different (system_clock::time_point (aka chrono::time_point> duration>) in the first case,
>> steady_clock::time_point (aka chrono::time_point)
>> in the latter).  And there is no conversion in between the two.
>>
>> Perhaps I'd have to do something like:
>>   return time_point(system_clock::now().time_since_epoch());
>> ?  Can try that.
>
> Ah, but the duration can be different depending on macros.

You can convert between durations: with duration_cast:

return 
time_point(duration_cast(system_clock::now().time_since_epoch()));


Re: [C++ Patch] PR 19618

2013-05-24 Thread Paolo Carlini

Hi,

On 05/24/2013 03:36 PM, Jason Merrill wrote:
Why would we want to pedwarn?  As far as I can tell, the standard 
doesn't say this is ill-formed.  9.6 says,


"The value of the integral constant expression may be larger than the 
number of bits in the object representation (3.9) of the bit-field’s 
type; in such cases the extra bits are used as padding bits and do not 
participate in the value representation (3.9) of the bit-field."


and

"A bool value can successfully be stored in a bit-field of any nonzero 
size."


I'm sure that lots of users would complain about the compiler starting 
to reject bool bitfields of 2-8 bits.
Thanks Jason. Shame on me, I was totally confused, I guess I need some 
time off (*).
I'm not opposed to warning about excessive size for bool and enum 
here, but the warning should be based on TYPE_SIZE rather than 
TYPE_PRECISION.

Makes perfect sense. Thus I'm finishing testing the below. Better?

Thanks again,
Paolo.

(*) For real, next week vacations for me.


Index: cp/class.c
===
--- cp/class.c  (revision 199287)
+++ cp/class.c  (working copy)
@@ -3140,9 +3140,14 @@ check_bitfield_decl (tree field)
  error ("zero width for bit-field %q+D", field);
  w = error_mark_node;
}
-  else if (compare_tree_int (w, TYPE_PRECISION (type)) > 0
-  && TREE_CODE (type) != ENUMERAL_TYPE
-  && TREE_CODE (type) != BOOLEAN_TYPE)
+  else if ((TREE_CODE (type) != ENUMERAL_TYPE
+   && TREE_CODE (type) != BOOLEAN_TYPE
+   && compare_tree_int (w, TYPE_PRECISION (type)) > 0)
+  || ((TREE_CODE (type) == ENUMERAL_TYPE
+   && (tree_int_cst_lt
+   (TYPE_SIZE (ENUM_UNDERLYING_TYPE (type)), w)))
+  || (TREE_CODE (type) == BOOLEAN_TYPE
+  && tree_int_cst_lt (TYPE_SIZE (type), w
warning (0, "width of %q+D exceeds its type", field);
   else if (TREE_CODE (type) == ENUMERAL_TYPE
   && (0 > (compare_tree_int
Index: testsuite/g++.dg/expr/bitfield12.C
===
--- testsuite/g++.dg/expr/bitfield12.C  (revision 0)
+++ testsuite/g++.dg/expr/bitfield12.C  (working copy)
@@ -0,0 +1,19 @@
+// PR c++/19618
+
+struct bset1 {
+  bool bit : sizeof(bool) * __CHAR_BIT__ + 1;  // { dg-warning "exceeds" }
+};
+
+enum E {};
+
+struct bset2 {
+  E bit : sizeof(__underlying_type(E)) * __CHAR_BIT__ + 1; // { dg-warning 
"exceeds" }
+};
+
+struct bset3 {
+  bool bit : sizeof(bool) * __CHAR_BIT__;
+};
+
+struct bset4 {
+  E bit : sizeof(__underlying_type(E)) * __CHAR_BIT__;
+};


Re: C++ PATCH for c++/57391 (bootstrap fail on AIX)

2013-05-24 Thread Paolo Carlini

On 05/24/2013 04:16 PM, Jason Merrill wrote:
When FMA_EXPR was added to potential_constant_expression_1, it wasn't 
added to cxx_eval_constant_expression at the same time...

Sorry.

Paolo.


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 03:29:43PM +0100, Jonathan Wakely wrote:
> >> in the latter).  And there is no conversion in between the two.
> >>
> >> Perhaps I'd have to do something like:
> >>   return time_point(system_clock::now().time_since_epoch());
> >> ?  Can try that.
> >
> > Ah, but the duration can be different depending on macros.
> 
> You can convert between durations: with duration_cast:
> 
> return 
> time_point(duration_cast(system_clock::now().time_since_epoch()));

Actually return time_point(system_clock::now().time_since_epoch());
seems to work too, there is a ctor for that:
template::value
 || (ratio_divide<_Period2, period>::den == 1
 && !treat_as_floating_point<_Rep2>::value)>::type>
  constexpr duration(const duration<_Rep2, _Period2>& __d)
  : __r(duration_cast(__d).count()) { }
I've tried a configuration where system_clock::now() used gettimeofday
and system_clock duration was in microseconds and steady_clock was
the non-steady one, but with nanoseconds resolution, and system_clock::now()
then contains
callgettimeofday
movq(%rsp), %rax
imulq   $100, %rax, %rax
addq8(%rsp), %rax
(100 * tv.tv_sec + tv.tv_usec) and steady_clock::now()
call_ZNSt6chrono12system_clock3nowEv
imulq   $1000, %rax, %rax
so it converts correctly.

So, adjusted patches attached, ok for trunk/4.8 if they pass
bootstrap/regtest?  Guess Rainer will need to on top of that adjust
Solaris baseline_symbols.txt files.

Jakub
2013-05-24  Jakub Jelinek  

* src/c++11/chrono.cc: If _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL,
include unistd.h and sys/syscall.h.  If _GLIBCXX_COMPATIBILITY_CXX0X,
don't define system_clock::is_steady, system_clock::now() and
steady_clock::is_steady.
(std::chrono::system_clock::now()): If
_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, call
syscall (SYS_clock_gettime, ...) instead of clock_gettime (...).
(std::chrono::system_clock::now()): Likewise.  Add weak attribute
if _GLIBCXX_COMPATIBILITY_CXX0X and compatibility-chrono.cc will
be non-empty.
* src/Makefile.am (cxx11_sources): Add compatibility-chrono.cc.
(compatibility-chrono.lo, compatibility-chrono.o): New goals.
* src/c++11/compatibility-chrono.cc: New file.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_TIME): On linux*, check for
syscall (SYS_clock_gettime, CLOCK_MONOTONIC, &tp).
* testsuite/util/testsuite_abi.cc (check_version): Add
GLIBCXX_3.4.20 version and make it the latest.
* config/abi/pre/gnu.ver (_ZNSt6chrono12steady_clock3nowEv): Export
also @@GLIBCXX_3.4.19.  Move all symbols so far added for GCC 4.9 to
@@GLIBCXX_3.4.20 instead.
* config/abi/post/i386-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt:
Regenerated.
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/s390-linux-gnu/baseline_symbols.txt: Regenerated.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Regenerated.
* config.h.in: Regenerated.
* src/Makefile.in: Regenerated.
* configure: Regenerated.

--- libstdc++-v3/src/c++11/chrono.cc.jj 2013-02-04 18:15:15.078395533 +0100
+++ libstdc++-v3/src/c++11/chrono.cc2013-05-23 18:06:40.562825017 +0200
@@ -22,7 +22,20 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
+#include 
+
+#ifndef _GLIBCXX_USE_CLOCK_MONOTONIC
+// If !_GLIBCXX_USE_CLOCK_MONOTONIC, std::chrono::steady_clock
+// is just a typedef to std::chrono::system_clock, for ABI compatibility
+// force it not to be a typedef now and export it anyway.  Programs
+// using the headers where it is a typedef will actually just use
+// std::chrono::system_clock instead, and this remains here just as a fallback.
+#define _GLIBCXX_USE_CLOCK_MONOTONIC
+#include 
+#undef _GLIBCXX_USE_CLOCK_MONOTONIC
+#else
 #include 
+#endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 
@@ -32,13 +45,18 @@
  defined(_GLIBCXX_USE_GETTIMEOFDAY)
 #include 
 #endif
+#ifdef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL
+#include 
+#include 
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   namespace chrono
   {
   _GLIBCXX_BEGIN_NAMESPACE_VERSION
- 
+
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
 constexpr bool system_clock::is_steady;
 
 system_clock::time_point
@@ -47,7 +65,11 @@ namespace std _GLIBCXX_VISIBILITY(defaul
 #ifdef _GLIBCXX_USE_CLOCK_REA

Re: [PATCH] Do not allow non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs

2013-05-24 Thread Eric Botcazou
> 2013-05-23  Martin Jambor  
> 
>   * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REFs, IMAGPART_EXPRs
>   and REALPART_EXPRs have scalar type.

I cannot formally approve, but this looks the right test to me.

-- 
Eric Botcazou


Re: Use unsigned(-1) for lshift

2013-05-24 Thread Joseph S. Myers
On Fri, 24 May 2013, Richard Biener wrote:

> On Thu, May 23, 2013 at 9:47 PM, Marc Glisse  wrote:
> > Hello,
> >
> > this is a simple patch to reduce a bit the noise in PR57324 (undefined
> > behavior flagged by clang). I only handled some of the most obvious ones.
> > Passes bootstrap+testsuite on x86_64-linux-gnu.
> 
> Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
> and nonnegative
> value, and E1 * 2^E2 is representable in the result type, then that is the
> resulting value; otherwise, the behavior is undefined."
> 
> While seriously underspecified for signed negative values (always undefined?!
> or well-defined?!), I wonder why CLang requires

Always undefined for signed negative values (compared to the 
implementation-defined of C90; DR#081).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Rainer Orth
Jakub Jelinek  writes:

> So, adjusted patches attached, ok for trunk/4.8 if they pass
> bootstrap/regtest?  Guess Rainer will need to on top of that adjust
> Solaris baseline_symbols.txt files.

I meant to look into that, but usually I only update the baselines for
x.y.0 releases, not micro releases.  The addition of GLIBCXX_3.4.19
might justify an exception, though.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] Do not allow non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 05:05:52PM +0200, Eric Botcazou wrote:
> > 2013-05-23  Martin Jambor  
> > 
> > * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REFs, IMAGPART_EXPRs
> > and REALPART_EXPRs have scalar type.
> 
> I cannot formally approve, but this looks the right test to me.

I agree it is desirable, but is it enough to ensure that they will be only
toplevel?  Can't you e.g. do a VIEW_CONVERT_EXPR from an integer type or
floating/vector type etc. to struct type, then the verifier wouldn't
discover there is VIEW_CONVERT_EXPR >?

Jakub


[PATCH, PR 57294] Update symbol table references in IPA-SRA

2013-05-24 Thread Martin Jambor
Hi,

when modifying an indirectly recursively called function, IPA-SRA may
remove a statement for which we have already gathered references in
the symbol table and replace it with new statement(s), making the
symbol table information stale which can lead to problems like PR
57294.

The patch below adds a function to remove references relating to a
particular statement and another one to allow callers from outside of
cgraphbuild.c record references in a particular statement, allowing
the argument modification function to update them accordingly.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2013-05-24  Martin Jambor  

* cgraph.h (ipa_record_stmt_references): Declare.
* cgraphbuild.c (ipa_record_stmt_references): New function.
(build_cgraph_edges): Use ipa_record_stmt_references.
(rebuild_cgraph_edges): Likewise.
(cgraph_rebuild_references): Likewise.
* ipa-prop.c (ipa_modify_call_arguments): Discard references
associated with the old statement and build references from the
newly built statements.
* ipa-ref.c (ipa_remove_stmt_references): New function.
* ipa-ref.h (ipa_remove_stmt_references): Declare.

testsuite/
* gcc.dg/ipa/pr57294.c: New test.

Index: src/gcc/cgraph.h
===
--- src.orig/gcc/cgraph.h
+++ src/gcc/cgraph.h
@@ -705,6 +705,7 @@ unsigned int rebuild_cgraph_edges (void)
 void cgraph_rebuild_references (void);
 int compute_call_stmt_bb_frequency (tree, basic_block bb);
 void record_references_in_initializer (tree, bool);
+void ipa_record_stmt_references (struct cgraph_node *, gimple);
 
 /* In ipa.c  */
 bool symtab_remove_unreachable_nodes (bool, FILE *);
Index: src/gcc/cgraphbuild.c
===
--- src.orig/gcc/cgraphbuild.c
+++ src/gcc/cgraphbuild.c
@@ -288,6 +288,14 @@ mark_store (gimple stmt, tree t, void *d
   return false;
 }
 
+/* Record all references from NODE that are taken in statement STMT.  */
+void
+ipa_record_stmt_references (struct cgraph_node *node, gimple stmt)
+{
+  walk_stmt_load_store_addr_ops (stmt, node, mark_load, mark_store,
+mark_address);
+}
+
 /* Create cgraph edges for function calls.
Also look for functions and variables having addresses taken.  */
 
@@ -323,8 +331,7 @@ build_cgraph_edges (void)
 gimple_call_flags (stmt),
 bb->count, freq);
}
- walk_stmt_load_store_addr_ops (stmt, node, mark_load,
-mark_store, mark_address);
+ ipa_record_stmt_references (node, stmt);
  if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
  && gimple_omp_parallel_child_fn (stmt))
{
@@ -348,8 +355,7 @@ build_cgraph_edges (void)
}
}
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-   walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node,
-  mark_load, mark_store, mark_address);
+   ipa_record_stmt_references (node, gsi_stmt (gsi));
}
 
   /* Look for initializers of constant variables and private statics.  */
@@ -437,13 +443,10 @@ rebuild_cgraph_edges (void)
 gimple_call_flags (stmt),
 bb->count, freq);
}
- walk_stmt_load_store_addr_ops (stmt, node, mark_load,
-mark_store, mark_address);
-
+ ipa_record_stmt_references (node, stmt);
}
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-   walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node,
-  mark_load, mark_store, mark_address);
+   ipa_record_stmt_references (node, gsi_stmt (gsi));
 }
   record_eh_tables (node, cfun);
   gcc_assert (!node->global.inlined_to);
@@ -468,16 +471,9 @@ cgraph_rebuild_references (void)
   FOR_EACH_BB (bb)
 {
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-   {
- gimple stmt = gsi_stmt (gsi);
-
- walk_stmt_load_store_addr_ops (stmt, node, mark_load,
-mark_store, mark_address);
-
-   }
+   ipa_record_stmt_references (node, gsi_stmt (gsi));
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-   walk_stmt_load_store_addr_ops (gsi_stmt (gsi), node,
-  mark_load, mark_store, mark_address);
+   ipa_record_stmt_references (node, gsi_stmt (gsi));
 }
   record_eh_tables (node, cfun);
 }
Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -3216,18 +3216,22 @@ void
 ipa_modify_call_arguments (

Re: [PATCH, PR 57294] Update symbol table references in IPA-SRA

2013-05-24 Thread Jan Hubicka
> 2013-05-24  Martin Jambor  
> 
>   * cgraph.h (ipa_record_stmt_references): Declare.
>   * cgraphbuild.c (ipa_record_stmt_references): New function.
>   (build_cgraph_edges): Use ipa_record_stmt_references.
>   (rebuild_cgraph_edges): Likewise.
>   (cgraph_rebuild_references): Likewise.
>   * ipa-prop.c (ipa_modify_call_arguments): Discard references
>   associated with the old statement and build references from the
>   newly built statements.
>   * ipa-ref.c (ipa_remove_stmt_references): New function.
>   * ipa-ref.h (ipa_remove_stmt_references): Declare.
> 
> testsuite/
>   * gcc.dg/ipa/pr57294.c: New test.
> 
> +
> +void
> +ipa_remove_stmt_references (symtab_node referring_node, gimple stmt)

Missing comment.
Otherwise the patch is OK.
It would be nice to modify ipa_record_stmt_references to allow also 
verification that all
references are recorded. 

Honza


RE: [PATCH][gensupport] Add optional attributes field to define_cond_exec

2013-05-24 Thread Kyrylo Tkachov
> > As things stand now, if "predicable" is set to "no" for a
> particular
> > alternative, the value of control_attr is irrelevant, that
> alternative
> > will never have a cond_exec version. In your scheme, however,
> > the presence of  triggers the creation of
> cond_exec
> > variants for all of the alternatives, even the ones that we don't
> want
> > to cond_exec.
> Well, that's not quite right. Internally, define_cond_exec works
> pretty similar to define_subst. It can't be applied to one
> alternative
> and not applied to another - it works on the entire pattern. What
> it
> does to distinguish alternatives basing on 'predicable' attribute
> is
> to properly set attribute 'ce_enabled'.

Fair enough. What I meant is that conceptually, it's like there doesn't
exist a cond_exec variant when "predicable" is set to "no".

> 
> Here is a small example (you could try it yourself by invoking
> genmddump which is located in build directory):
> -EXAMPLE 1-
> (define_attr "predicable" "no,yes" (const_string "no"))
> (define_insn "aaa"
>  [(set (match_operand:SI 0 "register_operand" "=r,m,x")
>(match_operand:SI 1 "register_operand" "r,m,x"))]
>  ""
>  "add %0 %1"
>  [(set_attr "predicable" "yes,no,yes")])
> 
> (define_cond_exec
>   [(match_operator 0 "arm_comparison_operator"
> [(match_operand 1 "cc_register" "")
>  (const_int 0)])]
>   "TARGET_32BIT"
>   "")
> - END OF EXAMPLE 1-
> 
> And here is what the compiler has after expanding all patterns (it
> is
> output of genmddump):
> ;; built-in: -1
> (define_attr ("nonce_enabled") ("no,yes") (const_string ("yes")))
> ;; built-in: -1
> (define_attr ("ce_enabled") ("no,yes") (const_string ("yes")))
> ;; a.md: 1
> (define_attr ("predicable") ("no,yes") (const_string ("no")))
> ;; a.md: 3
> (define_insn ("aaa")
>  [ (set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
> (match_operand:SI 1 ("register_operand") ("r,m,x")))
> ] ("") ("add %0 %1")
>  [ (set_attr ("predicable") ("yes,no,yes")) ])
> 
> ;; a.md: 3
> (define_insn ("*p aaa")
>  [ (cond_exec (match_operator 2 ("arm_comparison_operator")
>  [(match_operand 3 ("cc_register") (""))
> (const_int 0 [0]) ])
> (set (match_operand:SI 0 ("register_operand")
> ("=r,m,x"))
> (match_operand:SI 1 ("register_operand")
> ("r,m,x"
> ] ("TARGET_32BIT") ("add %0 %1")
>  [ (set_attr ("ce_enabled") ("yes,no,yes")) ])
> 
> As you might see, it doesn't distinguish alternatives at all - it
> just
> fills 'ce_enabled' attribute with proper values.
> Here is a second example, which is actually pretty similar to the
> first one, but it's done with define_subst:
> -EXAMPLE 2-
> (define_subst_attr "at" "ce_subst" "yes" "no")
> 
> (define_insn "aaa"
>  [(set (match_operand:SI 0 "register_operand" "=r,m,x")
>(match_operand:SI 1 "register_operand" "r,m,x"))]
>  ""
>  "add %0 %1"
>  [(set_attr "ce_enabled" "yes,,yes")])

Isn't ce_enabled an internal, implicit attribute? I don't think it was
meant to be directly manipulated by the MD patterns.
It seems like a hack around the canonical mechanism we have for defining
conditional execution (by way of the "predicable" attribute). 

Presumably, in order to disable the cond_exec variant dynamically
(alternative 3 in your example)
I'd have to add:
(define_subst_attr "subst_predicated" "ce_subst" "no" "yes")

and then in the "aaa" define_insn add:

(set_attr "predicated" "")
(set_attr "control_attr" "yes,yes,no")

and manipulate the "enabled" rules considering the dynamic condition,
"predicated" and "control_attr".
This has the disadvantages of:
- Having to copy (set_attr "predicated" "") in all
patterns that are predicable.
- Using the internal ce_enabled attribute instead of the canonical
"predicable".
- Still doesn't work for define_insn_and_split ;)

> 
> (define_subst "ce_subst"
>  [(match_operand 0)]
>   "TARGET_32BIT"
>   [(cond_exec (match_operator 1 "arm_comparison_operator"
> [(match_operand 2 "cc_register" "")
>  (const_int 0)])
>(match_dup 0))])
> -END OF EXAMPLE 2-
> 
> Here is what compiler has after expanding patterns:
> ;; c.md: 1
> (define_attr ("ce_subst") ("no,yes")  (const_string ("no")))
> ;; c.md: 3
> (define_insn ("aaa")
>  [   (set (match_operand:SI 0 ("register_operand") ("=r,m,x"))
> (match_operand:SI 1 ("register_operand") ("r,m,x")))
> ] ("") ("add %0 %1")
>  [   (set_attr ("ce_enabled") ("yes,yes,yes"))])
> 
> ;; c.md: 3
> (define_insn ("aaa")
>  [(cond_exec (match_operator 2 ("arm_comparison_operator")
>  [(match_operand 3 ("cc_register") (""))
> (const_int 0 [0])])
> (set (match_operand:SI 0 ("register_operand")
> ("=r,m,x"))
> (match_operand:SI 1 ("register_operand")
> ("r,m,x"
> ] ("TARGET_32BIT") ("add %0 %1")
>  [(set_attr ("ce_enabled") ("yes,no,yes"))
>   (set_attr ("ce_subst

Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jonathan Wakely
On 24 May 2013 16:03, Jakub Jelinek wrote:
>
> So, adjusted patches attached, ok for trunk/4.8 if they pass
> bootstrap/regtest?

Yes, they're OK - thanks for sorting it out.


Re: profile mode: statistics for vector and map

2013-05-24 Thread Jonathan Wakely
On 24 May 2013 16:20, Gedare Bloom wrote:
> Updated patch attached to address the comments. I was not able to
> figure out how to build the libstdc++ documentation to verify my doc
> changes although I did run xmllint successfully.

Did you see 
http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_hacking.html#doc.docbook
?


Re: [Patch] Extend script ./contrib/download_prerequisites usage for isl and cloog

2013-05-24 Thread Chung-Ju Wu
2013/5/23 Chung-Ju Wu :
>
> The patch is revised accordingly as follows:
>   - The tar files, including gmp/mpfr/mpc/isl/cloog, are left under directory.
>   - In the shell script, we should use '=' as equality comparison operator.
>
> Thanks for the review comments and Paolo's approval.
> I will commit it tomorrow as long as there are no other comments or 
> objections.
>

Committed as Rev. 199297.
http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=199297

Thanks again for the approval and comments.


Best regards,
jasonwucj


a lra patch

2013-05-24 Thread Vladimir Makarov
The following patch contains some changes needed for porting LRA to 
rs6000 and s390.


The patch was successfully bootstrapped on x86/x86-64.

Committed as rev. 199298.

2013-05-24  Vladimir Makarov  

* lra-constraints.c (emit_spill_move): Use smaller mode for
mem-mem moves.
(check_and_process_move): Consider mem-reg moves for secondary
too.
(curr_insn_transform): Don't lose insns emitted before for
secondary memory moves.
(inherit_in_ebb): Mark defined reg.  Add usage only if it is not a
reg set up in the current insn.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 199273)
+++ lra-constraints.c   (working copy)
@@ -859,10 +859,20 @@ emit_spill_move (bool to_p, rtx mem_pseu
 {
   if (GET_MODE (mem_pseudo) != GET_MODE (val))
 {
-  val = gen_rtx_SUBREG (GET_MODE (mem_pseudo),
-   GET_CODE (val) == SUBREG ? SUBREG_REG (val) : val,
-   0);
-  LRA_SUBREG_P (val) = 1;
+  lra_assert (GET_MODE_SIZE (GET_MODE (mem_pseudo))
+ >= GET_MODE_SIZE (GET_MODE (val)));
+  if (! MEM_P (val))
+   {
+ val = gen_rtx_SUBREG (GET_MODE (mem_pseudo),
+   GET_CODE (val) == SUBREG ? SUBREG_REG (val) : 
val,
+   0);
+ LRA_SUBREG_P (val) = 1;
+   }
+  else
+   {
+ mem_pseudo = gen_lowpart_SUBREG (GET_MODE (val), mem_pseudo);
+ LRA_SUBREG_P (mem_pseudo) = 1;
+   }
 }
   return (to_p
  ? gen_move_insn (mem_pseudo, val)
@@ -890,7 +900,7 @@ check_and_process_move (bool *change_p,
 dreg = SUBREG_REG (dest);
   if (GET_CODE (src) == SUBREG)
 sreg = SUBREG_REG (src);
-  if (! REG_P (dreg) || ! REG_P (sreg))
+  if (! (REG_P (dreg) || MEM_P (dreg)) || ! (REG_P (sreg) || MEM_P (sreg)))
 return false;
   sclass = dclass = NO_REGS;
   if (REG_P (dreg))
@@ -911,14 +921,22 @@ check_and_process_move (bool *change_p,
   if (sclass == ALL_REGS)
 /* See comments above.  */
 return false;
+  if (sclass == NO_REGS && dclass == NO_REGS)
+return false;
 #ifdef SECONDARY_MEMORY_NEEDED
-  if (dclass != NO_REGS && sclass != NO_REGS
-  && SECONDARY_MEMORY_NEEDED (sclass, dclass, GET_MODE (src)))
+  if (SECONDARY_MEMORY_NEEDED (sclass, dclass, GET_MODE (src))
+#ifdef SECONDARY_MEMORY_NEEDED_MODE
+  && ((sclass != NO_REGS && dclass != NO_REGS)
+ || GET_MODE (src) != SECONDARY_MEMORY_NEEDED_MODE (GET_MODE (src)))
+#endif
+  )
 {
   *sec_mem_p = true;
   return false;
 }
 #endif
+  if (! REG_P (dreg) || ! REG_P (sreg))
+return false;
   sri.prev_sri = NULL;
   sri.icode = CODE_FOR_nothing;
   sri.extra_cost = 0;
@@ -3006,16 +3024,22 @@ curr_insn_transform (void)
  /* If the target says specifically to use another mode for
 secondary memory moves we can not reuse the original
 insn.  */
- after = emit_spill_move (false, new_reg, dest);
- lra_process_new_insns (curr_insn, NULL_RTX, after,
-"Inserting the sec. move");
- before = emit_spill_move (true, new_reg, src);
- lra_process_new_insns (curr_insn, before, NULL_RTX, "Changing on");
- lra_set_insn_deleted (curr_insn);
-   }
+ after = emit_spill_move (false, new_reg, dest);
+ lra_process_new_insns (curr_insn, NULL_RTX, after,
+"Inserting the sec. move");
+ /* We may have non null BEFORE here (e.g. after address
+processing.  */
+ push_to_sequence (before);
+ before = emit_spill_move (true, new_reg, src);
+ emit_insn (before);
+ before = get_insns ();
+ end_sequence ();
+ lra_process_new_insns (curr_insn, before, NULL_RTX, "Changing on");
+ lra_set_insn_deleted (curr_insn);
+   }
   else if (dest == rld)
-   {
- *curr_id->operand_loc[0] = new_reg;
+{
+ *curr_id->operand_loc[0] = new_reg;
  after = emit_spill_move (false, new_reg, dest);
  lra_process_new_insns (curr_insn, NULL_RTX, after,
 "Inserting the sec. move");
@@ -3023,7 +3047,12 @@ curr_insn_transform (void)
   else
{
  *curr_id->operand_loc[1] = new_reg;
+ /* See comments above.  */
+ push_to_sequence (before);
  before = emit_spill_move (true, new_reg, src);
+ emit_insn (before);
+ before = get_insns ();
+ end_sequence ();
  lra_process_new_insns (curr_insn, before, NULL_RTX,
 "Inserting the sec. move");
}
@@ -3823,7 +3852,9 @@ struct usage_insns
 {
   /* If the value is equal to CURR_USAGE_INSNS_CHECK, then the member
  value INSNS is valid.  The insns is chain of optional debug insns
- and a finishing non-debug insn u

Re: [PATCH] Do not allow non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs

2013-05-24 Thread Eric Botcazou
> I agree it is desirable, but is it enough to ensure that they will be only
> toplevel?  Can't you e.g. do a VIEW_CONVERT_EXPR from an integer type or
> floating/vector type etc. to struct type, then the verifier wouldn't
> discover there is VIEW_CONVERT_EXPR  32>>?

Sure, you can apply VIEW_CONVERT_EXPR to whatever you want, but does that 
count as non-toplevelness?  Won't SRA already punt on such abomination?

-- 
Eric Botcazou


Re: [patch] Fix sched-deps DEP_POSTPONED, ds_t documentation

2013-05-24 Thread Vladimir Makarov

On 13-05-23 4:51 PM, Steven Bosscher wrote:

Ping**2

Steven, sorry for the delay.  The patch is ok.  Thanks for better 
documentation too.  We need it as the scheduler is becoming more and 
more complicated.


Re: Mark threshold arrays in bb-reorder.c as constant

2013-05-24 Thread Chung-Ju Wu
2013/5/23 Jakub Jelinek :
> On Wed, May 22, 2013 at 08:30:35PM -0400, David Malcolm wrote:
>> The arrays of thresholds in gcc/bb-reorder.c appear not to have changed
>> since 2004 (in r80564).
>>
>> As part of my hope of quashing global state in gcc, I'd like to mark
>> them as const.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu against r199189, and
>> has the same test results as an unpatched bootstrap of that revision.
>>
>> OK to commit to trunk?
>>
>> 2013-05-21  David Malcolm  
>>
>>   * bb-reorder.c (branch_threshold): make const
>>   (exec_threshold): ditto
>
> The ChangeLog formatting is bad.  After ): should always be a capital letter
> and the description should end with dot.  So:
>
> * bb-reorder.c (branch_threshold): Make const.
> (exec_threshold): Ditto.
>
> instead.
>
> Jakub


Hi, David,

There is a similar issue in the contrib/ChangeLog.


2013-05-21  David Malcolm  

* repro_fail: filter out "-ignore SIGHUP" from the spawn lines


It would be great if you can fix them to make formatting consistent. :)


Best regards,
jasonwucj


Re: C++ PATCH for c++/57391 (bootstrap fail on AIX)

2013-05-24 Thread David Edelsohn
On Fri, May 24, 2013 at 10:16 AM, Jason Merrill  wrote:
> When FMA_EXPR was added to potential_constant_expression_1, it wasn't added
> to cxx_eval_constant_expression at the same time...
>
> Regression tested x86_64-pc-linux-gnu, applying to trunk.  David, can you
> verify that this fixes bootstrap on AIX?

With the patch applied, I am able to progress past the point of the
previous ICE.

Thanks, David


Re: [C++ Patch] PR 19618

2013-05-24 Thread Jason Merrill

On 05/24/2013 10:50 AM, Paolo Carlini wrote:

+  || ((TREE_CODE (type) == ENUMERAL_TYPE
+   && (tree_int_cst_lt
+   (TYPE_SIZE (ENUM_UNDERLYING_TYPE (type)), w)))
+  || (TREE_CODE (type) == BOOLEAN_TYPE
+  && tree_int_cst_lt (TYPE_SIZE (type), w


The size of the enum underlying type is the same as the size of the enum 
itself, so I don't think you need to handle enum and bool differently here.


Jason



Re: Mark threshold arrays in bb-reorder.c as constant

2013-05-24 Thread David Malcolm
On Fri, 2013-05-24 at 23:51 +0800, Chung-Ju Wu wrote:
> 2013/5/23 Jakub Jelinek :
> > On Wed, May 22, 2013 at 08:30:35PM -0400, David Malcolm wrote:
> >> The arrays of thresholds in gcc/bb-reorder.c appear not to have changed
> >> since 2004 (in r80564).
> >>
> >> As part of my hope of quashing global state in gcc, I'd like to mark
> >> them as const.
> >>
> >> Bootstrapped and tested on x86_64-unknown-linux-gnu against r199189, and
> >> has the same test results as an unpatched bootstrap of that revision.
> >>
> >> OK to commit to trunk?
> >>
> >> 2013-05-21  David Malcolm  
> >>
> >>   * bb-reorder.c (branch_threshold): make const
> >>   (exec_threshold): ditto
> >
> > The ChangeLog formatting is bad.  After ): should always be a capital letter
> > and the description should end with dot.  So:
> >
> > * bb-reorder.c (branch_threshold): Make const.
> > (exec_threshold): Ditto.
> >
> > instead.
> >
> > Jakub
> 
> 
> Hi, David,
> 
> There is a similar issue in the contrib/ChangeLog.
> 
> 
> 2013-05-21  David Malcolm  
> 
> * repro_fail: filter out "-ignore SIGHUP" from the spawn lines
> 
> 
> It would be great if you can fix them to make formatting consistent. :)

I've fixed both of these (I hope) in r199302

Thanks
Dave



Re: [PING]RE: [patch] cilkplus: Array notation for C patch

2013-05-24 Thread Jeff Law

On 05/23/2013 06:42 PM, Iyer, Balaji V wrote:


I got all your responses and, if I remove the compile, execute and
errors directories but keep cilk-plus and array notation, maybe even
abbreviate array notation to "an", (in future cilk keywords to "ck",
pragma simd to "ps" and  elemental function to "ef"), will that be OK
with everyone? We removed one directory and moved 3 scripts to 1, and
with abbreviated subdirectories the ChangeLog lines won't be long. I
really like to put all the cilk-plus tests in one location for C
compiler so that if anyone wants to get them I can point to one
location.
Seems like a reasonable compromise..  Works for me.  I'll stop 
bikeshedding :-)


jeff


Fwd: [PATCH, updated] Vtable pointer verification, C++ front end changes (patch 1 of 3)

2013-05-24 Thread Caroline Tice
Trying to send again; gcc_patches list bounced original message.

-- Forwarded message --
From: Caroline Tice 
Date: Fri, May 24, 2013 at 9:15 AM
Subject: Re: [PATCH, updated] Vtable pointer verification, C++ front
end changes (patch 1 of 3)
To: Jason Merrill 
Cc: Diego Novillo , Luis Lozano
, Bhaskar Janakiraman ,
GCC Patches 



I'm afraid I have been busy trying to finish up other things recently,
but now I am ready to focus full time on this again.

On Mon, Apr 8, 2013 at 6:21 PM, Jason Merrill  wrote:
>
> Hi, sorry it has taken me so long to get back to this.  Hopefully we can wrap 
> it up quickly now that we're back in stage 1.
>
> On 02/25/2013 02:24 PM, Caroline Tice wrote:
>>
>> -CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ 
>> -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)
>> /libstdc++-v3/scripts/testsuite_flags; then $(SHELL) 
>> $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-
>> includes; else echo -funconfigured-libstdc++-v3 ; fi` 
>> -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/li
>> bstdc++-v3/src/.libs'
>> +CXX_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/xg++ -B$$r/$(HOST_SUBDIR)/gcc/ 
>> -nostdinc++ `if test -f $$r/$(TARGET_SUBDIR)
>> /libstdc++-v3/scripts/testsuite_flags; then $(SHELL) 
>> $$r/$(TARGET_SUBDIR)/libstdc++-v3/scripts/testsuite_flags --build-
>> includes; else echo -funconfigured-libstdc++-v3 ; fi` 
>> -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/li
>> bstdc++-v3/src/.libs -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs'
>
>
> You shouldn't need this, since libstdc++ includes libsupc++.  And if you did 
> need to do it, it would need to be in configure.ac or it will be discarded by 
> the next autoconf.
>

Ok, I will remove this.

>>
>> + information aboui which vtable will actually be emitted.  */
>
>
> "about"


Done.

>
>
>> +vtv_finish_verification_constructor_init_function (tree function_body)
>> +{
>> +  tree fn;
>> +
>> +  finish_compound_stmt (function_body);
>> +  fn = finish_function (0);
>> +  DECL_STATIC_CONSTRUCTOR (fn) = 1;
>> +  decl_init_priority_insert (fn, MAX_RESERVED_INIT_PRIORITY - 1);
>
>
> Why did you stop using finish_objects?  If it was to be able to return the 
> function, you can get that from current_function_decl before calling 
> finish_objects.
>

I stopped using finish_objects because it always called
expand_or_defer_fn, and I did not want that to happen here.

>>>
>>> Index: gcc/cp/g++spec.c
>>
>>
>> Changes to g++spec.c only affect the g++ driver, not the gcc driver. Are you 
>> sure this is what you want?  Can't you handle this stuff directly in the 
>> specs like address sanitizer does?
>
>
> I haven't seen a response to this comment.
>

It seems correct to only update the g++ driver, since this option only
does things for C++ programs.  I'm not sure what address sanitizer
does "directly in the specs"...Which specs would these be?


>>>
>>> +   vtv_rts.cc \
>>> +   vtv_malloc.cc \
>>> +   vtv_utils.cc
>>
>>
>> It seems to me that this code belongs in a separate library like 
>> libsanitizer, not in libstdc++.
>
>
> Or this one.
>

Originally I was not doing anything with the specs, and so I didn't
want to have to add a special link command, to link in a special
library whenever the fvtable-verify option is used.  Now that I've
started changing the specs anyway, I suppose I could go ahead and put
this in its own separate library and add a link option.  Is that
really the way I should go with this?


 -  switch_to_section (sect);
 +  if (sect->named.name
 + && (strcmp (sect->named.name, ".vtable_map_vars") == 0))
 +   {
 +#if defined (OBJECT_FORMAT_ELF)
 +  targetm.asm_out.named_section (sect->named.name,
 +sect->named.common.flags
 +| SECTION_LINKONCE,
 +DECL_NAME (decl));
 +  in_section = sect;
 +#else
 +  switch_to_section (sect);
 +#endif
 +}
 +  else
 +switch_to_section (sect);
>>>
>>>
>>>
 +  if (strcmp (name, ".vtable_map_vars") == 0)
 +  flags |= SECTION_LINKONCE;
>>>
>>>
>>>
>>> These changes should not be necessary.  Just set DECL_ONE_ONLY on the vtable
>>> map variables.
>>>

I am sorry to disagree with you, but you are incorrect.  The second
change can be eliminated (the one that adds SECTION_LINKONCE to
flags), but the first change above is necessary.  What the first bit
of code does is to ensure that each vtable map variable gets its own
unique comdat name.  When I tried removing this code, it put all the
vtable map variables into the same section with a single comdat name.
This will not work for us because the linker may need to pick and
choose individual variables out of each object file, not accept or
reject all the variables in an object file as a s

Re: profile mode: statistics for vector and map

2013-05-24 Thread Gedare Bloom
On Fri, May 24, 2013 at 11:26 AM, Jonathan Wakely  wrote:
> On 24 May 2013 16:20, Gedare Bloom wrote:
>> Updated patch attached to address the comments. I was not able to
>> figure out how to build the libstdc++ documentation to verify my doc
>> changes although I did run xmllint successfully.
>
> Did you see 
> http://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_hacking.html#doc.docbook
> ?
Yes. I could not resolve errors dealing with some of the xml/xsl
processing, like "cannot parse /xhtml/chunk.xsl".


Re: RFA: fix rtl-optimization/56833

2013-05-24 Thread Joern Rennecke

Please find attached the updated patch.

bootstrapped / regtested for i686-pc-linux-gnu
regtested for i686-pc-linux-gnu X sh-elf
regtested in gcc 4.8 branch for i686-pc-linux-gnu X avr  
(--target-board atmega128-sim)
2013-05-24  Joern Rennecke 

PR rtl-optimization/56833
* postreload.c (move2add_record_mode): New function.
(move2add_record_sym_value, move2add_valid_value_p): Likewise.
(move2add_use_add2_insn): Use move2add_record_sym_value.
(move2add_use_add3_insn): Likewise.
(reload_cse_move2add): Use move2add_valid_value_p and
move2add_record_mode.  Invalidate call-clobbered and REG_INC
affected regs by setting reg_mode to VOIDmode.
(move2add_note_store): Don't pretend the inside of a SUBREG is
the actual destination.  Invalidate single/leading registers by
setting reg_mode to VOIDmode.
Use move2add_record_sym_value, move2add_valid_value_p and
move2add_record_mode.

Index: postreload.c
===
--- postreload.c(revision 199190)
+++ postreload.c(working copy)
@@ -1645,14 +1645,22 @@ reload_combine_note_use (rtx *xp, rtx in
later disable any optimization that would cross it.
reg_offset[n] / reg_base_reg[n] / reg_symbol_ref[n] / reg_mode[n]
are only valid if reg_set_luid[n] is greater than
-   move2add_last_label_luid.  */
+   move2add_last_label_luid.
+   For a set that established a new (potential) base register with
+   non-constant value, we use move2add_luid from the place where the
+   setting insn is encountered; registers based off that base then
+   get the same reg_set_luid.  Constants all get
+   move2add_last_label_luid + 1 as their reg_set_luid.  */
 static int reg_set_luid[FIRST_PSEUDO_REGISTER];
 
 /* If reg_base_reg[n] is negative, register n has been set to
reg_offset[n] or reg_symbol_ref[n] + reg_offset[n] in mode reg_mode[n].
If reg_base_reg[n] is non-negative, register n has been set to the
sum of reg_offset[n] and the value of register reg_base_reg[n]
-   before reg_set_luid[n], calculated in mode reg_mode[n] .  */
+   before reg_set_luid[n], calculated in mode reg_mode[n] .
+   For multi-hard-register registers, all but the first one are
+   recorded as BLKmode in reg_mode.  Setting reg_mode to VOIDmode
+   marks it as invalid.  */
 static HOST_WIDE_INT reg_offset[FIRST_PSEUDO_REGISTER];
 static int reg_base_reg[FIRST_PSEUDO_REGISTER];
 static rtx reg_symbol_ref[FIRST_PSEUDO_REGISTER];
@@ -1674,6 +1682,63 @@ #define MODES_OK_FOR_MOVE2ADD(OUTMODE, I
|| (GET_MODE_SIZE (OUTMODE) <= GET_MODE_SIZE (INMODE) \
&& TRULY_NOOP_TRUNCATION_MODES_P (OUTMODE, INMODE)))
 
+/* Record that REG is being set to a value with the mode of REG.  */
+
+static void
+move2add_record_mode (rtx reg)
+{
+  int regno, nregs;
+  enum machine_mode mode = GET_MODE (reg);
+  int i;
+
+  if (GET_CODE (reg) == SUBREG)
+{
+  regno = subreg_regno (reg);
+  nregs = subreg_nregs (reg);
+}
+  else if (REG_P (reg))
+{
+  regno = REGNO (reg);
+  nregs = hard_regno_nregs[regno][mode];
+}
+  else
+gcc_unreachable ();
+  for (i = nregs - 1; i > 0; i--)
+reg_mode[regno + i] = BLKmode;
+  reg_mode[regno] = mode;
+}
+
+/* Record that REG is being set to the sum of SYM and OFF.  */
+
+static void
+move2add_record_sym_value (rtx reg, rtx sym, rtx off)
+{
+  int regno = REGNO (reg);
+
+  move2add_record_mode (reg);
+  reg_set_luid[regno] = move2add_luid;
+  reg_base_reg[regno] = -1;
+  reg_symbol_ref[regno] = sym;
+  reg_offset[regno] = INTVAL (off);
+}
+
+/* Check if REGNO contains a valid value in MODE.  */
+
+static bool
+move2add_valid_value_p (int regno, enum machine_mode mode)
+{
+  int i;
+
+  if (reg_set_luid[regno] <= move2add_last_label_luid
+  || !MODES_OK_FOR_MOVE2ADD (mode, reg_mode[regno]))
+return false;
+
+  for (i = hard_regno_nregs[regno][mode] - 1; i > 0; i--)
+if (reg_mode[i] != BLKmode)
+  return false;
+  return true;
+}
+
 /* This function is called with INSN that sets REG to (SYM + OFF),
while REG is known to already have value (SYM + offset).
This function tries to change INSN into an add instruction
@@ -1749,11 +1814,7 @@ move2add_use_add2_insn (rtx reg, rtx sym
}
}
 }
-  reg_set_luid[regno] = move2add_luid;
-  reg_base_reg[regno] = -1;
-  reg_mode[regno] = GET_MODE (reg);
-  reg_symbol_ref[regno] = sym;
-  reg_offset[regno] = INTVAL (off);
+  move2add_record_sym_value (reg, sym, off);
   return changed;
 }
 
@@ -1787,8 +1848,7 @@ move2add_use_add3_insn (rtx reg, rtx sym
   SET_SRC (pat) = plus_expr;
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-if (reg_set_luid[i] > move2add_last_label_luid
-   && reg_mode[i] == GET_MODE (reg)
+if (move2add_valid_value_p (i, GET_MODE (reg))
&& reg_base_reg[i] < 0
&& reg_symbol_ref[i] != NULL_RTX
&& rtx_equal_p (sym, reg_symbol_ref[i]))
@@

Re: [PATCH] [tree-optimization/57124] Updated fix for 254.gap problems

2013-05-24 Thread Jeff Law

On 05/21/2013 02:23 AM, Richard Biener wrote:

On Fri, May 17, 2013 at 5:51 PM, Jeff Law  wrote:

As I believe I pointed out in a follow-up message, 254.gap is depending on
signed overflow semantics.

This patch avoids eliminating a cast feeding a conditional when the
SSA_NAME's range has overflowed unless -fstrict-overflow is in effect. Thus
254.gap should be building with -fno-strict-overflow.

This patch also introduces a warning when the optimization is applied and
the ranges have overflowed.

Bootstrapped and regression tested on x86-unknown-linux-gnu.

OK for the trunk?




commit 62bbaa8de0e8d929eb3c63331b47950e9b09d801
Author: Jeff Law 
Date:   Wed May 1 12:33:20 2013 -0600

 PR tree-optimization/57124
 * tree-vrp.c (simplify_cond_using_ranges): Only simplify a
 conversion feeding a condition if the range has an overflow
 if -fstrict-overflow.  Add warnings for when we do make the
 transformation.

 PR tree-optimization/57124
 * gcc.c-torture/execute/pr57124.c: New test.
 * gcc.c-torture/execute/pr57124.x: Set -fno-strict-overflow.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8e92c44..9320f21 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2013-05-17  Jeff Law  
+
+   PR tree-optimization/57124
+   * tree-vrp.c (simplify_cond_using_ranges): Only simplify a
+   conversion feeding a condition if the range has an overflow
+   if -fstrict-overflow.  Add warnings for when we do make the
+   transformation.
+
  2013-05-16  Rainer Orth  

 * reorg.c (link_cc0_insns): Wrap in #ifdef HAVE_cc0.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 879b9bc..482151c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-17  Jeff Law  
+
+   PR tree-optimization/57124
+   * gcc.c-torture/execute/pr57124.c: New test.
+   * gcc.c-torture/execute/pr57124.x: Set -fno-strict-overflow.
+
  2013-05-16  Greta Yorsh  

 * gcc.target/arm/unaligned-memcpy-2.c: Adjust expected output.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr57124.c
b/gcc/testsuite/gcc.c-torture/execute/pr57124.c
new file mode 100644
index 000..835d249
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr57124.c
@@ -0,0 +1,27 @@
+__attribute__ ((noinline))
+foo(short unsigned int *p1, short unsigned int *p2)
+{
+  short unsigned int x1, x4;
+  int x2, x3, x5, x6;
+  unsigned int x7;
+
+  x1 = *p1;
+  x2 = (int) x1;
+  x3 = x2 * 65536;
+  x4 = *p2;
+  x5 = (int) x4;
+  x6 = x3 + x4;
+  x7 = (unsigned int) x6;
+  if (x7 <= 268435455U)
+abort ();
+  exit (0);
+}
+
+main()
+{
+  short unsigned int x, y;
+  x = -5;
+  y = -10;
+  foo (&x, &y);
+}
+
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr57124.x
b/gcc/testsuite/gcc.c-torture/execute/pr57124.x
new file mode 100644
index 000..d8cacbe
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr57124.x
@@ -0,0 +1,2 @@
+set additional_flags "-fno-strict-overflow"
+return 0
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index b5de683..b3eccf0 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -8669,8 +8669,32 @@ simplify_cond_using_ranges (gimple stmt)
   && range_fits_type_p (vr,
 TYPE_PRECISION (TREE_TYPE (op0)),
 TYPE_UNSIGNED (TREE_TYPE (op0)))
- && int_fits_type_p (op1, TREE_TYPE (innerop)))
+ && int_fits_type_p (op1, TREE_TYPE (innerop))
+ /* The range must not have overflowed, or if it did overflow
+we must not be wrapping/trapping overflow and optimizing
+with strict overflow semantics.  */
+ && ((!is_negative_overflow_infinity (vr->min)
+  && !is_positive_overflow_infinity (vr->max))
+ || (!flag_wrapv && !flag_trapv && flag_strict_overflow)))


Ok with changing this to

|| TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (innerop)))

That's handy :-)Done.



+ warning_at (location, OPT_Wstrict_overflow,
+ "assuming signed overflow does not occur when "
+ "simplifying conditional.");


and the trailing '.' removed

Done.

Bootstrapped and retested on x86_64-unknown-linux-gnu.  Installed. 
Final patch attached for future reference.


Jeff
commit 65a8f1a1cd31f5b564a7e41e9146c638aaeb0942
Author: law 
Date:   Fri May 24 17:13:38 2013 +

PR tree-optimization/57124
* tree-vrp.c (simplify_cond_using_ranges): Only simplify a
conversion feeding a condition if the range has an overflow
if -fstrict-overflow.  Add warnings for when we do make the
transformation.

PR tree-optimization/57124
* gcc.c-torture/execute/pr57124.c: New test.
* gcc.c-torture/execute/pr57124.x: Set -fno-strict-overflow.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199305 
138bc75d-0d04-

Re: [C++ Patch] PR 19618

2013-05-24 Thread Paolo Carlini

Hi,

On 05/24/2013 06:12 PM, Jason Merrill wrote:

On 05/24/2013 10:50 AM, Paolo Carlini wrote:

+   || ((TREE_CODE (type) == ENUMERAL_TYPE
+&& (tree_int_cst_lt
+(TYPE_SIZE (ENUM_UNDERLYING_TYPE (type)), w)))
+   || (TREE_CODE (type) == BOOLEAN_TYPE
+   && tree_int_cst_lt (TYPE_SIZE (type), w


The size of the enum underlying type is the same as the size of the 
enum itself, so I don't think you need to handle enum and bool 
differently here.
Yeah. Sorry for wasting your time on this. I'm finishing testing the 
below then.


Thanks,
Paolo.

/
Index: cp/class.c
===
--- cp/class.c  (revision 199302)
+++ cp/class.c  (working copy)
@@ -3140,9 +3140,12 @@ check_bitfield_decl (tree field)
  error ("zero width for bit-field %q+D", field);
  w = error_mark_node;
}
-  else if (compare_tree_int (w, TYPE_PRECISION (type)) > 0
-  && TREE_CODE (type) != ENUMERAL_TYPE
-  && TREE_CODE (type) != BOOLEAN_TYPE)
+  else if ((TREE_CODE (type) != ENUMERAL_TYPE
+   && TREE_CODE (type) != BOOLEAN_TYPE
+   && compare_tree_int (w, TYPE_PRECISION (type)) > 0)
+  || ((TREE_CODE (type) == ENUMERAL_TYPE
+   || TREE_CODE (type) == BOOLEAN_TYPE)
+  && tree_int_cst_lt (TYPE_SIZE (type), w)))
warning (0, "width of %q+D exceeds its type", field);
   else if (TREE_CODE (type) == ENUMERAL_TYPE
   && (0 > (compare_tree_int
Index: testsuite/g++.dg/expr/bitfield12.C
===
--- testsuite/g++.dg/expr/bitfield12.C  (revision 0)
+++ testsuite/g++.dg/expr/bitfield12.C  (working copy)
@@ -0,0 +1,19 @@
+// PR c++/19618
+
+struct bset1 {
+  bool bit : sizeof(bool) * __CHAR_BIT__ + 1;  // { dg-warning "exceeds" }
+};
+
+enum E {};
+
+struct bset2 {
+  E bit : sizeof(E) * __CHAR_BIT__ + 1;// { dg-warning "exceeds" }
+};
+
+struct bset3 {
+  bool bit : sizeof(bool) * __CHAR_BIT__;
+};
+
+struct bset4 {
+  E bit : sizeof(E) * __CHAR_BIT__;
+};


Re: [C++ Patch] PR 19618

2013-05-24 Thread Jason Merrill

OK.

Jason


Re: PR tree-optimization/57337

2013-05-24 Thread Easwaran Raman
In that case, if my insert_stmt immediately follows dep_stmt and both
have the same UID, not_dominated_by would return true and I will end
up updating insert_stmt to dep_stmt which is wrong.

- Easwaran

On Fri, May 24, 2013 at 1:07 AM, Richard Biener
 wrote:
> On Thu, May 23, 2013 at 7:26 PM, Easwaran Raman  wrote:
>> This addresses the case where UID alone is not sufficient to figure
>> out which statement appears earlier in  a BB. Bootstraps and no test
>> regressions in x86_64 on linux. Ok for trunk?
>
> Why not simply conservatively use gimple_uid (a) <= gimple_uid (b)
> in not_dominated_by?
>
> Richard.
>
>
>
>> Thanks,
>> Easwaran
>>
>>
>> 2013-05-23  Easwaran Raman  
>>
>> PR tree-optimization/57337
>> * tree-ssa-reassoc.c (appears_later_in_bb): New function.
>> (find_insert_point): Correctly identify the insertion point
>> when two statements with the same UID is compared.
>>
>> Index: gcc/tree-ssa-reassoc.c
>> ===
>> --- gcc/tree-ssa-reassoc.c  (revision 199211)
>> +++ gcc/tree-ssa-reassoc.c  (working copy)
>> @@ -2866,6 +2866,31 @@ not_dominated_by (gimple a, gimple b)
>>
>>  }
>>
>> +/* Among STMT1 and STMT2, return the statement that appears later. Both
>> +   statements are in same BB and have the same UID.  */
>> +
>> +static gimple
>> +appears_later_in_bb (gimple stmt1, gimple stmt2)
>> +{
>> +  unsigned uid = gimple_uid (stmt1);
>> +  gimple_stmt_iterator gsi = gsi_for_stmt (stmt1);
>> +  gsi_next (&gsi);
>> +  if (gsi_end_p (gsi))
>> +return stmt1;
>> +  for (; !gsi_end_p (gsi); gsi_next (&gsi))
>> +{
>> +  gimple stmt = gsi_stmt (gsi);
>> +
>> +  /* If STMT has a different UID than STMT1 and we haven't seen
>> + STMT2 during traversal, we know STMT1 appears later.  */
>> +  if (gimple_uid (stmt) != uid)
>> +return stmt1;
>> +  else if (stmt == stmt2)
>> +return stmt2;
>> +}
>> +  gcc_unreachable ();
>> +}
>> +
>>  /* Find the statement after which STMT must be moved so that the
>> dependency from DEP_STMT to STMT is maintained.  */
>>
>> @@ -2875,7 +2900,11 @@ find_insert_point (gimple stmt, gimple dep_stmt)
>>gimple insert_stmt = stmt;
>>if (dep_stmt == NULL)
>>  return stmt;
>> -  if (not_dominated_by (insert_stmt, dep_stmt))
>> +  if (gimple_uid (insert_stmt) == gimple_uid (dep_stmt)
>> +  && gimple_bb (insert_stmt) == gimple_bb (dep_stmt)
>> +  && insert_stmt != dep_stmt)
>> +insert_stmt = appears_later_in_bb (insert_stmt, dep_stmt);
>> +  else if (not_dominated_by (insert_stmt, dep_stmt))
>>  insert_stmt = dep_stmt;
>>return insert_stmt;
>>  }


RE: [PING]RE: [patch] cilkplus: Array notation for C patch

2013-05-24 Thread Iyer, Balaji V
Hello Richard, et al.,
Attached please find a patch with the following changes:

1. Test-suite codes were moved to the appropriate location as suggested below

And the following modifications that RTH mentioned in 
(http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01400.html)

2. ARRAY_NOTATION_TYPE is completely removed (from the location in tree, its 
definition and usage) 
3. Generic.texi had documentation for ARRAY_NOTATION_REF. That is also removed.

It is passing all the regression tests and not breaking/passing any other tests 
that were not already breaking/passing in the trunk.

Here are the ChangeLog entries with the above updates reflected:

gcc/ChangeLog
2013-05-24  Balaji V. Iyer  

* doc/extend.texi (C Extensions): Added documentation about Cilk Plus
array notation built-in reduction functions.
* doc/passes.texi (Passes): Added documentation about changes done
for Cilk Plus.
* doc/invoke.texi (C Dialect Options): Added documentation about
the -fcilkplus flag.
* Makefile.in (C_COMMON_OBJS): Added c-family/array-notation-common.o.
(BUILTINS_DEF): Depend on cilkplus.def.
* builtins.def: Include cilkplus.def.  Define DEF_CILKPLUS_BUILTIN.
* builtin-types.def: Define BT_FN_INT_PTR_PTR_PTR.
* cilkplus.def: New file.

gcc/c-family/ChangeLog
2013-05-24  Balaji V. Iyer  

* c-common.c (c_define_builtins): When cilkplus is enabled, the
function array_notation_init_builtins is called.
(c_common_init_ts): Added ARRAY_NOTATION_REF as typed.
* c-common.def (ARRAY_NOTATION_REF): New tree.
* c-common.h (build_array_notation_expr): New function declaration.
(build_array_notation_ref): Likewise.
(extract_sec_implicit_index_arg): New extern declaration.
(is_sec_implicit_index_fn): Likewise.
(ARRAY_NOTATION_CHECK): New define.
(ARRAY_NOTATION_ARRAY): Likewise.
(ARRAY_NOTATION_START): Likewise.
(ARRAY_NOTATION_LENGTH): Likewise.
(ARRAY_NOTATION_STRIDE): Likewise.
* c-pretty-print.c (pp_c_postifix_expression): Added a new case for
ARRAY_NOTATION_REF.
(pp_c_expression): Likewise.
* c.opt (flag_enable_cilkplus): New flag.
* array-notation-common.c: New file.

gcc/c/ChangeLog
2013-05-24  Balaji V. Iyer  

* c-typeck.c (build_array_ref): Added a check to see if array's
index is greater than one.  If true, then emit an error.
(build_function_call_vec): Exclude error reporting and checking
for builtin array-notation functions.
(convert_arguments): Likewise.
(c_finish_return): Added a check for array notations as a return
expression.  If true, then emit an error.
(c_finish_loop): Added a check for array notations in a loop
condition.  If true then emit an error.
(lvalue_p): Added a ARRAY_NOTATION_REF case.
(build_binary_op): Added a check for array notation expr inside
op1 and op0.  If present, we call another function to find correct
type.
* Make-lang.in (C_AND_OBJC_OBJS): Added c-array-notation.o.
* c-parser.c (c_parser_compound_statement): Check if array
notation code is used in tree, if so, then transform them into
appropriate C code.
(c_parser_expr_no_commas): Check if array notation is used in LHS
or RHS, if so, then build array notation expression instead of
regular modify.
(c_parser_postfix_expression_after_primary): Added a check for
colon(s) after square braces, if so then handle it like an array
notation.  Also, break up array notations in unary op if found.
(c_parser_direct_declarator_inner): Added a check for array
notation.
(c_parser_compound_statement): Added a check for array notation in
a stmt.  If one is present, then expand array notation expr.
(c_parser_if_statement): Likewise.
(c_parser_switch_statement): Added a check for array notations in
a switch statement's condition.  If true, then output an error.
(c_parser_while_statement): Similarly, but for a while.
(c_parser_do_statement): Similarly, but for a do-while.
(c_parser_for_statement): Similarly, but for a for-loop.
(c_parser_unary_expression): Check if array notation is used in a
pre-increment or pre-decrement expression.  If true, then expand
them.
(c_parser_array_notation): New function.
* c-array-notation.c: New file.
* c-tree.h (is_cilkplus_reduce_builtin): Protoize.


gcc/testsuite/ChangeLog
2013-05-24  Balaji V. Iyer  

* gcc.dg/cilk-plus/AN/array_test1.c: New test.
* gcc.dg/cilk-plus/AN/array_test2.c: Ditto.
* gcc.dg/cilk-plus/AN/array_test_ND.c: Ditto.
* gcc.dg/cilk-plus/AN/builtin_func_double.c: Ditto.
* gcc.dg/cilk-plus/AN/builtin_func_double2.c: Ditto.
 

RE: [PING]RE: [patch] cilkplus: Array notation for C patch

2013-05-24 Thread Aldy Hernandez
I'm ok inasmuch as the relevant tests are shared between c/c++.

"Iyer, Balaji V"  wrote:

[I included Jeff Law also in this conversation]

> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Aldy Hernandez
> Sent: Thursday, May 23, 2013 3:23 PM
> To: Jakub Jelinek
> Cc: Iyer, Balaji V; Richard Henderson; 'Joseph S. Myers'; 'gcc-patches'
> Subject: Re: [PING]RE: [patch] cilkplus: Array notation for C patch
> 
> On 05/23/13 14:03, Jakub Jelinek wrote:
> > On Thu, May 23, 2013 at 06:27:04PM +, Iyer, Balaji V wrote:
> >> gcc/testsuite/ChangeLog
> >> 2013-05-23  Balaji V. Iyer  
> >>
> >>  * gcc.dg/cilk-plus/array_notation/compile/array_test2.c: New test.
> >
> > I have concerns about the test locations, to me this looks way too
> > deep tree, whether something is a compile test, or compile test
> > expecting errors or runtime test is easily determined by { dg-do
> > compile } vs. { dg-do run } and presence or lack of { dg-error ... }
> > comments.  So IMHO that level should be left out, plus I'd say the
> > array_notation/ level is unnecessary as well, just put everything into
> > c-c++-common/cilk-plus/an-*.c (except for tests that aren't going to
> > be usable for C++, those can stay in gcc.dg/cilk-plus/an-*.c).  Then
> > gcc.dg/cilk-plus/*.exp would just ensure that tests from that
> > directory are run and also from c-c++-common/ and later on the same
> > would happen in g++.dg/cilk-plus/.  In the future when you will need
> > to link against runtime library cilk-plus.exp would just arrange for that 
> > to be
> added to LD_LIBRARY_PATH, -L.../ etc.
> 
> For the record, I agree.

I got all your responses and, if I remove the compile, execute and errors 
directories but keep cilk-plus and array notation, maybe even abbreviate array 
notation to "an", (in future cilk keywords to "ck", pragma simd to "ps" and  
elemental function to "ef"), will that be OK with everyone? We removed one 
directory and moved 3 scripts to 1, and with abbreviated subdirectories the 
ChangeLog lines won't be long. I really like to put all the cilk-plus tests in 
one location for C compiler so that if anyone wants to get them I can point to 
one location.

Thanks,

Balaji V. Iyer.


Re: [PING]RE: [patch] cilkplus: Array notation for C patch

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 05:52:11PM +, Iyer, Balaji V wrote:
>   * gcc.dg/cilk-plus/AN/array_test1.c: New test.
...
>   * gcc.dg/cilk-plus/AN/cilkplus_AN_c.exp: New script.

Ok, I guess I can live with /AN/ extra level, but can you please
move it still to c-c++-common/cilk-plus/AN/ for all tests that can
be shared with C++?  Look at c-c++-common/ current tests, see
how they can use { target c } or { target c++ } etc. if there is say
small difference in diagnostics, but still most of the test is the same.

I don't like the cilkplus_AN_c.exp, IMNSHO you should just have
gcc.dg/cilk-plus/cilk-plus.exp that handles everything.  For how
is it supposed to load the files from subdirectories or how is it supposed
to load c-c++-common/cilk-plus/ testcases please look at g++.dg/dg.exp
and/or gcc.dg/dg.exp.

Jakub


Re: [google gcc-4_7,gcc-4_8,integration] Add bounds checks to vector

2013-05-24 Thread Diego Novillo

On 2013-05-23 11:51 , Paul Pluzhnikov wrote:

Greetings,

This patch adds (relatively) cheap bounds and dangling checks to
vector, similar to the checks I added to vector in r195373,
r195356, etc.

Ok for google branches (gcc-4_7, gcc-4_8, integration) ?


OK.


Diego.


[v3] Couple of tiny tweaks

2013-05-24 Thread Paolo Carlini

Hi,

a couple of tiny tweaks that should reduce a bit the risk of confusions 
and subtle bugs (mostly suggested by Daniel, thanks!)


Thanks,
Paolo.


2013-05-24  Paolo Carlini  

* include/ext/type_traits.h (__is_null_pointer): Add std::nullptr_t
overload.

* include/bits/cpp_type_traits.h (__is_fundamental): Remove, unused.
Index: include/bits/cpp_type_traits.h
===
--- include/bits/cpp_type_traits.h  (revision 199306)
+++ include/bits/cpp_type_traits.h  (working copy)
@@ -327,14 +327,6 @@
 { };
 
   //
-  // A fundamental type is `void' or and arithmetic type
-  //
-  template
-struct __is_fundamental
-: public __traitor<__is_void<_Tp>, __is_arithmetic<_Tp> >
-{ };
-
-  //
   // A scalar type is an arithmetic type or a pointer type
   // 
   template
Index: include/ext/type_traits.h
===
--- include/ext/type_traits.h   (revision 199306)
+++ include/ext/type_traits.h   (working copy)
@@ -155,6 +155,11 @@
 __is_null_pointer(_Type)
 { return false; }
 
+#if __cplusplus >= 201103L
+  inline bool
+  __is_null_pointer(std::nullptr_t)
+  { return true; }
+#endif
 
   // For complex and cmath
   template::__value>


Re: [google gcc-4_7,gcc-4_8,integration] Add bounds checks to vector

2013-05-24 Thread Paul Pluzhnikov
Jonathan,

On Thu, May 23, 2013 at 10:13 AM, Paul Pluzhnikov
 wrote:
> On Thu, May 23, 2013 at 9:14 AM, Jonathan Wakely  
> wrote:
>
>> I was wondering the other day whether we should put these checks on
>> trunk and enable them automatically when !defined(__OPTIMIZE__)
>
> FWIW, we keep this under a separate macro so we can turn it on or off
> independent of other build options.
>
> Our current code looks like this:
>
> #if !defined(__google_stl_debug_vector)
> # if !defined(NDEBUG)
> #  define __google_stl_debug_vector 1
> # endif
> #endif
>
>
> Keying off NDEBUG rather than __OPTIMIZE__ seems like a more
> consistent approach -- if you want assert()s, then you probably also
> want these checks.

I'll be happy to try to push these changes into trunk, if you'd like me to.

The question is what macro(s) should guard the checks, and under what
conditions should they be turned on.

BTW, this is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56109

Thanks,
-- 
Paul Pluzhnikov


RE: [PING]RE: [patch] cilkplus: Array notation for C patch

2013-05-24 Thread Iyer, Balaji V


> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Jakub Jelinek
> Sent: Friday, May 24, 2013 2:03 PM
> To: Iyer, Balaji V
> Cc: Jeff Law; r...@redhat.com; Aldy Hernandez; 'Joseph S. Myers'; 
> 'gcc-patches'
> Subject: Re: [PING]RE: [patch] cilkplus: Array notation for C patch
> 
> On Fri, May 24, 2013 at 05:52:11PM +, Iyer, Balaji V wrote:
> > * gcc.dg/cilk-plus/AN/array_test1.c: New test.
> ...
> > * gcc.dg/cilk-plus/AN/cilkplus_AN_c.exp: New script.
> 
> Ok, I guess I can live with /AN/ extra level, but can you please move it 
> still to c-
> c++-common/cilk-plus/AN/ for all tests that can be shared with C++?  Look at 
> c-
> c++-common/ current tests, see how they can use { target c } or { target c++ }
> etc. if there is say small difference in diagnostics, but still most of the 
> test is the
> same.

> 
> I don't like the cilkplus_AN_c.exp, IMNSHO you should just have gcc.dg/cilk-
> plus/cilk-plus.exp that handles everything.  For how is it supposed to load 
> the
> files from subdirectories or how is it supposed to load 
> c-c++-common/cilk-plus/
> testcases please look at g++.dg/dg.exp and/or gcc.dg/dg.exp.

Hi Jakub,
I moved all the tests from gcc.dg/cilk-plus/AN directory to 
c-c++-common/cilk-plus/AN directory. The gcc.dg/cilk-plus directory just 
contains cilk-plus.exp script, which will handle all the tests in cilk-plus, 
not just array notation (when the others are checked in that is). Is this what 
you requested?

I apologize for misunderstanding your request.

I am attaching the fixed patch and the ChangeLogs are below:

gcc/ChangeLog
2013-05-24  Balaji V. Iyer  

* doc/extend.texi (C Extensions): Added documentation about Cilk Plus
array notation built-in reduction functions.
* doc/passes.texi (Passes): Added documentation about changes done
for Cilk Plus.
* doc/invoke.texi (C Dialect Options): Added documentation about
the -fcilkplus flag.
* Makefile.in (C_COMMON_OBJS): Added c-family/array-notation-common.o.
(BUILTINS_DEF): Depend on cilkplus.def.
* builtins.def: Include cilkplus.def.  Define DEF_CILKPLUS_BUILTIN.
* builtin-types.def: Define BT_FN_INT_PTR_PTR_PTR.
* cilkplus.def: New file.

gcc/c-family/ChangeLog
2013-05-24  Balaji V. Iyer  

* c-common.c (c_define_builtins): When cilkplus is enabled, the
function array_notation_init_builtins is called.
(c_common_init_ts): Added ARRAY_NOTATION_REF as typed.
* c-common.def (ARRAY_NOTATION_REF): New tree.
* c-common.h (build_array_notation_expr): New function declaration.
(build_array_notation_ref): Likewise.
(extract_sec_implicit_index_arg): New extern declaration.
(is_sec_implicit_index_fn): Likewise.
(ARRAY_NOTATION_CHECK): New define.
(ARRAY_NOTATION_ARRAY): Likewise.
(ARRAY_NOTATION_START): Likewise.
(ARRAY_NOTATION_LENGTH): Likewise.
(ARRAY_NOTATION_STRIDE): Likewise.
* c-pretty-print.c (pp_c_postifix_expression): Added a new case for
ARRAY_NOTATION_REF.
(pp_c_expression): Likewise.
* c.opt (flag_enable_cilkplus): New flag.
* array-notation-common.c: New file.

gcc/c/ChangeLog
2013-05-24  Balaji V. Iyer  

* c-typeck.c (build_array_ref): Added a check to see if array's
index is greater than one.  If true, then emit an error.
(build_function_call_vec): Exclude error reporting and checking
for builtin array-notation functions.
(convert_arguments): Likewise.
(c_finish_return): Added a check for array notations as a return
expression.  If true, then emit an error.
(c_finish_loop): Added a check for array notations in a loop
condition.  If true then emit an error.
(lvalue_p): Added a ARRAY_NOTATION_REF case.
(build_binary_op): Added a check for array notation expr inside
op1 and op0.  If present, we call another function to find correct
type.
* Make-lang.in (C_AND_OBJC_OBJS): Added c-array-notation.o.
* c-parser.c (c_parser_compound_statement): Check if array
notation code is used in tree, if so, then transform them into
appropriate C code.
(c_parser_expr_no_commas): Check if array notation is used in LHS
or RHS, if so, then build array notation expression instead of
regular modify.
(c_parser_postfix_expression_after_primary): Added a check for
colon(s) after square braces, if so then handle it like an array
notation.  Also, break up array notations in unary op if found.
(c_parser_direct_declarator_inner): Added a check for array
notation.
(c_parser_compound_statement): Added a check for array notation in
a stmt.  If one is present, then expand array notation expr.
(c_parser_if_statement): Likewise.

Re: [testsuite] Adding target nonpic to g++.dg/tm/pr47746.C

2013-05-24 Thread Mike Stump
On May 24, 2013, at 12:02 AM, Alexander Ivchenko  wrote:
> *ping*
> 
> 2013/4/11 Alexander Ivchenko :
>> Hi,
>> 
>> The same motivation as for:
>> http://gcc.gnu.org/ml/gcc-cvs/2013-03/msg00786.html
>> 
>> "Since -fpic option is turned on by default in Android we have certain test
>> fails. The reason for that is that those tests rely on the
>> availability of functions, defined in them
>> and with -fpic compiler conservatively assumes that they are
>> AVAIL_OVERWRITABLE."
>> 
>> In case of tm we have that in here:
>> 
>> 4461|   /* If we aren't seeing the final version of the function we don't
>> 4462|  know what it will contain at runtime.  */
>> 4463|   if (cgraph_function_body_availability (node) < AVAIL_AVAILABLE)
>> 4464+>return true;
>> 4465|
>> 
>> (gdb) p cgraph_function_body_availability (node)
>> $54 = AVAIL_OVERWRITABLE

So, normally I would just approve it.  This is the last chance to answer the 
question, is that reasonable?

So, I'd like a linker/cgraph person to say, yes, indeed, that is reasonable.  
If yes, then Ok.

I can't help but think that merely having -fpic doesn't actually change 
something like linkage or the fact something is, or is not defined.

C++ PATCH for c++/56971 (ICE with friend template and template template parameter)

2013-05-24 Thread Jason Merrill
We do in fact set TYPE_STRUCTURAL_EQUALITY_P on TEMPLATE_TEMPLATE_PARM, 
so we can't assume it isn't set.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit affd3dcbcfeeda70db2413f19948dfd039ce0a0a
Author: Jason Merrill 
Date:   Fri May 24 13:52:31 2013 -0400

	PR c++/56971
	* pt.c (any_template_arguments_need_structural_equality_p): A
	TEMPLATE_TEMPLATE_PARM can require structural type comparison.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f861f4c..fb2fe2a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20397,8 +20397,7 @@ any_template_arguments_need_structural_equality_p (tree args)
 
 	  if (error_operand_p (arg))
 		return true;
-	  else if (TREE_CODE (arg) == TEMPLATE_DECL
-		   || TREE_CODE (arg) == TEMPLATE_TEMPLATE_PARM)
+	  else if (TREE_CODE (arg) == TEMPLATE_DECL)
 		continue;
 	  else if (TYPE_P (arg) && TYPE_STRUCTURAL_EQUALITY_P (arg))
 		return true;
diff --git a/gcc/testsuite/g++.dg/template/ttp28.C b/gcc/testsuite/g++.dg/template/ttp28.C
new file mode 100644
index 000..a15dea1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ttp28.C
@@ -0,0 +1,21 @@
+// PR c++/56971
+
+template 
+class rp {
+};
+
+template  class P>
+struct b {
+template  class FriendP>
+friend void f(b from);
+};
+
+template  class P>
+void f(b from) {
+}
+
+int main() {
+b v;
+f(v);
+return 0;
+}


Re: [patch] Default to --enable-libstdcxx-time=auto

2013-05-24 Thread Jakub Jelinek
On Fri, May 24, 2013 at 04:22:43PM +0100, Jonathan Wakely wrote:
> On 24 May 2013 16:03, Jakub Jelinek wrote:
> >
> > So, adjusted patches attached, ok for trunk/4.8 if they pass
> > bootstrap/regtest?
> 
> Yes, they're OK - thanks for sorting it out.

Note, I've already committed the patches, but further testing using
#include 
#include 

int
main()
{
  using namespace std::chrono;
  steady_clock::time_point t1 = steady_clock::now();
  sleep (2);
  steady_clock::time_point t2 = steady_clock::now();
  auto d1 = t1.time_since_epoch ();
  auto d2 = t2.time_since_epoch ();
  long long l1 = d1.count ();
  long long l2 = d1.zero ().count ();
  long long l3 = d1.min ().count ();
  long long l4 = d1.max ().count ();
  long long l5 = d2.count ();
  __builtin_printf ("%lld %lld %lld %lld %lld %lld\n", l1, l2, l3, l4, l5, l5 - 
l1);
  system_clock::time_point t3 = system_clock::now();
  sleep (2);
  system_clock::time_point t4 = system_clock::now();
  auto d3 = t3.time_since_epoch ();
  auto d4 = t4.time_since_epoch ();
  l1 = d3.count ();
  l2 = d3.zero ().count ();
  l3 = d3.min ().count ();
  l4 = d3.max ().count ();
  l5 = d4.count ();
  __builtin_printf ("%lld %lld %lld %lld %lld %lld\n", l1, l2, l3, l4, l5, l5 - 
l1);
  return 0;
}

seems to point at another possible serious ABI issue.

g++ 4.7 compiled, linked and run against:
1369424708027221 0 -9223372036854775808 9223372036854775807 1369424710027308 
287
1369424710027397 0 -9223372036854775808 9223372036854775807 1369424712027522 
2000125
g++ 4.8 head (with the patch) with
-   if test x"$ac_has_clock_monotonic_syscall" = x"yes"; then
+   if test x"$ac_has_clock_monotonic_syscall" = x"yesz"; then
in configure (thus, typedef system_clock steady_clock; plus
steady_clock::now() in libstdc++):
1369424714156881 0 -9223372036854775808 9223372036854775807 1369424716157039 
2000158
1369424716157108 0 -9223372036854775808 9223372036854775807 1369424718157236 
2000128
g++ 4.8 head (with the patch):
1421990971125719 0 -9223372036854775808 9223372036854775807 1421992971246052 
2000120333
1369424821707660285 0 -9223372036854775808 9223372036854775807 
1369424823707805952 2000145667
g++ 4.8 head compiled, but run against libstdc++ built with that configure hack:
1369424720776367000 0 -9223372036854775808 9223372036854775807 
1369424722776515000 2000148000
1369424722776583 0 -9223372036854775808 9223372036854775807 1369424724776704 
2000121
4.7 compiled, run against 4.8 head libstdc++.so:
1369425485748333050 0 -9223372036854775808 9223372036854775807 
1369425487748453585 2000120535
1369425487748521770 0 -9223372036854775808 9223372036854775807 
1369425489748695701 2000173931
4.7 compiled, run against 4.8 head with configure hack libstdc++.so:
1369425496792688 0 -9223372036854775808 9223372036854775807 1369425498792910 
2000222
1369425498792966 0 -9223372036854775808 9223372036854775807 1369425500793089 
2000123

So, there is a minor issue that what is std::chrono::steady_clock has
changed, if you say use it as a function parameter, it will mangle
differently before/after.  Guess not that big a deal, after all, C++11
support is still experimental, right?

But the more important issue is that std::chrono::system_clock broke,
code compiled against the old headers will assume
std::chrono::system_clock::duration is microseconds resolution on Linux,
while code compiled against the new headers will assume it is in
nanoseconds resolution.  That is because of:
#ifdef _GLIBCXX_USE_CLOCK_REALTIME
  typedef chrono::nanoseconds   duration;
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
  typedef chrono::microseconds  duration;
#else
  typedef chrono::seconds   duration;
#endif

Thus, I'm afraid we can't ABI compatibly change either of these macros,
unless we e.g. keep old std::chrono::system_clock as is and introduce
std::chrono::__whatever::system_clock or whatever, that will be typedefed
as std::chrono::system_clock.  Is it a big issue if system_clock will have
just old resolution (usec) and =auto code is reverted to only tweak
steady_clock (aka. _GLIBCXX_USE_CLOCK_MONOTONIC) (then for 4.8 the change
would be just to drop
  ac_has_clock_realtime=yes
line from if test x"$ac_has_clock_monotonic_syscall" = x"yes"; then)?

Ugh, C++ and ABI doesn't go well together...

Jakub


  1   2   >