Re: [PATCH][AArch64] Specify CRC and Crypto support for Cortex-A53, A57

2014-01-23 Thread Kyrill Tkachov

On 16/01/14 18:10, Kyrill Tkachov wrote:

Hi all,

The Cortex-A53 and Cortex-A57 cores support the CRC32 and Crypto extensions to
the ARMv8-A architecture. This patch adds that information to their definitions
in aarch64-cores.def.

Tested aarch64-none-elf with no regressions.

Ok for trunk? (or next stage1)?

Thanks,
Kyrill

2014-01-16  Kyrylo Tkachov  

  * config/aarch64/aarch64-cores.def (cortex-a53): Specify CRC32
  and crypto support.
  (cortex-a57): Likewise.
  (cortex-a57.cortex-a53): Likewise.


Ping.

Kyrill



Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-23 Thread Marek Polacek
Ping.

On Thu, Jan 16, 2014 at 07:52:43PM +0100, Marek Polacek wrote:
> On Wed, Jan 15, 2014 at 09:23:06PM +, Joseph S. Myers wrote:
> > On Wed, 15 Jan 2014, Marek Polacek wrote:
> > 
> > > +/* Return true if T is a pointer to a zero-sized struct/union.  */
> > > +
> > > +bool
> > > +pointer_to_zero_sized_aggr_p (tree t)
> > > +{
> > > +  t = strip_pointer_operator (t);
> > > +  return ((RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE)
> > > +   && TYPE_SIZE (t)
> > > +   && integer_zerop (TYPE_SIZE (t)));
> > 
> > Why have the (RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ARRAY_TYPE) 
> > check at all?  It may well be the case that those are the only kinds of 
> > types that can have zero size here, but the principle of this error 
> > applies to anything with zero size so it would seem best not to have that 
> > part of the check at all.
> 
> Ok, changed.
>  
> > strip_pointer_operator seems wrong here.  It recursively removes an 
> > arbitrary number of pointer type derivations - but where the types are 
> > pointer to pointer to zero-size, arithmetic is perfectly valid (so you 
> > should have a test that such cases are still accepted, where this patch 
> > version would have rejected them).  I believe this function should return 
> > true if the argument is a pointer (to anything) and after removal of 
> > exactly one level of pointer type derivation, the result has zero size 
> > (constant zero - also add a test that the array case where the size is a 
> > const int initialized to 0 is not, for C, rejected, as those are VLAs in C 
> > terms).
> 
> Ah, right, sorry about that.  Hopefully all done in the following.
> The if (!POINTER_TYPE_P (t)) check in pointer_to_zero_sized_aggr_p
> could perhaps go; I added it mostly for paranoia sake.
> 
> 2014-01-16  Marek Polacek  
> 
>   PR c/58346
> c-family/
>   * c-common.c (pointer_to_zero_sized_aggr_p): New function.
>   * c-common.h: Declare it.
> cp/
>   * typeck.c (pointer_diff): Give an error on arithmetic on pointer to
>   an empty aggregate.
> c/
>   * c-typeck.c (pointer_diff): Give an error on arithmetic on pointer to
>   an empty aggregate.
> testsuite/
>   * c-c++-common/pr58346-1.c: New test.
>   * c-c++-common/pr58346-2.c: New test.
>   * c-c++-common/pr58346-3.c: New test.
> 
> --- gcc/c-family/c-common.h.mp2014-01-15 11:24:41.438608787 +0100
> +++ gcc/c-family/c-common.h   2014-01-16 16:40:06.105688048 +0100
> @@ -789,6 +789,7 @@ extern bool keyword_is_storage_class_spe
>  extern bool keyword_is_type_qualifier (enum rid);
>  extern bool keyword_is_decl_specifier (enum rid);
>  extern bool cxx_fundamental_alignment_p (unsigned);
> +extern bool pointer_to_zero_sized_aggr_p (tree);
>  
>  #define c_sizeof(LOC, T)  c_sizeof_or_alignof_type (LOC, T, true, false, 1)
>  #define c_alignof(LOC, T) c_sizeof_or_alignof_type (LOC, T, false, false, 1)
> --- gcc/c-family/c-common.c.mp2014-01-16 16:39:17.093487218 +0100
> +++ gcc/c-family/c-common.c   2014-01-16 17:15:37.466403444 +0100
> @@ -11823,4 +11823,15 @@ cxx_fundamental_alignment_p  (unsigned a
>TYPE_ALIGN (long_double_type_node)));
>  }
>  
> +/* Return true if T is a pointer to a zero-sized aggregate.  */
> +
> +bool
> +pointer_to_zero_sized_aggr_p (tree t)
> +{
> +  if (!POINTER_TYPE_P (t))
> +return false;
> +  t = TREE_TYPE (t);
> +  return (TYPE_SIZE (t) && integer_zerop (TYPE_SIZE (t)));
> +}
> +
>  #include "gt-c-family-c-common.h"
> --- gcc/cp/typeck.c.mp2014-01-15 11:24:48.940639724 +0100
> +++ gcc/cp/typeck.c   2014-01-16 16:40:06.120688120 +0100
> @@ -5043,6 +5043,14 @@ pointer_diff (tree op0, tree op1, tree p
>   return error_mark_node;
>  }
>  
> +  if (pointer_to_zero_sized_aggr_p (TREE_TYPE (op1)))
> +{
> +  if (complain & tf_error)
> + error ("arithmetic on pointer to an empty aggregate");
> +  else
> + return error_mark_node;
> +}
> +
>op1 = (TYPE_PTROB_P (ptrtype)
>? size_in_bytes (target_type)
>: integer_one_node);
> --- gcc/c/c-typeck.c.mp   2014-01-15 11:24:53.699659333 +0100
> +++ gcc/c/c-typeck.c  2014-01-16 16:40:06.130688170 +0100
> @@ -3536,6 +3536,9 @@ pointer_diff (location_t loc, tree op0,
>/* This generates an error if op0 is pointer to incomplete type.  */
>op1 = c_size_in_bytes (target_type);
>  
> +  if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
> +error_at (loc, "arithmetic on pointer to an empty aggregate");
> +
>/* Divide by the size, in easiest possible way.  */
>result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
>   op0, convert (inttype, op1));
> --- gcc/testsuite/c-c++-common/pr58346-3.c.mp 2014-01-16 17:13:26.184800572 
> +0100
> +++ gcc/testsuite/c-c++-common/pr58346-3.c2014-01-16 17:30:15.503506328 
> +0100
> @@ -0,0 +1,16 @@
> +/* PR c/58346 */
> +/* { dg-do compile } */
> +
> +void
> +foo (void)
> +{
> +  __PTRDIFF_TYPE__ d;
> +  

Re: [PATCH] fix for PR 59825

2014-01-23 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 10:40:31PM +, Iyer, Balaji V wrote:
> --- a/gcc/c/c-array-notation.c
> +++ b/gcc/c/c-array-notation.c
> @@ -1218,22 +1218,22 @@ fix_return_expr (tree expr)
>return new_mod_list;
>  }
>  
> -/* Walks through tree node T and find all the call-statements that do not 
> return
> -   anything and fix up any array notations they may carry.  The return value
> -   is the same type as T but with all array notations replaced with 
> appropriate
> -   STATEMENT_LISTS.  */
> +/* Callback for walk_tree.  Expands all array notations in *TP.  
> *WALK_SUBTREES
> +   is set to 1 unless *TP contains no array notation expressions.  Parameter 
> +   D is unused.  */
>  
> -tree
> -expand_array_notation_exprs (tree t)
> +static tree
> +expand_array_notations (tree *tp, int *walk_subtrees, void *d 
> ATTRIBUTE_UNUSED)

As we are now using C++, just use
expand_array_notations (tree *tp, int *walk_subtrees, void *)
and remove the comment about unused parameter D.

>  {
> -  if (!contains_array_notation_expr (t))
> -return t;
> +  if (!contains_array_notation_expr (*tp))

Why do you want to walk the whole subtree once more at every level?
That has bad time complexity for very deep trees.
Can't you just do that in expand_array_notations_exprs once?

Jakub


Re: FW: [GOMP4][PATCH] SIMD-enabled functions (formerly Elemental functions) for C++

2014-01-23 Thread Jakub Jelinek
On Mon, Jan 20, 2014 at 03:42:02AM +, Iyer, Balaji V wrote:
> I forgot to add the 2 changelog entries for decl.c and pt.c. The patch is 
> attached again with the corrected Changelogs.

This is ok for trunk, thanks.

Jakub


Re: [C++ patch] PR 59482

2014-01-23 Thread Paolo Carlini

Hi,

On 01/22/2014 11:38 PM, Ville Voutilainen wrote:

Oh, I was expecting Jason would do that. Note that Marek Polacek pointed
out two formatting issues:
- comments should have full stop and two spaces at the end

Yes, will fix in my next commit touching that file.

- also two spaces before  in the ChangeLog

I took care of this when I applied the patch.

Thanks,
Paolo.


Re: Reload codegen improvement

2014-01-23 Thread Chung-Lin Tang
On 14/1/8 12:22 AM, Bernd Schmidt wrote:
> This fixes a problem identified by Chung-Lin. Once reload is done, all
> equivalencing insns for pseudos that didn't get a hard reg but could be
> eliminated using their REG_EQUIV are deleted. However, we still can
> produce reloads and reload insns for them in certain cases, leading to
> unnecessary spilling. This patch corrects this by making sure we use
> identical tests when deciding whether to ignore an insn while reloading,
> and whether to delete it afterwards.
> 
> Bootstrapped and tested on x86_64-linux (with lra_p disabled). Chung-Lin
> says he's tested it as well, I think on arm (probably with something 4.8
> based). Will commit in a few days if no objections.
> 
> 
> Bernd

Hi Bernd, this does not seem to be committed yet.

Thanks,
Chung-Lin



Re: [PATCH][AVX512] Add forgotten intrinsics.

2014-01-23 Thread Ilya Tocar
> >> > I found out that we forgot to implement some of AVX512 intrinsics.
> >> > Here is a patch that adds them. Sorry for huge patch, but changes are
> >> > mostly trivial.
> >> > Ok for trunk?
...
> >>
> >> This is the same as the second alternative of the
> >> avx512f_2_mask pattern. Please change the above
> >> into an expander to reuse existing pattern.
> >>
> >> Uros.
> >
> > Fixed.
> 
> OK for mainline if tested properly (you didn't say how the patch was tested).
>
Yeah, it bootstraps, passes make-check, runs spec2006.
I'll ask Kirill to commit, thanks.


Re: [PATCH] _Cilk_for for C and C++

2014-01-23 Thread Jakub Jelinek
On Sun, Jan 19, 2014 at 04:50:39AM +, Iyer, Balaji V wrote:
> I have answered your questions below. In addition to your changes, I have
> also fixed the issues Aldy pointed out and have answered his questions in
> that thread.  With this email I have attached two patches and 2
> change-logs (for C and C++).  I have also rebased these patches to the
> trunk revision (r206756)

Haven't looked at the patch yet, just applied and looked what it generates:

Say in cilk_fors.c -O2 -fcilkplus -std=c99 
-fdump-tree-{original,gimple,omplower,ompexp}
I'm seeing in *.original dump:
<<< Unknown tree: cilk_for
which suggests that tree-pretty-print.c doesn't handle CILK_FOR.

Much more important is what is seen in the *.gimple dump though:
   schedule(runtime,0) private(ii)
  _Cilk_for (ii = 0; ii <= 9; ii = ii + 1)
{
  #pragma omp parallel shared(__cilk_incr.0) shared(__cilk_cond.2) 
shared(__cilk_init.1) shared(ii) shared(Array)
{
  Array[ii] = 1133;
}
}
Why do you put the parallel inside of _Cilk_for rather than the other way
around?  That looks just wrong.  That would represent runtime scheduling of
work across the parallel regions at the _Cilk_for, and then in each
iteration running the body in several threads concurrently.
You want the parallel around the _Cilk_for, and
gimple_omp_parallel_set_combined_p (parallel_stmt, true) so that you can
then handle it specially during omp lowering/expansion.

Also, the printing of _Cilk_for is weird, the clauses (with space before)
look really weird above the _Cilk_for when there is no #pragma or something
similar.  Perhaps print the clauses after _Cilk_for?
  _Cilk_for (ii = 0; ii <= 9; ii = ii + 1) schedule(runtime,0) private(ii)
?

Jakub


Re: [PATCH] fix for PR 59825

2014-01-23 Thread Jakub Jelinek
On Thu, Jan 23, 2014 at 10:27:58AM +0100, Jakub Jelinek wrote:
> On Mon, Jan 20, 2014 at 10:40:31PM +, Iyer, Balaji V wrote:
> > --- a/gcc/c/c-array-notation.c
> > +++ b/gcc/c/c-array-notation.c
> > @@ -1218,22 +1218,22 @@ fix_return_expr (tree expr)
> >return new_mod_list;
> >  }
> >  
> > -/* Walks through tree node T and find all the call-statements that do not 
> > return
> > -   anything and fix up any array notations they may carry.  The return 
> > value
> > -   is the same type as T but with all array notations replaced with 
> > appropriate
> > -   STATEMENT_LISTS.  */
> > +/* Callback for walk_tree.  Expands all array notations in *TP.  
> > *WALK_SUBTREES
> > +   is set to 1 unless *TP contains no array notation expressions.  
> > Parameter 
> > +   D is unused.  */
> >  
> > -tree
> > -expand_array_notation_exprs (tree t)
> > +static tree
> > +expand_array_notations (tree *tp, int *walk_subtrees, void *d 
> > ATTRIBUTE_UNUSED)
> 
> As we are now using C++, just use
> expand_array_notations (tree *tp, int *walk_subtrees, void *)
> and remove the comment about unused parameter D.
> 
> >  {
> > -  if (!contains_array_notation_expr (t))
> > -return t;
> > +  if (!contains_array_notation_expr (*tp))
> 
> Why do you want to walk the whole subtree once more at every level?
> That has bad time complexity for very deep trees.
> Can't you just do that in expand_array_notations_exprs once?

Though, as this is not a regression with this patch and the patch fixes
a bug in the testsuite, perhaps you can do that incrementally.

So, can you please change the comment and expand_array_notations
prototype, then commit (patch preapproved)?

Then please add to todo list that walking all subtrees twice at every level
is something you should avoid.  Perhaps for the trees you don't explictly
handle you could gather in *(bool *)d whether it contained any array
notations, and trees you actually handle could first walk the subtrees
manually to gather the flags and transform what needs to be transformed in
there, and then just based on the bool flag decide if it should do anything
and what.  Also, how is e.g. array notation supposed to be handled in case
of nested MODIFY_EXPRs where the nested MODIFY_EXPRs contain array
notations?  I mean something like:
a[0:10] = (b[0:10] ? (c[0:10] = d[0:10] + (e[0:10] = f[0:10] ? (g[0:10] * 3 : 
g[0:10] + 12))) : 5);
etc.?
I'd say contains_array_notation_expr should also be rewritten to use
walk_tree, so should be the C++ AN expansion etc.  Just you'll need to
use cp_walk_tree for C++ probably and thus the c-family/ code should just
contain callbacks that you can use for the walking, not the actual calls
to walk_tree/cp_walk_tree.

Jakub


Re: [Patch, fortran] PR59414 [4.8/4.9 Regression] [OOP] ICE in in gfc_conv_expr_descriptor on ALLOCATE inside SELECT TYPE

2014-01-23 Thread Paul Richard Thomas
Dear Janus,

snip

> well, actually the selector in the test case is not an array. And
> polymorphic arrays as such have been supported since 4.7.

duuh!  Shows how time flies when you're having fun!
>
>> Bootstrapped and regtested on FC17/x86_64 - OK for trunk and, after a
>> decent delay, 4.8?
>
> Yes, looks good to me. Thanks for the patch!

Thanks for the review.
>
>
>> PS I know of at least one other place where this manoeuvre had to be
>> done.  If I find a third, I will turn it into a function in class.c.
>> It might be worth doing anyway?
>
> I tend to agree. Up to you ...

I am debugging such a function but, for reasons that I have not yet
found, it recovers the original ICE :-(

Elsewhere, I have implemented the same removal of references in the
TREE_SSA representation for which there is a helper function.  I must
check if that is not possible here.

Cheers

Paul

>
> Cheers,
> Janus
>
>
>
>> 2014-01-20  Paul Thomas  
>>
>> PR fortran/59414
>> * trans-stmt.c (gfc_trans_allocate): Before the pointer
>> assignment to transfer the source _vptr to a class allocate
>> expression, the final class reference should be exposed. The
>> tail that includes the _data and array references is stored.
>> This reduced expression is transferred to 'lhs' and the _vptr
>> added. Then the tail is restored to the allocate expression.
>>
>> 2014-01-20  Paul Thomas  
>>
>> PR fortran/59414
>> * gfortran.dg/allocate_class_3.f90 : New test



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
   --Hitchhikers Guide to the Galaxy


[build] PR 43538: Don't overwrite CXXFLAGS_FOR_TARGET in config/mt-gnu

2014-01-23 Thread Marc Glisse

Hello,

although setting CFLAGS_FOR_TARGET before compiling gcc works fine, 
CXXFLAGS_FOR_TARGET is ignored. I don't see any good reason for that.


I tested the patch by doing a regular bootstrap+testsuite on 
x86_64-unknown-linux-gnu. I also did a non-bootstrap build where I set 
CXXFLAGS_FOR_TARGET and checked that it now propagates to libstdc++ and 
others.


config/ChangeLog:

2014-01-23  Marc Glisse  

PR target/43538
* mt-gnu: Don't reset CXXFLAGS_FOR_TARGET.

--
Marc GlisseIndex: config/mt-gnu
===
--- config/mt-gnu   (revision 206958)
+++ config/mt-gnu   (working copy)
@@ -1 +1 @@
-CXXFLAGS_FOR_TARGET = $(CXXFLAGS) -D_GNU_SOURCE
+CXXFLAGS_FOR_TARGET += -D_GNU_SOURCE


[PING] Fix test case vect-nop-move.c

2014-01-23 Thread Bernd Edlinger
Hi,

this might be almost obvious?

Thanks
Bernd.

> Date: Mon, 13 Jan 2014 12:13:53 +0100
>
> Hello,
>
> there is another test case, that misses the necessary check_vect() runtime 
> check.
>
> Tested on i686-pc-linux-gnu.
> OK for trunk?
>
> Regards
> Bernd.  

patch-vect-nop-move.diff
Description: Binary data


Re: [PING] Fix test case vect-nop-move.c

2014-01-23 Thread Jakub Jelinek
On Thu, Jan 23, 2014 at 12:49:06PM +0100, Bernd Edlinger wrote:
> Hi,
> 
> this might be almost obvious?

No, check_vect () has to preceed all the vector statements in main, or
often even better if main contains just check_vect () call and call to
some other noinline routine that has the vector stuff in it.
Otherwise, the test might crash on vector insns already before calling
check_vect.

Jakub


Re: [PATCH][AArch64] Vector shift by 64 fix

2014-01-23 Thread Marcus Shawcroft
On 6 January 2014 11:52, Alex Velenko  wrote:
> Hi,
>
> This patch fixes vector shift by 64 behavior to meet reference
> manual expectations. Testcase included to check that expectations
> are now met. No regressions found.
>
> Is patch OK?

OK
/Marcus


[PATCH] Fix for PR57316 (avoid building sanitizer on old kernels)

2014-01-23 Thread Yury Gribov

Hi,

Attached patch disables libsanitizer on older Linux distribs which lack 
necessary syscalls (see 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57316 for more details).


Bootstrapped/regtested on x64.

Ok to commit?

--
Best regards,
Yury Gribov
2014-01-22  ygribov  

	sanitizer/PR57316
	* configure.ac: Check for missing syscalls.
	* Makefile.am: Likewise.
	* configure: Regenerate.
	* Makefile.in: Regenerate.

diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index a17f7b6..b0dc582 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -1,5 +1,6 @@
 ACLOCAL_AMFLAGS = -I .. -I ../config
 
+if SANITIZER_SUPPORTED
 SUBDIRS = sanitizer_common
 if !USING_MAC_INTERPOSE
 SUBDIRS += interception
@@ -11,6 +12,7 @@ SUBDIRS += lsan asan ubsan
 if TSAN_SUPPORTED
 SUBDIRS += tsan
 endif
+endif
 
 ## May be used by toolexeclibdir.
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
index 5a33e0e..60cbe2e 100644
--- a/libsanitizer/Makefile.in
+++ b/libsanitizer/Makefile.in
@@ -35,9 +35,9 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception
-@LIBBACKTRACE_SUPPORTED_TRUE@am__append_2 = libbacktrace
-@TSAN_SUPPORTED_TRUE@am__append_3 = tsan
+@SANITIZER_SUPPORTED_TRUE@@USING_MAC_INTERPOSE_FALSE@am__append_1 = interception
+@LIBBACKTRACE_SUPPORTED_TRUE@@SANITIZER_SUPPORTED_TRUE@am__append_2 = libbacktrace
+@SANITIZER_SUPPORTED_TRUE@@TSAN_SUPPORTED_TRUE@am__append_3 = tsan
 subdir = .
 DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
@@ -250,8 +250,9 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I .. -I ../config
-SUBDIRS = sanitizer_common $(am__append_1) $(am__append_2) lsan asan \
-	ubsan $(am__append_3)
+@SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_1) \
+@SANITIZER_SUPPORTED_TRUE@	$(am__append_2) lsan asan ubsan \
+@SANITIZER_SUPPORTED_TRUE@	$(am__append_3)
 gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
 
 # Work around what appears to be a GNU make bug handling MAKEFLAGS
diff --git a/libsanitizer/configure b/libsanitizer/configure
index c207359..5e4840f 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -612,6 +612,8 @@ ALLOC_FILE
 VIEW_FILE
 BACKTRACE_SUPPORTED
 FORMAT_FILE
+SANITIZER_SUPPORTED_FALSE
+SANITIZER_SUPPORTED_TRUE
 USING_MAC_INTERPOSE_FALSE
 USING_MAC_INTERPOSE_TRUE
 link_liblsan
@@ -12017,7 +12019,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12020 "configure"
+#line 12022 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12123,7 +12125,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12126 "configure"
+#line 12128 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15586,6 +15588,47 @@ fi
 
 backtrace_supported=yes
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for necessary platform features" >&5
+$as_echo_n "checking for necessary platform features... " >&6; }
+case "$target" in
+  *-*-linux*)
+# Some old Linux distributions miss required syscalls.
+sanitizer_supported=no
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include 
+int
+main ()
+{
+
+  syscall (__NR_gettid);
+  syscall (__NR_futex);
+  syscall (__NR_exit_group);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  sanitizer_supported=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+;;
+  *)
+sanitizer_supported=yes
+;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sanitizer_supported" >&5
+$as_echo "$sanitizer_supported" >&6; }
+ if test "$sanitizer_supported" = yes; then
+  SANITIZER_SUPPORTED_TRUE=
+  SANITIZER_SUPPORTED_FALSE='#'
+else
+  SANITIZER_SUPPORTED_TRUE='#'
+  SANITIZER_SUPPORTED_FALSE=
+fi
+
+
 # Test for __sync support.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking __sync extensions" >&5
 $as_echo_n "checking __sync extensions... " >&6; }
@@ -16456,6 +16499,10 @@ if test -z "${USING_MAC_INTERPOSE_TRUE}" && test -z "${USING_MAC_INTERPOSE_FALSE
   as_fn_error "conditional \"USING_MAC_INTERPOSE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${SANITIZER_SUPPORTED_TRUE}" && test -z "${SANITIZER_SUPPORTED_FALSE}"; then
+  as_fn_error "conditional \"SANITIZER_SUPPORTED\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${LIBBACKTRACE_SUPPORTED_TRUE}" && test -z "${LIBBACKTRACE_SUPPORTED_FALSE}"; then
   as_fn_error "conditional \"LIBBACKTRACE_SUPPORTED\" was never defined.
 Usually this means the mac

[patch] Update libstdc++ FAQ

2014-01-23 Thread Jonathan Wakely

This expands the FAQ answer on dynamic linking, to be more explicit
for people who don't understand the concepts. It also corrects an
incorrect symver in abi.xml

* doc/xml/faq.xml (a-how_to_set_paths): Expand FAQ answer.
* doc/xml/manual/abi.xml (abi.versioning.history): Correct symver.

Tested with doc-xml-validate-docbook and doc-html-docbook, comitted to
trunk.

commit 130bb045a16d0054290641c94a6c6b6948adc9e5
Author: Jonathan Wakely 
Date:   Thu Jan 23 12:22:16 2014 +

* doc/xml/faq.xml (a-how_to_set_paths): Expand FAQ answer.
* doc/xml/manual/abi.xml (abi.versioning.history): Correct symver.

diff --git a/libstdc++-v3/doc/xml/faq.xml b/libstdc++-v3/doc/xml/faq.xml
index 501f161..b4a53a2 100644
--- a/libstdc++-v3/doc/xml/faq.xml
+++ b/libstdc++-v3/doc/xml/faq.xml
@@ -344,7 +344,7 @@
 
 Depending on your platform and library version, the error message might
 be similar to one of the following:
- 
+
 
 
 ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open 
shared object file: No such file or directory
@@ -358,11 +358,34 @@
 executable is run the linker finds and loads the required shared
 libraries by searching a pre-configured list of directories. If
 the directory where you've installed libstdc++ is not in this list
-then the libraries won't be found. The simplest way to fix this is
+then the libraries won't be found.
+
+
+
+If you already have an older version of libstdc++ installed then the
+error might look like one of the following instead:
+
+
+
+./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found
+./a.out: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found
+
+
+
+This means the linker found /usr/lib/libstdc++.so.6
+but that library belongs to an older version of GCC than was used to
+compile and link the program a.out (or some part
+of it). The program depends on code defined in the newer libstdc++
+that belongs to the newer version of GCC, so the linker must be told
+how to find the newer libstdc++ shared library.
+
+
+
+The simplest way to fix this is
 to use the LD_LIBRARY_PATH environment variable,
 which is a colon-separated list of directories in which the linker
 will search for shared libraries:
- 
+
 
 
 LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH
@@ -370,6 +393,11 @@
 
 
 
+Here the shell variable ${prefix} is assumed to contain
+the directory prefix where GCC was installed to. The directory containing
+the library might depend on whether you want the 32-bit or 64-bit copy
+of the library, so for example would be
+${prefix}/lib64 on some systems.
 The exact environment variable to use will depend on your
 platform, e.g. DYLD_LIBRARY_PATH for Darwin,
 LD_LIBRARY_PATH_32/LD_LIBRARY_PATH_64 for Solaris 32-/64-bit
@@ -379,7 +407,8 @@
 See the man pages for ld, ldd
 and ldconfig for more information. The dynamic
 linker has different names on different platforms but the man page
-is usually called something such as ld.so/rtld/dld.so.
+is usually called something such as ld.so,
+rtld or dld.so.
 
 
 Using LD_LIBRARY_PATH is not always the best solution, Finding Dynamic or Shared
diff --git a/libstdc++-v3/doc/xml/manual/abi.xml 
b/libstdc++-v3/doc/xml/manual/abi.xml
index 25d1b30..d1c622c 100644
--- a/libstdc++-v3/doc/xml/manual/abi.xml
+++ b/libstdc++-v3/doc/xml/manual/abi.xml
@@ -328,7 +328,7 @@ compatible.
 GCC 4.7.0: GLIBCXX_3.4.17, CXXABI_1.3.6
 GCC 4.8.0: GLIBCXX_3.4.18, CXXABI_1.3.7
 GCC 4.8.3: GLIBCXX_3.4.19, CXXABI_1.3.7
-GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.7
+GCC 4.9.0: GLIBCXX_3.4.20, CXXABI_1.3.8
 
 
 


Re: [PATCH] Fix use-after-return-1.c

2014-01-23 Thread Maxim Ostapenko

Mike Stump wrote:

This patch fixes c-c++-common/asan/use-after-return-1.c not to fail on darwin 
target (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59897).

Ok to commit?


Ok.


Commited in 206961.

-Maxim.



Re: [PATCH] Fix for PR57316 (avoid building sanitizer on old kernels)

2014-01-23 Thread Jakub Jelinek
On Thu, Jan 23, 2014 at 04:33:28PM +0400, Yury Gribov wrote:
> Attached patch disables libsanitizer on older Linux distribs which
> lack necessary syscalls (see
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57316 for more details).
> 
> Bootstrapped/regtested on x64.
> 
> Ok to commit?

Ok, thanks, but:

> 2014-01-22  ygribov  

Put your real name here instead.

>   sanitizer/PR57316

PR sanitizer/57316

>   * configure.ac: Check for missing syscalls.
>   * Makefile.am: Likewise.
>   * configure: Regenerate.
>   * Makefile.in: Regenerate.

Jakub


Re: Reload codegen improvement

2014-01-23 Thread Bernd Schmidt

On 01/23/2014 10:44 AM, Chung-Lin Tang wrote:

On 14/1/8 12:22 AM, Bernd Schmidt wrote:

This fixes a problem identified by Chung-Lin. Once reload is done, all
equivalencing insns for pseudos that didn't get a hard reg but could be
eliminated using their REG_EQUIV are deleted. However, we still can
produce reloads and reload insns for them in certain cases, leading to
unnecessary spilling. This patch corrects this by making sure we use
identical tests when deciding whether to ignore an insn while reloading,
and whether to delete it afterwards.

Bootstrapped and tested on x86_64-linux (with lra_p disabled). Chung-Lin
says he's tested it as well, I think on arm (probably with something 4.8
based). Will commit in a few days if no objections.


Hi Bernd, this does not seem to be committed yet.


Yeah - I decided this probably ought to wait for stage 1.


Bernd




Re: [PATCH i386 11/8] [AVX512] [2/2] Add missing packed PF gathers/scatters.

2014-01-23 Thread Uros Bizjak
On Tue, Jan 21, 2014 at 7:52 PM, Kirill Yukhin  wrote:
> Hello,
> This is non-trivial part of the patch.
>
>> On 15 Jan 20:53, Uros Bizjak wrote:
>> On Tue, Jan 14, 2014 at 7:13 AM, Kirill Yukhin  
>> wrote:
>> Did you try to add DF/SF mode to the unspec? I am not familiar with
>> this insn, but shouldn't the mode of mem access be somehow similar to
>> the avx512f_scattersi access?
> avx512f_scattersi is different in its appearence.
> It has explicit type of destination which discriminates SF/DF modes. 
> Prefetches
> has no such.
>
>> Also, you can use double macroization with MODEF iterator for SF and DFmode.
> I think I cannot. Because DF/SF types of the insn incurs different vidx 
> iterators.
> E.g.:
> Currently we have for SF:
> (define_expand "avx512pf_scatterpfsf"
>   [(unspec
>  [(match_operand: 0 "register_or_constm1_operand")
>   (mem:SF
> (match_par_dup 5
>   [(match_operand 2 "vsib_address_operand")
>(match_operand:VI48_512 1 "register_operand")
>(match_operand:SI 3 "const1248_operand")]))
>   (match_operand:SI 4 "const_0_to_1_operand")]
>  UNSPEC_SCATTER_PREFETCH)]
>
> and for DF:
> (define_expand "avx512pf_scatterpfdf"
>   [(unspec
>  [(match_operand: 0 "register_or_constm1_operand")
>   (mem:DF
>(match_par_dup 5
>  [(match_operand 2 "vsib_address_operand")
>   (match_operand:VI4_256_8_512 1 "register_operand")
>   (match_operand:SI 3 "const1248_operand")]))
>   (match_operand:SI 4 "const_0_to_1_operand")]
>  UNSPEC_SCATTER_PREFETCH)]
>
> We have this correspondence between, say, main and index modes:
>   SF -> (V16SI, V8DI)
>   DF -> (V8SI , V8DI)

It looks to me that you should use V16SF and V8DF instead of SF and DF
modes here.

Other than this, the patch looks OK to me. Please wait a day if Jakub
has any remark here.

Thanks,
Uros.


[committed] Fix OpenMP reduction with _Complex vars (PR middle-end/58809)

2014-01-23 Thread Jakub Jelinek
Hi!

&/|/^ are all rejected for _Complex vars, both floating and integral,
thus OpenMP &/|/^/min/max reductions should be rejected for those vars
similarly.  In OpenMP 4.1 hopefully they'll be allowed for user defined
reductions at least, but they aren't right now.

Below is trunk patch I've committed after testing on x86_64-linux,
attached 4.8 version of the patch.

2014-01-23  Jakub Jelinek  

PR middle-end/58809
* c-typeck.c (c_finish_omp_clause): Reject MIN_EXPR, MAX_EXPR,
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* semantics.c (finish_omp_reduction_clause): Reject
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* c-c++-common/gomp/pr58809.c: New test.

--- gcc/c/c-typeck.c.jj 2014-01-23 10:53:02.0 +0100
+++ gcc/c/c-typeck.c2014-01-23 13:13:11.268227493 +0100
@@ -11713,7 +11713,8 @@ c_finish_omp_clauses (tree clauses)
  need_implicitly_determined = true;
  t = OMP_CLAUSE_DECL (c);
  if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
- && FLOAT_TYPE_P (TREE_TYPE (t)))
+ && (FLOAT_TYPE_P (TREE_TYPE (t))
+ || TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE))
{
  enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
  const char *r_name = NULL;
@@ -11723,8 +11724,14 @@ c_finish_omp_clauses (tree clauses)
case PLUS_EXPR:
case MULT_EXPR:
case MINUS_EXPR:
+ break;
case MIN_EXPR:
+ if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
+   r_name = "min";
+ break;
case MAX_EXPR:
+ if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
+   r_name = "max";
  break;
case BIT_AND_EXPR:
  r_name = "&";
@@ -11736,10 +11743,12 @@ c_finish_omp_clauses (tree clauses)
  r_name = "|";
  break;
case TRUTH_ANDIF_EXPR:
- r_name = "&&";
+ if (FLOAT_TYPE_P (TREE_TYPE (t)))
+   r_name = "&&";
  break;
case TRUTH_ORIF_EXPR:
- r_name = "||";
+ if (FLOAT_TYPE_P (TREE_TYPE (t)))
+   r_name = "||";
  break;
default:
  gcc_unreachable ();
--- gcc/cp/semantics.c.jj   2014-01-23 11:40:53.0 +0100
+++ gcc/cp/semantics.c  2014-01-23 13:04:20.428976929 +0100
@@ -4971,6 +4971,10 @@ finish_omp_reduction_clause (tree c, boo
   case BIT_AND_EXPR:
   case BIT_IOR_EXPR:
   case BIT_XOR_EXPR:
+   if (FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)
+ break;
+   predefined = true;
+   break;
   case TRUTH_ANDIF_EXPR:
   case TRUTH_ORIF_EXPR:
if (FLOAT_TYPE_P (type))
--- gcc/testsuite/c-c++-common/gomp/pr58809.c.jj2014-01-23 
13:16:37.401160870 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr58809.c   2014-01-23 13:14:32.0 
+0100
@@ -0,0 +1,31 @@
+/* PR middle-end/58809 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+_Complex int j;
+_Complex double d;
+
+void
+foo (void)
+{
+  #pragma omp parallel reduction (&:j) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (|:j) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (^:j) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (min:j) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (max:j) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (&:d) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (|:d) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (^:d) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (min:d) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+  #pragma omp parallel reduction (max:d) /* { dg-error "has invalid type 
for|user defined reduction not found for" } */
+;
+}

Jakub
2014-01-23  Jakub Jelinek  

PR middle-end/58809
* c-typeck.c (c_finish_omp_clause): Reject MIN_EXPR, MAX_EXPR,
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* semantics.c (finish_omp_clauses): Reject MIN_EXPR, MAX_EXPR,
BIT_AND_EXPR, BIT_IOR_EXPR and BIT_XOR_EXPR on COMPLEX_TYPEs.

* c-c++-common/gomp/pr58809.c: New test.

--- gcc/c/

Re: [C++ Patch] PR 58980

2014-01-23 Thread Jason Merrill

On 01/22/2014 04:29 PM, Paolo Carlini wrote:

On 01/22/2014 10:10 PM, Jason Merrill wrote:

Yep, that's along the lines I was thinking of. But again, prev_scope
is irrelevant here, so the new code shouldn't mention it at all.

Well, in practice I have to mention it in the error_at itself.


Why?  prev_scope is the context where the name is written, i.e. 
current_class_type.  Why should the diagnostic treat it as an explicit 
qualifier?


Jason



Re: [PATCH] Fix for PR57316 (avoid building sanitizer on old kernels)

2014-01-23 Thread Yury Gribov

Jakub wrote:
>> Ok to commit?
>
> Ok, thanks, but:

Done, r206966.

> Put your real name here instead.
>PR sanitizer/57316

Oh my, fixed.

-Y


Re: [Patch, microblaze]: Add __builtin_trap instruction pattern

2014-01-23 Thread Michael Eager

On 11/25/13 23:47, David Holsgrove wrote:

Implement the "trap" pattern for MicroBlaze using matching
ABORT_INSTRUCTION used in glibc.

Resolves recent build failure while building glibc, also encountered
by ARM and AARCH64 and discussed here;
https://sourceware.org/ml/libc-alpha/2013-11/msg00320.html


ChangeLog

2013-11-26  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Add trap insn and attribute.


ChangeLog testsuite

2013-11-26  David Holsgrove 

  * gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c: New test.



Head: Committed revision 206967.
gcc-4_8-branch: Committed revision 206969.

--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Re: [C++ Patch] PR 58980

2014-01-23 Thread Paolo Carlini

Hi,

On 01/23/2014 03:05 PM, Jason Merrill wrote:

On 01/22/2014 04:29 PM, Paolo Carlini wrote:

On 01/22/2014 10:10 PM, Jason Merrill wrote:

Yep, that's along the lines I was thinking of. But again, prev_scope
is irrelevant here, so the new code shouldn't mention it at all.

Well, in practice I have to mention it in the error_at itself.
Why?  prev_scope is the context where the name is written, i.e. 
current_class_type.  Why should the diagnostic treat it as an explicit 
qualifier?
Jason, no problem, you choose. I only wanted to use the same compact 
form 'A::B' used in the non-template case. Which form do you prefer?


Paolo.


[committed][PATCH AArch64_BE] Big-Endian lane numbering fix

2014-01-23 Thread Kyrill Tkachov

Hi all,

I've committed this 4-patch series to aarch64 at:

http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00970.html
http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00972.html
http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00974.html
http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00975.html

as revisions 206967, 206970, 206972 and 206973.

They have been ok'd by Marcus,

Thanks,
Kyrill



[PATCH, ARM][PING] Reintroduce minipool ranges for zero-extension insn patterns

2014-01-23 Thread Yury Gribov

Hi,

Julian Brown has proposed patch 
(http://gcc.gnu.org/ml/gcc-patches/2013-06/msg01191.html) for the 
dreadful push_minipool_fix error 
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49423) in June but it 
didn't seem to get enough attention.


Can we submit it?

--
Best regards,
Yury


Re: [C++ Patch] PR 58980

2014-01-23 Thread Paolo Carlini

On 01/23/2014 04:01 PM, Paolo Carlini wrote:

Hi,

On 01/23/2014 03:05 PM, Jason Merrill wrote:

On 01/22/2014 04:29 PM, Paolo Carlini wrote:

On 01/22/2014 10:10 PM, Jason Merrill wrote:

Yep, that's along the lines I was thinking of. But again, prev_scope
is irrelevant here, so the new code shouldn't mention it at all.

Well, in practice I have to mention it in the error_at itself.
Why?  prev_scope is the context where the name is written, i.e. 
current_class_type.  Why should the diagnostic treat it as an 
explicit qualifier?
Jason, no problem, you choose. I only wanted to use the same compact 
form 'A::B' used in the non-template case. Which form do you prefer?

To be clear if we use %qT with nested_name_specifier we get:

58980.C:5:8: error: ‘typename A<  >::B’ has not 
been declared


which frankly seems suboptimal to me, both vs the non-template case and 
the use of typename.


Thus, as far as I can see, either what I posted, which is consistent 
with the '... has not been declared' message of the non-template case (I 
understand that we want to focus on the 'has not been declared' issue) 
or just '%<%E%>' or even just '%E' and nested_name_specifier.


Paolo.


Re: Fix bootstrap with -mno-accumulate-outgoing-args

2014-01-23 Thread Jan Hubicka
> FAIL: gcc.dg/guality/pr54693-2.c  -O3 -fomit-frame-pointer
> -funroll-loops  line 21 i == v + 1
> FAIL: gcc.target/i386/pr35767-5.c scan-assembler-not movups
> 
> Should we fix
> 
> FAIL: gcc.target/i386/pr35767-5.c scan-assembler-not movups

I will look into this one.  It did not failed for me previously.
I wonder if the guality case is broken unwind info - will try to check.

Honza
> 
> 
> -- 
> H.J.


Re: [C++ Patch] PR 58980

2014-01-23 Thread Jason Merrill

On 01/23/2014 10:30 AM, Paolo Carlini wrote:

To be clear if we use %qT with nested_name_specifier we get:

58980.C:5:8: error: ‘typename A<  >::B’ has not
been declared

which frankly seems suboptimal to me, both vs the non-template case and
the use of typename.


If you want to break apart the typename and do %T::%E with TYPE_CONTEXT 
(nested_name_specifier) on the left side, that's fine too.


Jason



Re: [PATCH][AArch64] Vector shift by 64 fix

2014-01-23 Thread Alex Velenko

Hi,
Could someone, please, commit this patch, as I do not have permissions 
to do so.

Kind regards,
Alex

On 23/01/14 12:04, Marcus Shawcroft wrote:

On 6 January 2014 11:52, Alex Velenko  wrote:

Hi,

This patch fixes vector shift by 64 behavior to meet reference
manual expectations. Testcase included to check that expectations
are now met. No regressions found.

Is patch OK?


OK
/Marcus





Re: [C++ Patch] PR 58980

2014-01-23 Thread Paolo Carlini

On 01/23/2014 04:50 PM, Jason Merrill wrote:

On 01/23/2014 10:30 AM, Paolo Carlini wrote:

To be clear if we use %qT with nested_name_specifier we get:

58980.C:5:8: error: ‘typename A<  >::B’ has not
been declared

which frankly seems suboptimal to me, both vs the non-template case and
the use of typename.
If you want to break apart the typename and do %T::%E with 
TYPE_CONTEXT (nested_name_specifier) on the left side, that's fine too.
Ah, Ok, I was missing that we really want to use TYPE_CONTEXT. To 
confirm, then we get:


58980.C:5:8: error: ‘A<  >::B’ has not been declared

I'm finishing testing the below.

Thanks,
Paolo.

///
Index: cp/parser.c
===
--- cp/parser.c (revision 206958)
+++ cp/parser.c (working copy)
@@ -15469,9 +15469,18 @@ cp_parser_enum_specifier (cp_parser* parser)
error_at (type_start_token->location, "cannot add an enumerator "
  "list to a template instantiation");
 
+ if (TREE_CODE (nested_name_specifier) == TYPENAME_TYPE)
+   {
+ error_at (type_start_token->location,
+   "%<%T::%E%> has not been declared",
+   TYPE_CONTEXT (nested_name_specifier),
+   nested_name_specifier);
+ type = error_mark_node;
+   }
  /* If that scope does not contain the scope in which the
 class was originally declared, the program is invalid.  */
- if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier))
+ else if (prev_scope && !is_ancestor (prev_scope,
+  nested_name_specifier))
{
  if (at_namespace_scope_p ())
error_at (type_start_token->location,
@@ -15480,7 +15489,8 @@ cp_parser_enum_specifier (cp_parser* parser)
  type, prev_scope, nested_name_specifier);
  else
error_at (type_start_token->location,
- "declaration of %qD in %qD which does not enclose 
%qD",
+ "declaration of %qD in %qD which does not "
+ "enclose %qD",
  type, prev_scope, nested_name_specifier);
  type = error_mark_node;
}
Index: testsuite/g++.dg/parse/enum11.C
===
--- testsuite/g++.dg/parse/enum11.C (revision 0)
+++ testsuite/g++.dg/parse/enum11.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/58980
+
+template struct A
+{ 
+  enum A::B::C {};   // { dg-error "has not been declared" }
+};


Re: [C++ Patch] PR 58980

2014-01-23 Thread Jason Merrill

OK, thanks.

Jason


Re: [PATCH][AArch64] Vector shift by 64 fix

2014-01-23 Thread James Greenhalgh
On Thu, Jan 23, 2014 at 03:57:33PM +, Alex Velenko wrote:
> Hi,
> Could someone, please, commit this patch, as I do not have permissions 
> to do so.

Please don't top-post on this list.

> On 23/01/14 12:04, Marcus Shawcroft wrote:
> > On 6 January 2014 11:52, Alex Velenko  wrote:
> >> Hi,
> >>
> >> This patch fixes vector shift by 64 behavior to meet reference
> >> manual expectations. Testcase included to check that expectations
> >> are now met. No regressions found.
> >>
> >> Is patch OK?
> >
> > OK
> > /Marcus

I've committed this on Alex' behalf as revision 206978.

Thanks,
James



[C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread Marek Polacek
shorten_compare can produce a better locinfo if we pass location
from {,cp_}build_binary_op to it; op0/op1 there don't have location.
Furthermore, I see no reason why use input_location in
parser_build_binary_op when we can use more accurate location.

I don't know if/how I can test the column info using dejagnu, so
no testcase attached.  But to give you an idea, instead of
tt.c:4:3: warning: comparison is always false due to limited range of data type 
[-Wtype-limits]
   return 0UL > p;
   ^
we now show
tt.c:4:14: warning: comparison is always false due to limited range of data 
type [-Wtype-limits]
   return 0UL > p;
  ^
Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-01-23  Marek Polacek  

PR c/59846
c-family/
* c-common.c (shorten_compare): Add location_t parameter.
* c-common.h (shorten_binary_op): Adjust declaration.
cp/
* typeck.c (cp_build_binary_op): Pass location to shorten_compare.
c/
* c-typeck.c (parser_build_binary_op): Use location instead of
input_location.
(build_binary_op): Pass location to shorten_compare.

--- gcc/c-family/c-common.h.mp  2014-01-23 16:19:49.936114468 +0100
+++ gcc/c-family/c-common.h 2014-01-23 16:19:55.407138560 +0100
@@ -799,7 +799,8 @@ extern tree shorten_binary_op (tree resu
 /* Subroutine of build_binary_op, used for comparison operations.
See if the operands have both been converted from subword integer types
and, if so, perhaps change them both back to their original type.  */
-extern tree shorten_compare (tree *, tree *, tree *, enum tree_code *);
+extern tree shorten_compare (location_t, tree *, tree *, tree *,
+enum tree_code *);
 
 extern tree pointer_int_sum (location_t, enum tree_code, tree, tree,
 bool = true);
--- gcc/c-family/c-common.c.mp  2014-01-23 16:19:49.935114463 +0100
+++ gcc/c-family/c-common.c 2014-01-23 16:19:55.407138560 +0100
@@ -3974,13 +3974,15 @@ expr_original_type (tree expr)
of build_binary_op: OP0_PTR is &OP0, OP1_PTR is &OP1,
RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE.
 
+   LOC is the location of the comparison.
+
If this function returns nonzero, it means that the comparison has
a constant value.  What this function returns is an expression for
that value.  */
 
 tree
-shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
-enum tree_code *rescode_ptr)
+shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr,
+tree *restype_ptr, enum tree_code *rescode_ptr)
 {
   tree type;
   tree op0 = *op0_ptr;
@@ -3989,7 +3991,6 @@ shorten_compare (tree *op0_ptr, tree *op
   int real1, real2;
   tree primop0, primop1;
   enum tree_code code = *rescode_ptr;
-  location_t loc = EXPR_LOC_OR_LOC (op0, input_location);
 
   /* Throw away any conversions to wider types
  already present in the operands.  */
--- gcc/cp/typeck.c.mp  2014-01-23 16:19:49.939114483 +0100
+++ gcc/cp/typeck.c 2014-01-23 16:19:55.424138642 +0100
@@ -4838,7 +4838,8 @@ cp_build_binary_op (location_t location,
  tree xop0 = op0, xop1 = op1, xresult_type = result_type;
  enum tree_code xresultcode = resultcode;
  tree val
-   = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
+   = shorten_compare (location, &xop0, &xop1, &xresult_type,
+  &xresultcode);
  if (val != 0)
return cp_convert (boolean_type_node, val, complain);
  op0 = xop0, op1 = xop1;
--- gcc/c/c-typeck.c.mp 2014-01-23 16:19:49.938114478 +0100
+++ gcc/c/c-typeck.c2014-01-23 17:15:56.404366164 +0100
@@ -3388,11 +3388,11 @@ parser_build_binary_op (location_t locat
   /* Check for cases such as x+y<

RE: [PATCH] _Cilk_for for C and C++

2014-01-23 Thread Iyer, Balaji V
Hi Jakub,

> -Original Message-
> From: Jakub Jelinek [mailto:ja...@redhat.com]
> Sent: Thursday, January 23, 2014 5:13 AM
> To: Iyer, Balaji V
> Cc: Jason Merrill; 'Jeff Law'; 'Aldy Hernandez'; 'gcc-patches@gcc.gnu.org';
> 'r...@redhat.com'
> Subject: Re: [PATCH] _Cilk_for for C and C++
> 
> On Sun, Jan 19, 2014 at 04:50:39AM +, Iyer, Balaji V wrote:
> > I have answered your questions below. In addition to your changes, I
> > have also fixed the issues Aldy pointed out and have answered his
> > questions in that thread.  With this email I have attached two patches
> > and 2 change-logs (for C and C++).  I have also rebased these patches
> > to the trunk revision (r206756)
> 
> Haven't looked at the patch yet, just applied and looked what it generates:
> 
> Say in cilk_fors.c -O2 -fcilkplus -std=c99 -fdump-tree-
> {original,gimple,omplower,ompexp}
> I'm seeing in *.original dump:
> <<< Unknown tree: cilk_for
> which suggests that tree-pretty-print.c doesn't handle CILK_FOR.
> 

OK. I will work on this and send you a patch soon.

> Much more important is what is seen in the *.gimple dump though:
>schedule(runtime,0) private(ii)
>   _Cilk_for (ii = 0; ii <= 9; ii = ii + 1)
> {
>   #pragma omp parallel shared(__cilk_incr.0) shared(__cilk_cond.2)
> shared(__cilk_init.1) shared(ii) shared(Array)
> {
>   Array[ii] = 1133;
> }
> }
> Why do you put the parallel inside of _Cilk_for rather than the other way
> around?  That looks just wrong.  That would represent runtime scheduling of
> work across the parallel regions at the _Cilk_for, and then in each iteration
> running the body in several threads concurrently.
> You want the parallel around the _Cilk_for, and
> gimple_omp_parallel_set_combined_p (parallel_stmt, true) so that you can
> then handle it specially during omp lowering/expansion.

This is how I started to think of it at first, but then when I thought 
about it ... in _Cilk_for unlike the #pragma simd's for, the for statement - 
not the body - (e.g. "_Cilk_for (int ii = 0; ii < 10; ii++") doesn't really do 
anything nor does it belong in the child function. It is really mostly used to 
calculate the loop count and capture step-size and starting point.

The child function has its own loop that will have a step size of 1 
regardless of your step size. You use the step-size to find the correct spot. 
Let me give you an example:

_Cilk_for (int ii = 0; ii < 10; ii = ii  + 2)
{
Array [ii] = 5;
}

This is translated to the following (assume grain is something that the user 
input):

data_ptr.start = 0;
data_ptr.end = 10;
data_ptr.step_size = 2;
__cilkrts_cilk_for_32 (child_function, &data_ptr, (10-0)/2, grain);

Child_function (void *data_ptr, int high, int low)
{
for (xx = low; xx < high; xx++) 
 {
Tmp_var = (xx * data_ptr->step_size) + data_ptr->start;
// Note: if the _Cilk_for was (ii = 9; ii >= 0; ii -= 2), we 
would have something like this:
// Tmp_var = data_ptr->end - (xx * data_ptr->step_size)
// The for-loop above won't change.  
Array[Tmp_var] = 5;
}
}

High and low are passed in by the runtime and thus their range can be any 
number (in this case between 1 and 5)

Now, if we model this like #pragma omp parallel for then all _Cilk_for 
statement will also be pulled into the child function. This can be circumvented 
(althrough I feel it is a bit convoluted) using the region->data_arg pointers 
to pass values back and forth and doing other adjustments in expand_omp_for, 
and it will work for C, but it gets problematic for STL. This is because during 
the gimplification, the vector.start() and vector.end () are replaced with the 
start and end integers and the translation is put in the child function and 
that messes things up in omp-low.c and the calculation for count in the parent 
function. Another thing also gets messed up for C++ which I can't recall off 
the top of my head.

On high-level, you can't think of _Cilk_for in terms of Open MP's for. These 
both are orthogonal technologies that produce parallel code with different 
starting points and assumptions. The reason why I modeled this way in the 
compiler is so that I can use OMP's  compiler-routines. Some things such as 
creating a child function, inserting *a* call to the library function are same 
and thus the routines to do those can be shared but the internals are very 
different and so this is why it  is modelled this way in the compiler.

> 
> Also, the printing of _Cilk_for is weird, the clauses (with space before) look
> really weird above the _Cilk_for when there is no #pragma or something
> similar.  Perhaps print the clauses after _Cilk_for?
>   _Cilk_for (ii = 0; ii <= 9; ii = ii + 1) schedule(runtime,0) private(ii) ?
> 

OK. I will work on this and send you a patch.

>   Jakub


[Ada] Remove unused node N_Subprogram_Info

2014-01-23 Thread Arnaud Charlet
This is an internal change only, does not affect functionality,
so no test needed.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-23  Robert Dewar  

* exp_util.adb, sinfo.adb, sinfo.ads, sem.adb, sem_res.adb,
expander.adb, exp_ch11.adb, exp_ch11.ads, sem_ch11.adb, sem_ch11.ads,
sprint.adb, sprint.ads: Remove unused node N_Subprogram_Info.

Index: exp_util.adb
===
--- exp_util.adb(revision 206922)
+++ exp_util.adb(working copy)
@@ -3829,7 +3829,6 @@
N_Single_Protected_Declaration   |
N_Slice  |
N_String_Literal |
-   N_Subprogram_Info|
N_Subtype_Indication |
N_Subunit|
N_Task_Definition|
Index: sinfo.adb
===
--- sinfo.adb   (revision 206918)
+++ sinfo.adb   (working copy)
@@ -1627,8 +1627,7 @@
 or else NT (N).Nkind = N_Enumeration_Representation_Clause
 or else NT (N).Nkind = N_Label
 or else NT (N).Nkind = N_Loop_Statement
-or else NT (N).Nkind = N_Record_Representation_Clause
-or else NT (N).Nkind = N_Subprogram_Info);
+or else NT (N).Nkind = N_Record_Representation_Clause);
   return Node1 (N);
end Identifier;
 
@@ -4768,8 +4767,7 @@
 or else NT (N).Nkind = N_Enumeration_Representation_Clause
 or else NT (N).Nkind = N_Label
 or else NT (N).Nkind = N_Loop_Statement
-or else NT (N).Nkind = N_Record_Representation_Clause
-or else NT (N).Nkind = N_Subprogram_Info);
+or else NT (N).Nkind = N_Record_Representation_Clause);
   Set_Node1_With_Parent (N, Val);
end Set_Identifier;
 
Index: sinfo.ads
===
--- sinfo.ads   (revision 206918)
+++ sinfo.ads   (working copy)
@@ -7683,23 +7683,6 @@
   --  with the N_In node (or a rewriting thereof) corresponding to a
   --  classwide membership test.
 
-  -
-  -- Subprogram_Info --
-  -
-
-  --  This node generates the appropriate Subprogram_Info value for a
-  --  given procedure. See Ada.Exceptions for further details
-
-  --  Sprint syntax: subprog'subprogram_info
-
-  --  N_Subprogram_Info
-  --  Sloc points to the entity for the procedure
-  --  Identifier (Node1) identifier referencing the procedure
-  --  Etype (Node5-Sem) type (always set to Ada.Exceptions.Code_Loc)
-
-  --  Note: in the case where a debug source file is generated, the Sloc
-  --  for this node points to the quote in the Sprint file output.
-
   --
   -- Unchecked Expression --
   --
@@ -7977,7 +7960,6 @@
   N_Reference,
   N_Selected_Component,
   N_Slice,
-  N_Subprogram_Info,
   N_Type_Conversion,
   N_Unchecked_Expression,
   N_Unchecked_Type_Conversion,
@@ -12080,13 +12062,6 @@
 4 => False,   --  unused
 5 => False),  --  Etype (Node5-Sem)
 
- N_Subprogram_Info =>
-   (1 => True,--  Identifier (Node1)
-2 => False,   --  unused
-3 => False,   --  unused
-4 => False,   --  unused
-5 => False),  --  Etype (Node5-Sem)
-
  N_Unchecked_Expression =>
(1 => False,   --  unused
 2 => False,   --  unused
Index: sem.adb
===
--- sem.adb (revision 206918)
+++ sem.adb (working copy)
@@ -530,9 +530,6 @@
  when N_Subprogram_Declaration =>
 Analyze_Subprogram_Declaration (N);
 
- when N_Subprogram_Info =>
-Analyze_Subprogram_Info (N);
-
  when N_Subprogram_Renaming_Declaration =>
 Analyze_Subprogram_Renaming (N);
 
Index: sem_res.adb
===
--- sem_res.adb (revision 206931)
+++ sem_res.adb (working copy)
@@ -201,7 +201,6 @@
procedure Resolve_Short_Circuit (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Slice (N : Node_Id; Typ : Entity_Id);
procedure Resolve_String_Literal(N : Node_Id; Typ : Entity_Id);
-   procedure Resolve_Subprogram_Info   (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Type_Conversion   (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Unary_Op  (N : Node_Id; Typ : Entity_Id);
procedure Resolve_Unchecked_Expression  (N : Node_Id; Typ : Entity_Id);
@@ -2897,9 +2896,6 @@
 when N_String_Literal
  => Resolve_String_Literal   (N, Ctx_Type);
 
-when N_Subprogram_Inf

[Ada] Fix detection of unmodified variables in -gnatc mode

2014-01-23 Thread Arnaud Charlet
For an implicit dereference such as J.K where J is of an access
type, the compiler incorrectly assumed that an assignment to
J.K would modify J if operating in semantics only (-gnatc) mode.
The following example gives the warning indicated if compiled
with -gnatwa with or without -gnatc

 1. procedure BadUnmodC is
 2.package Db_G is
 3.   type Access_Int is private;
 4.   procedure Modify_Via_Access
 5. (Ptr1 : in out Access_Int;
 6.  Ptr2 : in out Access_Int);
 7.   pragma Unreferenced (Modify_Via_Access);
 8.private
 9.   type Rec;
10.   type Access_Int is access Rec;
11.end;
12.pragma Unreferenced (Db_G);
13.package body Db_G is
14.   type Rec is
15.  record
16. I : Integer;
17.  end record;
18.   procedure Modify (I : in out Integer) is
19.   begin
20.  I := I + 1;
21.   end;
22.   procedure Modify_Via_Access
23. (Ptr1 : in out Access_Int;
24.  Ptr2 : in out Access_Int)
 |
>>> warning: formal parameter "Ptr2" is not
modified, mode could be "in" instead of "in out"

25.   is
26.  pragma Unmodified (Ptr1);
27.   begin
28.  Modify (Ptr1.I);
29.  Modify (Ptr2.I);
30.   end;
31.end;
32. begin
33.null;
34. end;

Previously, this warning was missed in -gnatc mode, and instead
there was a bogus complaint about the pragma Unmodified.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-23  Robert Dewar  

* sem_util.adb (Note_Possible_Modification): Fix error of
misbehaving for implicit dereference cases in -gnatc mode.

Index: sem_util.adb
===
--- sem_util.adb(revision 206918)
+++ sem_util.adb(working copy)
@@ -13344,7 +13344,6 @@
 
   Exp := N;
   loop
- <>
  Ent := Empty;
 
  if Is_Entity_Name (Exp) then
@@ -13370,8 +13369,7 @@
end if;
 
if Nkind (P) = N_Selected_Component
- and then
-   Present (Entry_Formal (Entity (Selector_Name (P
+ and then Present (Entry_Formal (Entity (Selector_Name (P
then
   --  Case of a reference to an entry formal
 
@@ -13380,8 +13378,8 @@
elsif Nkind (P) = N_Identifier
  and then Nkind (Parent (Entity (P))) = N_Object_Declaration
  and then Present (Expression (Parent (Entity (P
- and then Nkind (Expression (Parent (Entity (P
-   = N_Reference
+ and then Nkind (Expression (Parent (Entity (P =
+   N_Reference
then
   --  Case of a reference to a value on which side effects have
   --  been removed.
@@ -13391,7 +13389,6 @@
 
else
   return;
-
end if;
 end;
 
@@ -13405,9 +13402,25 @@
   N_Indexed_Component,
   N_Selected_Component)
  then
-Exp := Prefix (Exp);
-goto Continue;
+--  Special check, if the prefix is an access type, then return
+--  since we are modifying the thing pointed to, not the prefix.
+--  When we are expanding, most usually the prefix is replaced
+--  by an explicit dereference, and this test is not needed, but
+--  in some cases (notably -gnatc mode and generics) when we do
+--  not do full expansion, we need this special test.
 
+if Is_Access_Type (Etype (Prefix (Exp))) then
+   return;
+
+--  Otherwise go to prefix and keep going
+
+else
+   Exp := Prefix (Exp);
+   goto Continue;
+end if;
+
+ --  All other cases, not a modification
+
  else
 return;
  end if;
@@ -13539,6 +13552,9 @@
 
 return;
  end if;
+
+  <>
+ null;
   end loop;
end Note_Possible_Modification;
 


Re: [ARM] fix big.LITTLE spec rewriting

2014-01-23 Thread James Greenhalgh
*Ping*

On Tue, Jan 21, 2014 at 10:52:14AM +, James Greenhalgh wrote:
> 
> Hi,
> 
> As with the AArch64 case,
> ( http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01317.html )
> the way that we rewrite command lines for big.LITTLE systems
> causes bugs where more than one source file is to be used.
> 
> The solution here is identical to that proposed for AArch64,
> we update the spec command and compensate for that with an
> change to arm_rewrite_mcpu to handle multiple names.
> 
> The patch has been bootstrapped on a chromebook, and I've
> checked combinations of zero or more -mcpu values with
> one or more source files, and things seem to work as expected.
> 
> OK?
> 
> Thanks,
> James
> 
> ---
> 2014-01-21  James Greenhalgh  
> 
>   * common/config/arm/arm-common.c
>   (arm_rewrite_mcpu): Handle multiple names.
>   * config/arm/arm.h
>   (BIG_LITTLE_SPEC): Do not discard mcpu switches.
> 

> diff --git a/gcc/common/config/arm/arm-common.c 
> b/gcc/common/config/arm/arm-common.c
> index 065de7d..8ef8d83 100644
> --- a/gcc/common/config/arm/arm-common.c
> +++ b/gcc/common/config/arm/arm-common.c
> @@ -86,13 +86,15 @@ arm_rewrite_selected_cpu (const char *name)
>  
>  /* Called by the driver to rewrite a name passed to the -mcpu
> argument in preparation to be passed to the assembler.  The
> -   name will be in ARGV[0], ARGC should always be 1.  */
> +   names passed from the commend line will be in ARGV, we want
> +   to use the right-most argument, which should be in
> +   ARGV[ARGC - 1].  ARGC should always be greater than 0.  */
>  
>  const char *
>  arm_rewrite_mcpu (int argc, const char **argv)
>  {
> -  gcc_assert (argc == 1);
> -  return arm_rewrite_selected_cpu (argv[0]);
> +  gcc_assert (argc);
> +  return arm_rewrite_selected_cpu (argv[argc - 1]);
>  }
>  
>  #undef ARM_CPU_NAME_LENGTH
> diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
> index b815488..bed056e 100644
> --- a/gcc/config/arm/arm.h
> +++ b/gcc/config/arm/arm.h
> @@ -2356,7 +2356,7 @@ extern int making_const_table;
>  #define MAX_LDM_STM_OPS 4
>  
>  #define BIG_LITTLE_SPEC \
> -   " %{mcpu=*:% +   " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}"
>  
>  extern const char *arm_rewrite_mcpu (int argc, const char **argv);
>  #define BIG_LITTLE_CPU_SPEC_FUNCTIONS \



Re: [AArch64] fix big.LITTLE spec rewriting

2014-01-23 Thread James Greenhalgh
*ping*

On Tue, Jan 21, 2014 at 10:48:04AM +, James Greenhalgh wrote:
> 
> Hi,
> 
> As Charles Baylis pointed out here:
> 
> http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00921.html
> 
> The way that we rewrite command lines for big.LITTLE systems
> causes bugs where more than one source file is to be used.
> The problem fundamentally is that -mcpu never makes it to
> the second cc1 invocation.
> 
> This patch changes the spec command we use and updates
> aarch64-common.c to handle that fact. I confess that the specs
> stuff all looks like magic to me, but this approach seems to
> make sense. In English, I think I am saying:
> 
> "If you find an mcpu= followed by some name, rewrite that to be
>  -mcpu followed by the results of passing all other -mcpu values
>  we find through aarch64_rewrite_mcpu"
> 
> I've regression tested this patch on aarch64-none-elf with no
> issues and checked combinations of zero or more -mcpu values with
> one or more source files, and things seem to work as expected.
> 
> OK?
> 
> Thanks,
> James
> 
> ---
> 2014-01-21  James Greenhalgh  
> 
>   * common/config/aarch64/aarch64-common.c
>   (aarch64_rewrite_mcpu): Handle multiple names.
>   * config/aarch64/aarch64.h
>   (BIG_LITTLE_SPEC): Do not discard mcpu switches.
> 

> diff --git a/gcc/common/config/aarch64/aarch64-common.c 
> b/gcc/common/config/aarch64/aarch64-common.c
> index 6107007..e44b40a 100644
> --- a/gcc/common/config/aarch64/aarch64-common.c
> +++ b/gcc/common/config/aarch64/aarch64-common.c
> @@ -110,13 +110,15 @@ aarch64_rewrite_selected_cpu (const char *name)
>  
>  /* Called by the driver to rewrite a name passed to the -mcpu
> argument in preparation to be passed to the assembler.  The
> -   name will be in ARGV[0], ARGC should always be 1.  */
> +   names passed from the commend line will be in ARGV, we want
> +   to use the right-most argument, which should be in
> +   ARGV[ARGC - 1].  ARGC should always be greater than 0.  */
>  
>  const char *
>  aarch64_rewrite_mcpu (int argc, const char **argv)
>  {
> -  gcc_assert (argc == 1);
> -  return aarch64_rewrite_selected_cpu (argv[0]);
> +  gcc_assert (argc);
> +  return aarch64_rewrite_selected_cpu (argv[argc - 1]);
>  }
>  
>  #undef AARCH64_CPU_NAME_LENGTH
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index a08dee0..13c424c 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -857,7 +857,7 @@ extern enum aarch64_code_model aarch64_cmodel;
>(BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 - n : n)
>  
>  #define BIG_LITTLE_SPEC \
> -   " %{mcpu=*:% +   " %{mcpu=*:-mcpu=%:rewrite_mcpu(%{mcpu=*:%*})}"
>  
>  extern const char *aarch64_rewrite_mcpu (int argc, const char **argv);
>  #define BIG_LITTLE_CPU_SPEC_FUNCTIONS \



RE: [PATCH] fix for PR 59825

2014-01-23 Thread Iyer, Balaji V


> -Original Message-
> From: Jakub Jelinek [mailto:ja...@redhat.com]
> Sent: Thursday, January 23, 2014 5:28 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] fix for PR 59825
> 
> On Thu, Jan 23, 2014 at 10:27:58AM +0100, Jakub Jelinek wrote:
> > On Mon, Jan 20, 2014 at 10:40:31PM +, Iyer, Balaji V wrote:
> > > --- a/gcc/c/c-array-notation.c
> > > +++ b/gcc/c/c-array-notation.c
> > > @@ -1218,22 +1218,22 @@ fix_return_expr (tree expr)
> > >return new_mod_list;
> > >  }
> > >
> > > -/* Walks through tree node T and find all the call-statements that do not
> return
> > > -   anything and fix up any array notations they may carry.  The return
> value
> > > -   is the same type as T but with all array notations replaced with
> appropriate
> > > -   STATEMENT_LISTS.  */
> > > +/* Callback for walk_tree.  Expands all array notations in *TP.
> *WALK_SUBTREES
> > > +   is set to 1 unless *TP contains no array notation expressions.
> Parameter
> > > +   D is unused.  */
> > >
> > > -tree
> > > -expand_array_notation_exprs (tree t)
> > > +static tree
> > > +expand_array_notations (tree *tp, int *walk_subtrees, void *d
> > > +ATTRIBUTE_UNUSED)
> >
> > As we are now using C++, just use
> > expand_array_notations (tree *tp, int *walk_subtrees, void *) and
> > remove the comment about unused parameter D.
> >
> > >  {
> > > -  if (!contains_array_notation_expr (t))
> > > -return t;
> > > +  if (!contains_array_notation_expr (*tp))
> >
> > Why do you want to walk the whole subtree once more at every level?
> > That has bad time complexity for very deep trees.
> > Can't you just do that in expand_array_notations_exprs once?
> 
> Though, as this is not a regression with this patch and the patch fixes a bug 
> in
> the testsuite, perhaps you can do that incrementally.
> 
> So, can you please change the comment and expand_array_notations
> prototype, then commit (patch preapproved)?
> 

Ok. I will commit the patch with the fix you suggested above. For your 
reference, I have attached a patch.

Thanks,

Balaji V. Iyer.


> Then please add to todo list that walking all subtrees twice at every level is
> something you should avoid.  Perhaps for the trees you don't explictly handle
> you could gather in *(bool *)d whether it contained any array notations, and
> trees you actually handle could first walk the subtrees manually to gather the
> flags and transform what needs to be transformed in there, and then just
> based on the bool flag decide if it should do anything and what.  Also, how is
> e.g. array notation supposed to be handled in case of nested MODIFY_EXPRs
> where the nested MODIFY_EXPRs contain array notations?  I mean
> something like:
> a[0:10] = (b[0:10] ? (c[0:10] = d[0:10] + (e[0:10] = f[0:10] ? (g[0:10] * 3 : 
> g[0:10]
> + 12))) : 5); etc.?
> I'd say contains_array_notation_expr should also be rewritten to use
> walk_tree, so should be the C++ AN expansion etc.  Just you'll need to use
> cp_walk_tree for C++ probably and thus the c-family/ code should just
> contain callbacks that you can use for the walking, not the actual calls to
> walk_tree/cp_walk_tree.
> 

Ok. I will look into this..

>   Jakub
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 8230c86..a158f11 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,5 +1,13 @@
 2014-01-23  Balaji V. Iyer  
 
+   PR c/59825
+   * c-array-notation.c (expand_array_notation_exprs): Rewrote this
+   function to use walk_tree and moved a lot of its functionality to
+   expand_array_notations.
+   (expand_array_notations): New function.
+
+2014-01-23  Balaji V. Iyer  
+
* c-parser.c (c_finish_omp_declare_simd): Made "cilk simd function"
attribute an attribute without value.
 
diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 5526ee9..6a5631c
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -1218,22 +1218,21 @@ fix_return_expr (tree expr)
   return new_mod_list;
 }
 
-/* Walks through tree node T and find all the call-statements that do not 
return
-   anything and fix up any array notations they may carry.  The return value
-   is the same type as T but with all array notations replaced with appropriate
-   STATEMENT_LISTS.  */
+/* Callback for walk_tree.  Expands all array notations in *TP.  *WALK_SUBTREES
+   is set to 1 unless *TP contains no array notation expressions.  */
 
-tree
-expand_array_notation_exprs (tree t)
+static tree
+expand_array_notations (tree *tp, int *walk_subtrees, void *)
 {
-  if (!contains_array_notation_expr (t))
-return t;
+  if (!contains_array_notation_expr (*tp))
+{
+  *walk_subtrees = 0;
+  return NULL_TREE;
+}
+  *walk_subtrees = 1;
 
-  switch (TREE_CODE (t))
+  switch (TREE_CODE (*tp))
 {
-case BIND_EXPR:
-  t = expand_array_notation_exprs (BIND_EXPR_BODY (t));
-  return t;
 case TRUTH_ORIF_EXPR:
 case TRUTH_ANDIF_EXPR:
 case TRUTH_OR_EXPR:
@@ -1241,61 

[Ada] Restrictions on 'Old in a postcondition.

2014-01-23 Thread Arnaud Charlet
RM 6.1.1 (26/3) specifies that if the prefix of 'Old wihin a postcondition is
potentially unevaluated, as in the right-hand side of a short-circuit operation
then the prefix can only be an entity name.

Compiling main.adb must yield:

p.ads:5:44: prefix that is potentially unevaluated must denote an entity

---
with P; use P;
procedure Main is
   A : My_Array := (1, 2, 3);
   V : Integer;
begin
   Extract (A, 6, V);
end Main;
---
package P is
   type My_Array is array (Natural range <>) of Integer;
   
   procedure Extract (A : in out My_Array; J : Integer; V : out Integer) with
 Post => (if J in A'Range then V = A(J)'Old and A(J) = 0);  --  INCORRECT

   procedure Check (A : in out My_Array; J : Integer; V : out Integer) with
 Post => (if A(A'First)'Old > A(A'Last)'Old then True
else raise program_error);  -- OK
end P;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-23  Ed Schonberg  

* sem_util.ads, sem_util.adb (Is_Potentially_Unevaluated): new
predicate to implement rule given in 6.1.1 (20/3).
* sem_attr.adb (Analyze_Attribute, case 'Old): Reject prefix of
'Old in a postcondition, if it is potentially unevaluated and
it is not an entity name.

Index: sem_util.adb
===
--- sem_util.adb(revision 206980)
+++ sem_util.adb(working copy)
@@ -10249,6 +10249,48 @@
   end if;
end Is_Partially_Initialized_Type;
 
+   
+   -- Is_Potentially_Unevaluated --
+   
+
+   function Is_Potentially_Unevaluated (N : Node_Id) return Boolean is
+  Par  : Node_Id;
+  Expr : Node_Id;
+
+   begin
+  Expr := N;
+  Par  := Parent (N);
+  while not Nkind_In (Par, N_If_Expression,
+N_Case_Expression,
+N_And_Then,
+N_Or_Else,
+N_In,
+N_Not_In)
+  loop
+ Expr := Par;
+ Par  := Parent (Par);
+ if Nkind (Par) not in N_Subexpr then
+return False;
+ end if;
+  end loop;
+
+  if Nkind (Par) = N_If_Expression then
+ return Is_Elsif (Par) or else Expr /= First (Expressions (Par));
+
+  elsif Nkind (Par) = N_Case_Expression then
+ return Expr /= Expression (Par);
+
+  elsif Nkind_In (Par, N_And_Then, N_Or_Else) then
+ return Expr = Right_Opnd (Par);
+
+  elsif Nkind_In (Par, N_In, N_Not_In) then
+ return Expr /= Left_Opnd (Par);
+
+  else
+ return False;
+  end if;
+   end Is_Potentially_Unevaluated;
+

-- Is_Potentially_Persistent_Type --

Index: sem_util.ads
===
--- sem_util.ads(revision 206918)
+++ sem_util.ads(working copy)
@@ -1116,6 +1116,9 @@
--  if Include_Implicit is False, these cases do not count as making the
--  type be partially initialized.
 
+   function Is_Potentially_Unevaluated (N : Node_Id) return Boolean;
+   --  Predicate to implement definition given in RM 6.1.1 (20/3)
+
function Is_Potentially_Persistent_Type (T : Entity_Id) return Boolean;
--  Determines if type T is a potentially persistent type. A potentially
--  persistent type is defined (recursively) as a scalar type, a non-tagged
Index: sem_attr.adb
===
--- sem_attr.adb(revision 206918)
+++ sem_attr.adb(working copy)
@@ -4337,6 +4337,8 @@
  --  During pre-analysis, Prag is the enclosing pragma node if any
 
   begin
+ Prag := Empty;
+
  --  Find enclosing scopes, excluding loops
 
  CS := Current_Scope;
@@ -4515,6 +4517,18 @@
   ("??attribute Old applied to constant has no effect", P);
  end if;
 
+ --  Check that the prefix of 'Old is an entity, when it appears in
+ --  a postcondition and may be potentially unevaluated (6.1.1 (27/3)).
+
+ if Present (Prag)
+   and then Get_Pragma_Id (Prag) = Pragma_Postcondition
+   and then Is_Potentially_Unevaluated (N)
+   and then not Is_Entity_Name (P)
+ then
+Error_Msg_N ("prefix that is potentially unevaluated must "
+   & "denote an entity", N);
+ end if;
+
  --  The attribute appears within a pre/postcondition, but refers to
  --  an entity in the enclosing subprogram. If it is a component of
  --  a formal its expansion might generate actual subtypes that may


[Ada] Fix problem in save/restore of SPARK_Mode

2014-01-23 Thread Arnaud Charlet
The previous checkin for saving and restoring SPARK_Mode was not
complete, and as a result the SPARK_Mode_Pragma was not properly
set in some cases. The following test program:

 1. package Pack_Size1 is
 2.pragma SPARK_Mode (On);
 3.procedure P;
 4. end Pack_Size1;

 1. package body Pack_Size1 is
 2.type T_Bit is range 0 .. 1;
 3.type T_Bit_Buffer is
 4.  array (Natural range <>) of T_Bit;
 5.pragma Pack (T_Bit_Buffer);
 6.procedure P is begin null; end;
 7. end Pack_Size1;

Should set SPARK_Mode_Pragma in the body node procedure P, but
failed to do so (because Rtsfind was clobbering SPARK_Mode_Pragma).
An easy test is

   gcc -c pack_size1.adb -gnatdt >log
   grep "SPARK_Pragma " log | wc -l

this should output 3, prior to this patch it output 1

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-23  Robert Dewar  

* opt.adb (Save_Opt_Config_Switches): Save SPARK_Mode_Pragma
(Restore_Opt_Config_Switches): Restore SPARK_Mode_Pragma.
* sem.adb (Semantics): Remove save/restore of
SPARK_Mode[_Pragma]. Not needed since already done in
Save/Restore_Opt_Config_Switches.

Index: sem.adb
===
--- sem.adb (revision 206990)
+++ sem.adb (working copy)
@@ -1311,8 +1311,6 @@
   S_Inside_A_Generic  : constant Boolean  := Inside_A_Generic;
   S_Outer_Gen_Scope   : constant Entity_Id:= Outer_Generic_Scope;
   S_Style_Check   : constant Boolean  := Style_Check;
-  S_SPARK_Mode: constant SPARK_Mode_Type  := SPARK_Mode;
-  S_SPARK_Mode_Pragma : constant Node_Id  := SPARK_Mode_Pragma;
 
   Generic_Main : constant Boolean :=
Nkind (Unit (Cunit (Main_Unit)))
@@ -1512,8 +1510,6 @@
   Inside_A_Generic := S_Inside_A_Generic;
   Outer_Generic_Scope  := S_Outer_Gen_Scope;
   Style_Check  := S_Style_Check;
-  SPARK_Mode   := S_SPARK_Mode;
-  SPARK_Mode_Pragma:= S_SPARK_Mode_Pragma;
 
   Restore_Opt_Config_Switches (Save_Config_Switches);
 
Index: opt.adb
===
--- opt.adb (revision 206990)
+++ opt.adb (working copy)
@@ -100,6 +100,7 @@
   Polling_Required   := Save.Polling_Required;
   Short_Descriptors  := Save.Short_Descriptors;
   SPARK_Mode := Save.SPARK_Mode;
+  SPARK_Mode_Pragma  := Save.SPARK_Mode_Pragma;
   Use_VADS_Size  := Save.Use_VADS_Size;
 
   --  Update consistently the value of Init_Or_Norm_Scalars. The value of
@@ -137,6 +138,7 @@
   Save.Polling_Required   := Polling_Required;
   Save.Short_Descriptors  := Short_Descriptors;
   Save.SPARK_Mode := SPARK_Mode;
+  Save.SPARK_Mode_Pragma  := SPARK_Mode_Pragma;
   Save.Use_VADS_Size  := Use_VADS_Size;
end Save_Opt_Config_Switches;
 


Commit: MSP430: Linker script renaming

2014-01-23 Thread Nick Clifton
Hi Guys,

  I am committing the patch below which changes the MCU specific linker
  script naming scheme for the MSP430.  TI have now decided to replace
  the MCU specific directories containing memory.ld and peripherals.ld
  scripts with individual MCU scripts.

  The patch also updates the -mcpu command line option so that it will
  accept a wider range of names for the ISA to use.

Cheers
  Nick

gcc/ChangeLog
2014-01-23  Nick Clifton  

* config/msp430/msp430.h (ASM_SPEC): Pass the -mcpu as -mcpu.
(LIB_SPEC): Drop useof memory.ld and peripherals.ld scripts in
favour of mcu specific scripts.
* config/msp430/t-msp430 (MULTILIB_MATCHES): Add more matches for
430x multilibs.

Index: config/msp430/msp430.h
===
--- config/msp430/msp430.h  (revision 206976)
+++ config/msp430/msp430.h  (working copy)
@@ -52,7 +52,7 @@
 #define ENDFILE_SPEC "crtend.o%s crtn.o%s -lgcc"
 
 #define ASM_SPEC "-mP " /* Enable polymorphic instructions.  */ \
-  "%{mcpu=*:-mmcu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on 
to the assembler.  */ \
+  "%{mcpu=*:-mcpu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on 
to the assembler.  */ \
   "%{mrelax=-mQ} " /* Pass the relax option on to the assembler.  */ \
   "%{mlarge:-ml} " /* Tell the assembler if we are building for the LARGE 
pointer model.  */ \
   "%{!msim:-md} %{msim:%{mlarge:-md}}" /* Copy data from ROM to RAM if 
necessary.  */ \
@@ -71,8 +71,8 @@
 %{msim:-lsim}  \
 %{!msim:-lnosys}   \
 --end-group\
-%{!T*:%{!msim:%{mmcu=*:--script=%*/memory.ld --script=%*/peripherals.ld}}} 
\
-%{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \
+%{!T*:%{!msim:%{mmcu=*:--script=%*.ld}}}   \
+%{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \
 %{!T*:%{msim:%{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}} \
 "
 
Index: config/msp430/t-msp430
===
--- config/msp430/t-msp430  (revision 206976)
+++ config/msp430/t-msp430  (working copy)
@@ -27,6 +27,14 @@
 MULTILIB_MATCHES= mcpu?msp430x=mcpu?msp430X
 MULTILIB_MATCHES   += mcpu?msp430x=mcpu?msp430xv2
 MULTILIB_MATCHES   += mcpu?msp430x=mcpu?msp430Xv2
+MULTILIB_MATCHES   += mcpu?msp430x=mmcu?msp430x
+MULTILIB_MATCHES   += mcpu?msp430x=mmcu?msp430X
+MULTILIB_MATCHES   += mcpu?msp430x=mmcu?msp430xv2
+MULTILIB_MATCHES   += mcpu?msp430x=mmcu?msp430Xv2
+MULTILIB_MATCHES   += mcpu?msp430x=mcpu?430x
+MULTILIB_MATCHES   += mcpu?msp430x=mcpu?430X
+MULTILIB_MATCHES   += mcpu?msp430x=mcpu?430xv2
+MULTILIB_MATCHES   += mcpu?msp430x=mcpu?430Xv2
 
 # Add additional MCU matches like this:
 # MULTILIB_MATCHES += mcpu?msp430x=mmcu?xx


Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals

2014-01-23 Thread Jakub Jelinek
On Wed, Jan 22, 2014 at 09:16:02AM +0100, Dodji Seketeli wrote:
> +static fcache*
> +add_file_to_cache_tab (const char *file_path)
> +{
> +
> +  FILE *fp = fopen (file_path, "r");
> +  if (ferror (fp))
> +{
> +  fclose (fp);
> +  return NULL;
> +}

I've seen various segfaults here when playing with preprocessed sources
from PRs (obviously don't have the original source files).
When fopen fails, it just returns NULL, so I don't see why you just don't
do
  if (fp == NULL)
return fp;

Jakub


[patch] fix libstdc++/59872

2014-01-23 Thread Jonathan Wakely

This fixes a recent regression introduced when I added C++ allocator
support to the RB trees.

Tested x86_64-linux, committed to trunk.

PR libstdc++/59872
* include/bits/stl_map.h (map::operator=(map&&)): Fix comment.
* include/bits/stl_multimap.h (multimap::operator=(multimap&&)):
Likewise.
* include/bits/stl_multiset.h (multiset::operator=(multiset&&)):
Likewise.
* include/bits/stl_set.h (set::operator=(set&&)): Likewise.
* include/bits/stl_tree.h (_Rb_tree::_M_move_data): New overloaded
functions to perform moving or copying of elements from rvalue tree.
(_Rb_tree::_Rb_tree(_Rb_tree&&)): Use _M_move_data.
(_Rb_tree::_Rb_tree(_Rb_tree&&, _Node_allocator&&)): Likewise.
* testsuite/23_containers/map/59872.cc: New.
* testsuite/23_containers/map/56613.cc: Remove duplicate include.

commit 9e5339a11e00a7ca3d1a648ea27749d0f317c345
Author: Jonathan Wakely 
Date:   Thu Jan 23 17:00:35 2014 +

PR libstdc++/59872
* include/bits/stl_map.h (map::operator=(map&&)): Fix comment.
* include/bits/stl_multimap.h (multimap::operator=(multimap&&)):
Likewise.
* include/bits/stl_multiset.h (multiset::operator=(multiset&&)):
Likewise.
* include/bits/stl_set.h (set::operator=(set&&)): Likewise.
* include/bits/stl_tree.h (_Rb_tree::_M_move_data): New overloaded
functions to perform moving or copying of elements from rvalue tree.
(_Rb_tree::_Rb_tree(_Rb_tree&&)): Use _M_move_data.
(_Rb_tree::_Rb_tree(_Rb_tree&&, _Node_allocator&&)): Likewise.
* testsuite/23_containers/map/59872.cc: New.
* testsuite/23_containers/map/56613.cc: Remove duplicate include.

diff --git a/libstdc++-v3/include/bits/stl_map.h 
b/libstdc++-v3/include/bits/stl_map.h
index e261be8..fa121e2 100644
--- a/libstdc++-v3/include/bits/stl_map.h
+++ b/libstdc++-v3/include/bits/stl_map.h
@@ -301,8 +301,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  %Map move assignment operator.
*  @param  __x  A %map of identical element and allocator types.
*
-   *  The contents of @a __x are moved into this map (without copying).
-   *  @a __x is a valid, but unspecified %map.
+   *  The contents of @a __x are moved into this map (without copying
+   *  if the allocators compare equal or get moved on assignment).
+   *  Afterwards @a __x is in a valid, but unspecified state.
*/
   map&
   operator=(map&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
diff --git a/libstdc++-v3/include/bits/stl_multimap.h 
b/libstdc++-v3/include/bits/stl_multimap.h
index 84046cb..e4575c1 100644
--- a/libstdc++-v3/include/bits/stl_multimap.h
+++ b/libstdc++-v3/include/bits/stl_multimap.h
@@ -295,8 +295,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  %Multimap move assignment operator.
*  @param  __x  A %multimap of identical element and allocator types.
*
-   *  The contents of @a __x are moved into this multimap (without 
copying).
-   *  @a __x is a valid, but unspecified multimap.
+   *  The contents of @a __x are moved into this multimap (without copying
+   *  if the allocators compare equal or get moved on assignment).
+   *  Afterwards @a __x is in a valid, but unspecified state.
*/
   multimap&
   operator=(multimap&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
diff --git a/libstdc++-v3/include/bits/stl_multiset.h 
b/libstdc++-v3/include/bits/stl_multiset.h
index 3305107..6d71c1b 100644
--- a/libstdc++-v3/include/bits/stl_multiset.h
+++ b/libstdc++-v3/include/bits/stl_multiset.h
@@ -267,9 +267,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief  %Multiset move assignment operator.
*  @param  __x  A %multiset of identical element and allocator types.
*
-   *  The contents of @a __x are moved into this %multiset
-   *  (without copying).  @a __x is a valid, but unspecified
-   *  %multiset.
+   *  The contents of @a __x are moved into this %multiset (without
+   *  copying if the allocators compare equal or get moved on assignment).
+   *  Afterwards @a __x is in a valid, but unspecified state.
*/
   multiset&
   operator=(multiset&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
diff --git a/libstdc++-v3/include/bits/stl_set.h 
b/libstdc++-v3/include/bits/stl_set.h
index 652be58..3a39154 100644
--- a/libstdc++-v3/include/bits/stl_set.h
+++ b/libstdc++-v3/include/bits/stl_set.h
@@ -271,8 +271,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  @brief %Set move assignment operator.
*  @param __x  A %set of identical element and allocator types.
*
-   *  The contents of @a __x are moved into this %set (without copying).
-   *  @a __x is a valid, but unspecified %set.
+   *  The contents of @a __x are moved into this %set (without copying
+   *  if the allocators co

Re: [C PATCH] Disallow subtracting pointers to empty structs (PR c/58346)

2014-01-23 Thread Joseph S. Myers
On Thu, 23 Jan 2014, Marek Polacek wrote:

> > 2014-01-16  Marek Polacek  
> > 
> > PR c/58346
> > c-family/
> > * c-common.c (pointer_to_zero_sized_aggr_p): New function.
> > * c-common.h: Declare it.
> > cp/
> > * typeck.c (pointer_diff): Give an error on arithmetic on pointer to
> > an empty aggregate.
> > c/
> > * c-typeck.c (pointer_diff): Give an error on arithmetic on pointer to
> > an empty aggregate.
> > testsuite/
> > * c-c++-common/pr58346-1.c: New test.
> > * c-c++-common/pr58346-2.c: New test.
> > * c-c++-common/pr58346-3.c: New test.

OK.

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


Re: [C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread Joseph S. Myers
On Thu, 23 Jan 2014, Marek Polacek wrote:

> shorten_compare can produce a better locinfo if we pass location
> from {,cp_}build_binary_op to it; op0/op1 there don't have location.
> Furthermore, I see no reason why use input_location in
> parser_build_binary_op when we can use more accurate location.
> 
> I don't know if/how I can test the column info using dejagnu, so
> no testcase attached.  But to give you an idea, instead of

The approach used is

/* { dg-warning "14:comparison is always false" } */

or similar, with the column number put at the start of the dg-error / 
dg-warning text.

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


Re: [C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-23 Thread Joseph S. Myers
On Wed, 22 Jan 2014, Marek Polacek wrote:

> 2014-01-22  Marek Polacek  
> 
>   PR c/59871
> c/
>   * c-typeck.c (build_compound_expr): Warn even for right-hand operand
>   of a comma expression.
>   (emit_side_effect_warnings): Likewise.
> libdecnumber/
>   * decNumberLocal.h (UBFROMUS, UBFROMUI): Remove last argument.
> testsuite/
>   * gcc.dg/20020220-2.c: Adjust dg-warning message.
>   * gcc.dg/pr59871.c: New test.

OK.

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


Re: [PATCH] add __attribute__ ((designated_init))

2014-01-23 Thread Joseph S. Myers
On Mon, 20 Jan 2014, Tom Tromey wrote:

> I wrote a new test case covering the same cases that the sparse test
> case covers.  I also added tests for applying the attribute to
> non-struct types; note that in this case sparse issues a warning but
> gcc issues an error.  I think an error is more appropriate.

I think the test should also cover cases with designators such as .d.x = 
1.

> +static tree handle_designated_init (tree *, tree, tree, int, bool *);

handle_designated_init_attribute would seem a better name.

> +  error ("designated_init attribute is only valid on struct type");

% (or use %qE with the attribute name as passed to the 
function, as is usual for such diagnostics).

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


[PATCH] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov

Hi all.

Jakub, could you review these patches, if they are OK to gomp-4_0-branch?

Thomas, please, have a look whether this implementation applies current 
OpenACC support style.


These patches port OpenACC 1.0 support in fortran front-end from 
openacc-1_0-branch to gomp-4_0-branch. In addition, they extend 
middle-end infrastructure with necessary GENERIC nodes.


Patches support almost all directives (except loop) and all clauses from 
the specification ver. 1.0 (without subarrays).


In addition to OpenACC version 1.0, patches add functionality from 
OpenACC 2.0: enter data and exit data directives.


Patches stub gimplification of OpenACC constructs and directives, except 
OACC_PARALLEL node, to prevent crashes.


I didn't port loop directive, since in openacc-1_0-branch we consider it 
as OpenACC construct, like kernels or parallel. Hence, OpenACC loop and 
OpenMP for directives differ. It means there are no checks in C FE (in 
openacc-1_0-branch) and the functionality will be modified, in both FEs 
and back-end.


As far as loop directive doesn't exist in GENERIC, fortran FE doesn't 
transform it from internal EXEC_OACC_LOOP statement. Consequenly, there 
are no tests to check the directive.


Lately, I'm going to port loop directive, too.

Inspite of the fact that subarrays do exist in openacc-1_0-branch, they 
don't present in patches. Currently, we are using our own GENERIC nodes 
to represent subarrays. I'm going to replace them with existing 
functionality, like ARRAY_RANGE_REF.


Full list of supported fuctionality is the following:

Constructs/directives:

Namefront-end   GENERIC tests
parallelY   Y   Y
kernels Y   Y   Y
dataY   Y   Y
host_data   Y   Y   Y
loopY   N   N
update  Y   Y   Y
waitY   Y   N
cache   Y   Y   N
declare Y   Y   Y
kernels loopY   N   N
parallel loop   Y   N   N
enter data (2.0)Y   Y   Y
exit data (2.0) Y   Y   Y

Clauses
Namefront-end   GENERIC tests
async   Y   Y   Y
waitY   Y   Y
num_gangs   Y   Y   Y
num_workers Y   Y   Y
vector_length   Y   Y   Y
if  Y   Y   Y
reduction   Y   Y   Y
copyY   Y   Y
copyin  Y   Y   Y
copyout Y   Y   Y
create  Y   Y   Y
delete (2.0)Y   Y   Y
present Y   Y   Y
present_or_copy Y   Y   Y
present_or_copyin   Y   Y   Y
present_or_copyout  Y   Y   Y
present_or_create   Y   Y   Y
deviceptr   Y   Y   Y
private Y   Y   Y
firstprivateY   Y   Y
default(none) (2.0) Y   N   Y
collapseY   Y   N
gangY   Y   N
worker  Y   Y   N
vector  Y   Y   N
seq Y   Y   N
auto (2.0)  Y   N   N
tileY   N   N
independent Y   Y   N
device_resident Y   Y   N

 


Successfully bootstraps on x86_64 with no regressions.

OK to commit?

--
Ilmir



[PATCH 2/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From 69bf2531e4512b7cdb2feba8541de1eaf9c2aa56 Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:05:11 +0400
Subject: [PATCH 2/6] OpenACC fortran FE part 2

---
 gcc/fortran/openmp.c | 1032 +-
 1 file changed, 1019 insertions(+), 13 deletions(-)

diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 6c4dccb..ce13e52 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -69,11 +69,36 @@ gfc_free_omp_clauses (gfc_omp_clauses *c)
   gfc_free_expr (c->final_expr);
   gfc_free_expr (c->num_threads);
   gfc_free_expr (c->chunk_size);
-  for (i = 0; i < OMP_LIST_NUM; i++)
+  gfc_free_expr (c->async_expr);
+  gfc_free_expr (c->gang_expr);
+  gfc_free_expr (c->worker_expr);
+  gfc_free_expr (c->vector_expr);
+  gfc_free_expr (c->num_gangs_expr);
+  gfc_free_expr (c->num_workers_expr);
+  gfc_free_expr (c->vector_length_expr);
+  gfc_free_expr (c->non_clause_wait_expr);
+
+  for (i = 0; i < OACC_LIST_NUM; i++)
 gfc_free_namelist (c->lists[i]);
+
+  gfc_free_exprlist (c->waitlist);
+
   free (c);
 }
 
+/* Free expression list. */
+void
+gfc_free_exprlist (gfc_exprlist *list)
+{
+  gfc_exprlist *n;
+
+  for (; list; list = n)
+{
+  n = list->next;
+  free (list);
+}
+}
+
 /* Match a variable/common block list and construct a namelist from it.  */
 
 static match
@@ -169,6 +194,87 @@ cleanup:
   return MATCH_ERROR;
 }
 
+static match
+match_oacc_exprlist (const char *str, gfc_exprlist **list, bool allow_asterisk)
+{
+  gfc_exprlist *head, *tail, *p;
+  locus old_loc;
+  gfc_expr *expr;
+  match m;
+
+  head = tail = NULL;
+
+  old_loc = gfc_current_locus;
+
+  m = gfc_match (str);
+  if (m != MATCH_YES)
+return m;
+
+  for (;;)
+{
+  m = gfc_match_expr (&expr);
+  if (m == MATCH_YES || allow_asterisk)
+{
+  p = gfc_get_exprlist ();
+  if (head == NULL)
+head = tail = p;
+  else
+{
+  tail->next = p;
+  tail = tail->next;
+}
+  if (m == MATCH_YES)
+tail->expr = expr;
+  else if (gfc_match (" *") != MATCH_YES)
+goto syntax;
+  goto next_item;
+}
+  if (m == MATCH_ERROR)
+goto cleanup;
+  goto syntax;
+
+next_item:
+  if (gfc_match_char (')') == MATCH_YES)
+break;
+  if (gfc_match_char (',') != MATCH_YES)
+goto syntax;
+}
+
+  while (*list)
+list = &(*list)->next;
+
+  *list = head;
+  return MATCH_YES;
+
+syntax:
+  gfc_error ("Syntax error in OpenACC expression list at %C");
+
+cleanup:
+  gfc_free_exprlist (head);
+  gfc_current_locus = old_loc;
+  return MATCH_ERROR;
+}
+
+static match
+match_oacc_clause_gang (gfc_oacc_clauses *cp)
+{
+  if (gfc_match_char ('(') != MATCH_YES)
+return MATCH_NO;
+  if (gfc_match (" num :") == MATCH_YES)
+{
+  cp->gang_static = false;
+  return gfc_match (" %e )", &cp->gang_expr);
+}
+  if (gfc_match (" static :") == MATCH_YES)
+{
+  cp->gang_static = true;
+  if (gfc_match (" * )") != MATCH_YES)
+return gfc_match (" %e )", &cp->gang_expr);
+  return MATCH_YES;
+}
+  return gfc_match (" %e )", &cp->gang_expr);
+}
+
 #define OMP_CLAUSE_PRIVATE	(1 << 0)
 #define OMP_CLAUSE_FIRSTPRIVATE	(1 << 1)
 #define OMP_CLAUSE_LASTPRIVATE	(1 << 2)
@@ -186,15 +292,51 @@ cleanup:
 #define OMP_CLAUSE_FINAL	(1 << 14)
 #define OMP_CLAUSE_MERGEABLE	(1 << 15)
 
+/* OpenACC 2.0 clauses. */
+#define OACC_CLAUSE_IF   OMP_CLAUSE_IF
+#define OACC_CLAUSE_ASYNC(1 << 16)
+#define OACC_CLAUSE_NUM_GANGS(1 << 17)
+#define OACC_CLAUSE_NUM_WORKERS  (1 << 18)
+#define OACC_CLAUSE_VECTOR_LENGTH(1 << 19)
+#define OACC_CLAUSE_REDUCTIONOMP_CLAUSE_REDUCTION
+#define OACC_CLAUSE_COPY (1 << 20)
+#define OACC_CLAUSE_COPYIN   OMP_CLAUSE_COPYIN
+#define OACC_CLAUSE_COPYOUT  (1 << 21)
+#define OACC_CLAUSE_CREATE   (1 << 22)
+#define OACC_CLAUSE_PRESENT  (1 << 23)
+#define OACC_CLAUSE_PRESENT_OR_COPY  (1 << 24)
+#define OACC_CLAUSE_PRESENT_OR_COPYIN(1 << 25)
+#define OACC_CLAUSE_PRESENT_OR_COPYOUT   (1 << 26)
+#define OACC_CLAUSE_PRESENT_OR_CREATE(1 << 27)
+#define OACC_CLAUSE_DEVICEPTR(1 << 28)
+#define OACC_CLAUSE_PRIVATE  OMP_CLAUSE_PRIVATE
+#define OACC_CLAUSE_FIRSTPRIVATE OMP_CLAUSE_FIRSTPRIVATE
+#define OACC_CLAUSE_COLLAPSE OMP_CLAUSE_COLLAPSE
+#define OACC_CLAUSE_GANG (1 << 29)
+#define OACC_CLAUSE_WORKER   (1 << 30)
+#define OACC_CLAUSE_VECTOR   (1 << 31)
+#define OACC_CLAUSE_SEQ  (1ll << 32)
+#define OACC_CLAUSE_INDEPENDENT  (1ll << 33)
+#define OACC_CLAUSE_USE_DEVICE   (1ll << 34)
+#define OACC_CLAUSE_DEVICE_RESIDENT  (1ll << 35)
+#define OACC_CLAUSE_HOST (1ll << 36)
+#define OA

[PATCH 1/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From 84dc72f88c1b23ae995afdda0b946ebd73af102f Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:04:37 +0400
Subject: [PATCH 1/6] OpenACC fortran FE part 1

---
 gcc/fortran/decl.c|   1 +
 gcc/fortran/dump-parse-tree.c | 203 
 gcc/fortran/gfortran.h|  81 +++-
 gcc/fortran/match.c   |  34 +++-
 gcc/fortran/match.h   |  15 ++
 gcc/fortran/parse.c   | 425 ++
 gcc/fortran/parse.h   |   4 +-
 gcc/fortran/resolve.c |  36 
 gcc/fortran/scanner.c | 382 +
 gcc/fortran/st.c  |  14 +-
 10 files changed, 1082 insertions(+), 113 deletions(-)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 0a0f8e0..e988983 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -6000,6 +6000,7 @@ gfc_match_end (gfc_statement *st)
 
 case COMP_CONTAINS:
 case COMP_DERIVED_CONTAINS:
+case COMP_OACC_STRUCTURED_BLOCK:
   state = gfc_state_stack->previous->state;
   block_name = gfc_state_stack->previous->sym == NULL
 		 ? NULL : gfc_state_stack->previous->sym->name;
diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index 14ff004..74be9ba 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -1230,6 +1230,194 @@ show_omp_node (int level, gfc_code *c)
 fprintf (dumpfile, " (%s)", c->ext.omp_name);
 }
 
+/* Show a single OpenACC directive node and everything underneath it
+   if necessary.  */
+
+static void
+show_oacc_node (int level, gfc_code *c)
+{
+  gfc_oacc_clauses *acc_clauses = NULL;
+  const char *name = NULL;
+
+  switch (c->op)
+{
+case EXEC_OACC_PARALLEL_LOOP: name = "PARALLEL LOOP"; break;
+case EXEC_OACC_PARALLEL: name = "PARALLEL"; break;
+case EXEC_OACC_KERNELS_LOOP: name = "KERNELS LOOP"; break;
+case EXEC_OACC_KERNELS: name = "KERNELS"; break;
+case EXEC_OACC_DATA: name = "DATA"; break;
+case EXEC_OACC_HOST_DATA: name = "HOST_DATA"; break;
+case EXEC_OACC_LOOP: name = "LOOP"; break;
+case EXEC_OACC_UPDATE: name = "UPDATE"; break;
+case EXEC_OACC_WAIT: name = "WAIT"; break;
+case EXEC_OACC_CACHE: name = "CACHE"; break;
+case EXEC_OACC_ENTER_DATA: name = "ENTER DATA"; break;
+case EXEC_OACC_EXIT_DATA: name = "EXIT DATA"; break;
+default:
+  gcc_unreachable ();
+}
+  fprintf (dumpfile, "!$ACC %s", name);
+  acc_clauses = c->ext.omp_clauses;
+  if (acc_clauses)
+{
+  int list;
+
+  if (acc_clauses->if_expr)
+{
+  fputs (" IF(", dumpfile);
+  show_expr (acc_clauses->if_expr);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->async)
+{
+  fputs (" ASYNC", dumpfile);
+  if (acc_clauses->async_expr)
+{
+  fputc ('(', dumpfile);
+  show_expr (acc_clauses->async_expr);
+  fputc (')', dumpfile);
+}
+}
+  if (acc_clauses->num_gangs_expr)
+{
+  fputs (" NUM_GANGS(", dumpfile);
+  show_expr (acc_clauses->num_gangs_expr);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->num_workers_expr)
+{
+  fputs (" NUM_WORKERS(", dumpfile);
+  show_expr (acc_clauses->num_workers_expr);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->vector_length_expr)
+{
+  fputs (" VECTOR_LENGTH(", dumpfile);
+  show_expr (acc_clauses->vector_length_expr);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->collapse)
+{
+  fputs (" COLLAPSE(", dumpfile);
+  fprintf (dumpfile, "%d", acc_clauses->collapse);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->gang)
+{
+  fputs (" GANG", dumpfile);
+  if (acc_clauses->gang_expr)
+{
+  fputc ('(', dumpfile);
+  show_expr (acc_clauses->gang_expr);
+  fputc (')', dumpfile);
+}
+}
+  if (acc_clauses->worker)
+{
+  fputs (" WORKER", dumpfile);
+  if (acc_clauses->worker_expr)
+{
+  fputc ('(', dumpfile);
+  show_expr (acc_clauses->worker_expr);
+  fputc (')', dumpfile);
+}
+}
+  if (acc_clauses->vector)
+{
+  fputs (" VECTOR", dumpfile);
+  if (acc_clauses->vector_expr)
+{
+  fputc ('(', dumpfile);
+  show_expr (acc_clauses->vector_expr);
+  fputc (')', dumpfile);
+}
+}
+  if (acc_clauses->non_clause_wait_expr)
+{
+  fputc ('(', dumpfile);
+  show_expr (acc_clauses->non_clause_wait_expr);
+  fputc (')', dumpfile);
+}
+  if (acc_clauses->seq)
+fputs (" SEQ", dumpfile);
+  if (acc_clauses->independent)
+fputs 

[PATCH 3/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From 0658580cf665b8da8cc4533901989b7a1d54f73a Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:06:00 +0400
Subject: [PATCH 3/6] OpenACC fortran FE part 3

---
 gcc/fortran/trans-decl.c   |   7 +
 gcc/fortran/trans-openmp.c | 526 -
 gcc/fortran/trans-stmt.h   |   4 +
 gcc/fortran/trans.c|  15 ++
 4 files changed, 543 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index f974c6e..a7dde4f 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5529,6 +5529,13 @@ gfc_generate_function_code (gfc_namespace * ns)
   if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) && !sym->attr.is_bind_c)
 add_argument_checking (&body, sym);
 
+  /* Generate !$ACC DECLARE directive. */
+  if (ns->declare_clauses)
+{
+  tmp = gfc_trans_oacc_declare(&body, ns);
+  gfc_add_expr_to_block(&body, tmp);
+}
+
   tmp = gfc_trans_code (ns->code);
   gfc_add_expr_to_block (&body, tmp);
 
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index d23af17..c43b375 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -418,6 +418,12 @@ gfc_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *ctx, tree type)
 }
 }
 
+static inline tree 
+gfc_trans_oacc_add_clause (tree node, tree tail)
+{
+  OACC_CLAUSE_CHAIN (node) = tail;
+  return node;
+}
 
 static inline tree
 gfc_trans_add_clause (tree node, tree tail)
@@ -480,6 +486,27 @@ gfc_trans_omp_variable (gfc_symbol *sym)
   return t;
 }
 
+static inline tree 
+gfc_trans_oacc_variable (gfc_symbol *sym)
+{
+  return gfc_trans_omp_variable (sym);
+}
+
+static inline tree
+gfc_convert_oacc_expr_to_tree (stmtblock_t *block, gfc_expr *expr)
+{
+  gfc_se se;
+  tree result;
+
+  gfc_init_se (&se, NULL );
+  gfc_conv_expr (&se, expr);
+  gfc_add_block_to_block (block, &se.pre);
+  result = gfc_evaluate_now (se.expr, block);
+  gfc_add_block_to_block (block, &se.post);
+
+  return result;
+}
+
 static tree
 gfc_trans_omp_variable_list (enum omp_clause_code code, gfc_namelist *namelist,
 			 tree list)
@@ -498,20 +525,33 @@ gfc_trans_omp_variable_list (enum omp_clause_code code, gfc_namelist *namelist,
   return list;
 }
 
+static tree
+gfc_trans_oacc_variable_list (enum omp_clause_code code, 
+  gfc_namelist *namelist, tree list)
+{
+  return gfc_trans_omp_variable_list (code, namelist, list);
+}
+
 static void
-gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
+gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where, 
+   bool is_acc)
 {
   gfc_symtree *root1 = NULL, *root2 = NULL, *root3 = NULL, *root4 = NULL;
   gfc_symtree *symtree1, *symtree2, *symtree3, *symtree4 = NULL;
   gfc_symbol init_val_sym, outer_sym, intrinsic_sym;
   gfc_expr *e1, *e2, *e3, *e4;
   gfc_ref *ref;
-  tree decl, backend_decl, stmt, type, outer_decl;
+  tree decl, backend_decl, stmt, type, outer_decl, prev_decl;
+  enum tree_code reduction_code;
   locus old_loc = gfc_current_locus;
   const char *iname;
   bool t;
 
-  decl = OMP_CLAUSE_DECL (c);
+  if (is_acc)
+decl = prev_decl = OACC_CLAUSE_DECL (c);
+  else
+decl = prev_decl = OMP_CLAUSE_DECL (c);
+
   gfc_current_locus = where;
   type = TREE_TYPE (decl);
   outer_decl = create_tmp_var_raw (type, NULL);
@@ -542,7 +582,7 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
   outer_sym.attr.result = 0;
   outer_sym.attr.flavor = FL_VARIABLE;
   outer_sym.backend_decl = outer_decl;
-  if (decl != OMP_CLAUSE_DECL (c))
+  if (decl != prev_decl)
 outer_sym.backend_decl = build_fold_indirect_ref (outer_decl);
 
   /* Create fake symtrees for it.  */
@@ -587,7 +627,12 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
   gcc_assert (t);
 
   iname = NULL;
-  switch (OMP_CLAUSE_REDUCTION_CODE (c))
+  if (is_acc)
+reduction_code = OACC_CLAUSE_REDUCTION_CODE (c);
+  else
+reduction_code = OMP_CLAUSE_REDUCTION_CODE (c);
+
+  switch (reduction_code)
 {
 case PLUS_EXPR:
 case MINUS_EXPR:
@@ -702,7 +747,11 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
 stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
 poplevel (0, 0);
-  OMP_CLAUSE_REDUCTION_INIT (c) = stmt;
+
+  if (is_acc)
+OACC_CLAUSE_REDUCTION_INIT (c) = stmt;
+  else
+OMP_CLAUSE_REDUCTION_INIT (c) = stmt;
 
   /* Create the merge statement list.  */
   pushlevel ();
@@ -726,10 +775,18 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, locus where)
 stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   else
 poplevel (0, 0);
-  OMP_CLAUSE_REDUCTION_MERGE (c) = stmt;
 
   /* And stick the placeholder VAR_DECL into the clause as well.  */
-  OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = outer_decl;
+  if (is_acc)
+{
+  OACC_CLAUSE_REDUCTION_MERGE (c) = stmt;
+  OACC_CLAUSE_REDUCTION_PLAC

[PATCH 4/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From 37806068fffcab95a21b51829c900d49be14961d Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:08:05 +0400
Subject: [PATCH 4/6] OpenACC GENERIC nodes

---
 gcc/gimplify.c  |  73 
 gcc/omp-low.c   |  84 --
 gcc/tree-core.h | 106 +-
 gcc/tree-pretty-print.c | 286 +++-
 gcc/tree-pretty-print.h |   7 ++
 gcc/tree.c  |  96 ++--
 gcc/tree.def|  50 +
 gcc/tree.h  |  95 +++-
 8 files changed, 770 insertions(+), 27 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e45bed2..8af4368 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4274,6 +4274,15 @@ is_gimple_stmt (tree t)
 case ASM_EXPR:
 case STATEMENT_LIST:
 case OACC_PARALLEL:
+case OACC_KERNELS:
+case OACC_DATA:
+case OACC_CACHE:
+case OACC_WAIT:
+case OACC_HOST_DATA:
+case OACC_DECLARE:
+case OACC_UPDATE:
+case OACC_ENTER_DATA:
+case OACC_EXIT_DATA:
 case OMP_PARALLEL:
 case OMP_FOR:
 case OMP_SIMD:
@@ -6025,6 +6034,32 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 	remove = true;
 	  break;
 
+  case OACC_CLAUSE_COPY:
+  case OACC_CLAUSE_COPYOUT:
+  case OACC_CLAUSE_CREATE:
+  case OACC_CLAUSE_PRESENT:
+  case OACC_CLAUSE_PRESENT_OR_COPY:
+  case OACC_CLAUSE_PRESENT_OR_COPYIN:
+  case OACC_CLAUSE_PRESENT_OR_COPYOUT:
+  case OACC_CLAUSE_PRESENT_OR_CREATE:
+  case OACC_CLAUSE_HOST:
+  case OACC_CLAUSE_DEVICE:
+  case OACC_CLAUSE_DEVICEPTR:
+  case OACC_CLAUSE_DEVICE_RESIDENT:
+  case OACC_CLAUSE_USE_DEVICE:
+  case OACC_CLAUSE_DELETE:
+  case OACC_CLAUSE_ASYNC:
+  case OACC_CLAUSE_GANG:
+  case OACC_CLAUSE_WAIT:
+  case OACC_NO_CLAUSE_WAIT:
+  case OACC_NO_CLAUSE_CACHE:
+  case OACC_CLAUSE_SEQ:
+  case OACC_CLAUSE_INDEPENDENT:
+  case OACC_CLAUSE_WORKER:
+  case OACC_CLAUSE_VECTOR:
+  case OACC_CLAUSE_NUM_GANGS:
+  case OACC_CLAUSE_NUM_WORKERS:
+  case OACC_CLAUSE_VECTOR_LENGTH:
 	case OMP_CLAUSE_NOWAIT:
 	case OMP_CLAUSE_ORDERED:
 	case OMP_CLAUSE_UNTIED:
@@ -6339,6 +6374,32 @@ gimplify_adjust_omp_clauses (tree *list_p)
 	}
 	  break;
 
+  case OACC_CLAUSE_COPY:
+  case OACC_CLAUSE_COPYOUT:
+  case OACC_CLAUSE_CREATE:
+  case OACC_CLAUSE_PRESENT:
+  case OACC_CLAUSE_PRESENT_OR_COPY:
+  case OACC_CLAUSE_PRESENT_OR_COPYIN:
+  case OACC_CLAUSE_PRESENT_OR_COPYOUT:
+  case OACC_CLAUSE_PRESENT_OR_CREATE:
+  case OACC_CLAUSE_HOST:
+  case OACC_CLAUSE_DEVICE:
+  case OACC_CLAUSE_DEVICEPTR:
+  case OACC_CLAUSE_DEVICE_RESIDENT:
+  case OACC_CLAUSE_USE_DEVICE:
+  case OACC_CLAUSE_DELETE:
+  case OACC_CLAUSE_ASYNC:
+  case OACC_CLAUSE_GANG:
+  case OACC_CLAUSE_WAIT:
+  case OACC_NO_CLAUSE_WAIT:
+  case OACC_NO_CLAUSE_CACHE:
+  case OACC_CLAUSE_SEQ:
+  case OACC_CLAUSE_INDEPENDENT:
+  case OACC_CLAUSE_WORKER:
+  case OACC_CLAUSE_VECTOR:
+  case OACC_CLAUSE_NUM_GANGS:
+  case OACC_CLAUSE_NUM_WORKERS:
+  case OACC_CLAUSE_VECTOR_LENGTH:
 	case OMP_CLAUSE_REDUCTION:
 	case OMP_CLAUSE_COPYIN:
 	case OMP_CLAUSE_COPYPRIVATE:
@@ -7846,6 +7907,18 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	  ret = GS_ALL_DONE;
 	  break;
 
+  case OACC_KERNELS:
+  case OACC_DATA:
+  case OACC_CACHE:
+  case OACC_WAIT:
+  case OACC_HOST_DATA:
+  case OACC_DECLARE:
+  case OACC_UPDATE:
+  case OACC_ENTER_DATA:
+  case OACC_EXIT_DATA:
+ret = GS_ALL_DONE;
+break;
+
 	case OMP_PARALLEL:
 	  gimplify_omp_parallel (expr_p, pre_p);
 	  ret = GS_ALL_DONE;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index eb755c3..6da5977 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1543,10 +1543,12 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	break;
 	  /* FALLTHRU */
 
-	case OMP_CLAUSE_FIRSTPRIVATE:
-	case OMP_CLAUSE_REDUCTION:
 	case OMP_CLAUSE_LINEAR:
 	  gcc_assert (gimple_code (ctx->stmt) != GIMPLE_OACC_PARALLEL);
+/* FALLTHRU. */
+
+  case OMP_CLAUSE_FIRSTPRIVATE: /* == OACC_CLAUSE_FIRSTPRIVATE. */
+  case OMP_CLAUSE_REDUCTION: /* == OACC_CLAUSE_REDUCTION. */
 	  decl = OMP_CLAUSE_DECL (c);
 	do_private:
 	  if (is_variable_sized (decl))
@@ -1583,8 +1585,10 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	  break;
 
 	case OMP_CLAUSE_COPYPRIVATE:
-	case OMP_CLAUSE_COPYIN:
 	  gcc_assert (gimple_code (ctx->stmt) != GIMPLE_OACC_PARALLEL);
+/* FALLTHRU. */
+
+  case OMP_CLAUSE_COPYIN: /* == OACC_CLAUSE_COPYIN. */
 	  decl = OMP_CLAUSE_DECL (c);
 	  by_ref = use_pointer_for_field (decl, NULL);
 	  install_var_field (decl, by_ref, 3, ctx);
@@ -1596,7 +1600,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	  break;
 
 	case OMP_CLAUSE_FINAL:
-	case OMP_CLAUSE_IF:
 	case OMP_CLAUSE_NUM_THREADS:
 	case OMP_CLAUSE_NUM_TEAMS:
 	case OMP_CLAUSE_THREAD_LIMIT:
@@ -1605,6 +1608,9 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 	case OMP_CLAUSE_DIST_SCHEDULE:
 	case OMP_CLAUSE_DEPEND:
 	  gcc_assert (gimple_code (ctx->stmt) != GIMPLE_O

[PATCH 5/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From ae0ba17c51f6ed3529976a0cdf8f80046d1ed9b7 Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:10:41 +0400
Subject: [PATCH 5/6] OpenACC fortran tests

---
 gcc/testsuite/gfortran.dg/goacc/branch.f95 |  55 +
 .../gfortran.dg/goacc/continuation-free-form.f95   |  24 ++
 gcc/testsuite/gfortran.dg/goacc/data-clauses.f95   | 261 +
 gcc/testsuite/gfortran.dg/goacc/data-tree.f95  |  32 +++
 gcc/testsuite/gfortran.dg/goacc/declare-1.f95  |  11 +
 gcc/testsuite/gfortran.dg/goacc/declare.f95|   9 +
 .../gfortran.dg/goacc/directive-names.f95  |  19 ++
 .../gfortran.dg/goacc/enter-exit-data.f95  |  89 +++
 gcc/testsuite/gfortran.dg/goacc/goacc.exp  |  36 +++
 gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95 |  12 +
 gcc/testsuite/gfortran.dg/goacc/if.f95 |  53 +
 gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95   |  33 +++
 gcc/testsuite/gfortran.dg/goacc/list.f95   | 111 +
 .../gfortran.dg/goacc/parallel-kernels-clauses.f95 |  96 
 .../gfortran.dg/goacc/parallel-kernels-regions.f95 |  56 +
 gcc/testsuite/gfortran.dg/goacc/parallel-tree.f95  |  41 
 .../goacc/pure-elemental-procedures.f95|  46 
 gcc/testsuite/gfortran.dg/goacc/reduction.f95  | 139 +++
 .../gfortran.dg/goacc/sentinel-free-form.f95   |  22 ++
 .../gfortran.dg/goacc/several-directives.f95   |   7 +
 gcc/testsuite/gfortran.dg/goacc/sie.f95| 252 
 21 files changed, 1404 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/branch.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/continuation-free-form.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/data-clauses.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/data-tree.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/declare-1.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/declare.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/directive-names.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/enter-exit-data.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/goacc.exp
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/if.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/list.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/parallel-kernels-clauses.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/parallel-kernels-regions.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/parallel-tree.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/pure-elemental-procedures.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/reduction.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/several-directives.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/sie.f95

diff --git a/gcc/testsuite/gfortran.dg/goacc/branch.f95 b/gcc/testsuite/gfortran.dg/goacc/branch.f95
new file mode 100644
index 000..e470ce2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/branch.f95
@@ -0,0 +1,55 @@
+! { dg-do compile } 
+! { dg-options "-fopenacc" } 
+
+program test
+	implicit none
+
+	integer :: i
+
+	if (.true.) then
+		!$acc parallel 
+	end if ! { dg-error "Unexpected" }
+	!$acc end parallel 
+	end if
+
+	if (.true.) then
+		!$acc kernels 
+	end if ! { dg-error "Unexpected" }
+	!$acc end kernels 
+	end if
+
+	!$acc parallel
+	if (.true.) then
+		!$acc end parallel ! { dg-error "Unexpected" }
+	end if 
+	!$acc end parallel
+
+	!$acc kernels
+	if (.true.) then
+		!$acc end kernels ! { dg-error "Unexpected" }
+	end if 
+	!$acc end kernels
+
+	!$acc parallel
+	if (.true.) then
+	end if
+	!$acc end parallel
+
+	!$acc kernels
+	if (.true.) then
+	end if
+	!$acc end kernels
+
+	if (.true.) then
+		!$acc parallel
+		!$acc end parallel
+	end if
+
+	if (.true.) then
+		!$acc kernels
+		!$acc end kernels
+	end if
+10	i = 0
+
+
+end program test 
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/goacc/continuation-free-form.f95 b/gcc/testsuite/gfortran.dg/goacc/continuation-free-form.f95
new file mode 100644
index 000..df32d9c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/continuation-free-form.f95
@@ -0,0 +1,24 @@
+! { dg-do compile } 
+! { dg-options "-fopenacc" } 
+
+program test
+	implicit none
+
+	integer :: i
+	real :: x
+
+	!$acc parallel &
+	!$acc loop & ! continuation
+	!$acc & reduction(+:x)
+
+	! this line must be ignored
+	!$acc ! kernels
+	do i = 1,10
+		x = x + 0.3
+	enddo
+	! continuation must begin with sentinel
+	!$acc end parallel & ! { dg-error "Unclassifiable OpenACC directive" }
+	! loop
+
+	print *, x
+end
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/goacc/data-clauses.f95 b/gcc/testsuite/gfortran.dg/goacc/data-clauses.f95
new file mode 1

[PATCH 6/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov


>From 668a50443d0a70a633707ec49759d9e8b6d00b1e Mon Sep 17 00:00:00 2001
From: Ilmir Usmanov 
Date: Thu, 23 Jan 2014 21:26:50 +0400
Subject: [PATCH 6/6] OpenACC GENERIC docs

---
 gcc/doc/generic.texi | 40 
 1 file changed, 40 insertions(+)

diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index d51033e..dd88489 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -2052,6 +2052,14 @@ edge.  Rethrowing the exception is represented using @code{RESX_EXPR}.
 @node OpenMP
 @subsection OpenMP
 @tindex OACC_PARALLEL
+@tindex OACC_KERNELS
+@tindex OACC_DATA
+@tindex OACC_HOST_DATA
+@tindex OACC_UPDATE
+@tindex OACC_ENTER_DATA
+@tindex OACC_EXIT_DATA
+@tindex OACC_WAIT
+@tindex OACC_CACHE
 @tindex OMP_PARALLEL
 @tindex OMP_FOR
 @tindex OMP_SECTIONS
@@ -2073,6 +2081,38 @@ clauses used by the OpenMP API @w{@uref{http://www.openmp.org/}}.
 
 Represents @code{#pragma acc parallel [clause1 @dots{} clauseN]}.
 
+@item OACC_KERNELS
+
+Represents @code{#pragma acc kernels [clause1 @dots{} clauseN]}.
+
+@item OACC_DATA
+
+Represents @code{#pragma acc data [clause1 @dots{} clauseN]}.
+
+@item OACC_HOST_DATA
+
+Represents @code{#pragma acc host_data [clause1 @dots{} clauseN]}.
+
+@item OACC_UPDATE
+
+Represents @code{#pragma acc update [clause1 @dots{} clauseN]}.
+
+@item OACC_ENTER_DATA
+
+Represents @code{#pragma acc enter data [clause1 @dots{} clauseN]}.
+
+@item OACC_EXIT_DATA
+
+Represents @code{#pragma acc exit data [clause1 @dots{} clauseN]}.
+
+@item OACC_WAIT
+
+Represents @code{#pragma acc wait [(num @dots{})]}.
+
+@item OACC_CACHE
+
+Represents @code{#pragma acc cache (var @dots{})}.
+
 @item OMP_PARALLEL
 
 Represents @code{#pragma omp parallel [clause1 @dots{} clauseN]}. It
-- 
1.8.3.2



[PATCH 7/6] [GOMP4] OpenACC 1.0+ support in fortran front-end

2014-01-23 Thread Ilmir Usmanov

Finally, ChangeLog entry.


23-01-2014 Ilmir Usmanov 
Add OpenACC 1.0 support to fortran FE and GENERIC, except loop directive
and subarrays.

gcc/fortran/
* decl.c (gfc_match_end): Match end of OpenACC region.
* dump-parse-tree.c 
(show_oacc_node): New function to dump OpenACC executable statements.
(show_code_node): Call it.
* gfortran.h 
(ST_OACC_PARALLEL_LOOP, ST_OACC_END_PARALLEL_LOOP, ST_OACC_PARALLEL, 
ST_OACC_END_PARALLEL, ST_OACC_KERNELS, ST_OACC_END_KERNELS, 
ST_OACC_DATA, ST_OACC_END_DATA, ST_OACC_HOST_DATA, 
ST_OACC_END_HOST_DATA, ST_OACC_LOOP, ST_OACC_DECLARE, ST_OACC_UPDATE, 
ST_OACC_WAIT, ST_OACC_CACHE, ST_OACC_KERNELS_LOOP, 
ST_OACC_END_KERNELS_LOOP, ST_OACC_ENTER_DATA, 
ST_OACC_EXIT_DATA): New statements.
(gfc_exprlist): New structure to hold list of expressions.
(OACC_LIST_PRIVATE, OACC_LIST_REDUCTION_FIRST, 
OACC_LIST_REDUCTION_LAST, 
OACC_LIST_COPY, OACC_LIST_FIRST, OACC_LIST_DATA_CLAUSE_FIRST, 
OACC_LIST_COPYIN, OACC_LIST_COPYOUT, OACC_LIST_CREATE, OACC_LIST_DELETE,
OACC_LIST_PRESENT, OACC_LIST_PRESENT_OR_COPY, 
OACC_LIST_PRESENT_OR_COPYIN, OACC_LIST_PRESENT_OR_COPYOUT, 
OACC_LIST_PRESENT_OR_CREATE, OACC_LIST_DEVICEPTR, 
OACC_LIST_DATA_CLAUSE_LAST, OACC_LIST_USE_DEVICE,
OACC_LIST_DEVICE_RESIDENT, OACC_LIST_HOST, OACC_LIST_DEVICE, 
OACC_LIST_CACHE, OACC_LIST_NUM): New types of list, allowed in clauses.
(gfc_omp_clauses): Add OpenACC clauses.
(gfc_oacc_clauses): Pseudo structure.
(gfc_get_oacc_clauses): New function.
(gfc_namespace): Add OpenACC declare directive clauses.
(EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_PARALLEL,
EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA, EXEC_OACC_LOOP,
EXEC_OACC_UPDATE, EXEC_OACC_WAIT, EXEC_OACC_CACHE, EXEC_OACC_ENTER_DATA,
EXEC_OACC_EXIT_DATA): New executable statements.
(gfc_free_exprlist): New function declaration.
(gfc_resolve_oacc_directive): Likewise.
(gfc_resolve_oacc_parallel_loop_blocks): Likewise.
(gfc_resolve_oacc_blocks): Likewise.
* match.c (match_exit_cycle): Add support of OpenACC regions and loops.
* match.h (gfc_match_oacc_cache): New function declaration.
(gfc_match_oacc_wait, gfc_match_oacc_update): Likewise.
(gfc_match_oacc_declare, gfc_match_oacc_loop): Likewise.
(gfc_match_oacc_host_data, gfc_match_oacc_data): Likewise.
(gfc_match_oacc_kernels, gfc_match_oacc_kernels_loop): Likewise.
(gfc_match_oacc_parallel, gfc_match_oacc_parallel_loop): Likewise.
(gfc_match_oacc_enter_data, gfc_match_oacc_exit_data): Likewise.
* parse.c (decode_oacc_directive): New function.
(verify_token_free, verify_token_fixed): New helper functions.
(next_free, next_fixed): Decode !$ACC sentinel.
(case_executable): Add ST_OACC_UPDATE, ST_OACC_WAIT, ST_OACC_CACHE, 
ST_OACC_ENTER_DATA and ST_OACC_EXIT_DATA directives.
(case_exec_markers): Add ST_OACC_PARALLEL_LOOP, ST_OACC_PARALLEL, 
ST_OACC_KERNELS, ST_OACC_DATA, ST_OACC_HOST_DATA, ST_OACC_LOOP and 
ST_OACC_KERNELS_LOOP directives.
(push_state): Initialize OpenACC declare clauses.
(gfc_ascii_statement): Dump names of OpenACC directives.
(verify_st_order): Verify OpenACC declare directive as declarative.
(parse_spec): Push clauses to state stack when declare directive is 
parsed.
(parse_oacc_structured_block, parse_oacc_loop): New functions.
(parse_executable): Call them.
(parse_progunit): Move declare clauses from state stack to namespace.
* parse.h 
(COMP_OACC_STRUCTURED_BLOCK): New structured block to represent OpenACC 
region.
(gfc_state_data): Add declare directive's clauses.
* resolve.c (gfc_resolve_blocks): Resolve OpenACC directives.
(resolve_code): Likewise.
* scanner.c (openacc_flag, openacc_locus): New static variables.
(skip_oacc_attribute, skip_omp_attribute): New helper functions.
(skip_free_comments, skip_fixed_comments): Don't skip !$ACC sentinel.
(gfc_next_char_literal): Support OpenACC directives.
* st.c (gfc_free_statement): Free also OpenACC directives.
* openmp.c (gfc_free_omp_clauses): Remove also OpenACC clauses.
(gfc_free_exprlist): New function to clear expression list.
(match_oacc_exprlist): New function to match expression list.
(match_oacc_clause_gang): New function to match OpenACC 2.0 gang 
clauses.
(OACC_CLAUSE_IF, OACC_CLAUSE_ASYNC, OACC_CLAUSE_NUM_GANGS, 
OACC_CLAUSE_NUM_WORKERS, OACC_CLAUSE_VECTOR_LENGTH, 
OACC_CLAUSE_REDUCTION, OACC_CLAUSE_COPY, OACC_CLAUSE_COPYIN, 
OACC_CLAUSE_COPYOUT, OACC_CLAUSE_CREATE, OACC_CLAUSE_PRES

Re: [C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread Marek Polacek
On Thu, Jan 23, 2014 at 05:50:23PM +, Joseph S. Myers wrote:
> On Thu, 23 Jan 2014, Marek Polacek wrote:
> 
> > shorten_compare can produce a better locinfo if we pass location
> > from {,cp_}build_binary_op to it; op0/op1 there don't have location.
> > Furthermore, I see no reason why use input_location in
> > parser_build_binary_op when we can use more accurate location.
> > 
> > I don't know if/how I can test the column info using dejagnu, so
> > no testcase attached.  But to give you an idea, instead of
> 
> The approach used is
> 
> /* { dg-warning "14:comparison is always false" } */
> 
> or similar, with the column number put at the start of the dg-error / 
> dg-warning text.

Argh, not sure how I missed that.  So with a testcase this time.

OK now?

2014-01-23  Marek Polacek  

PR c/59846
c-family/
* c-common.c (shorten_compare): Add location_t parameter.
* c-common.h (shorten_binary_op): Adjust declaration.
cp/
* typeck.c (cp_build_binary_op): Pass location to shorten_compare.
c/
* c-typeck.c (parser_build_binary_op): Use location instead of
input_location.
(build_binary_op): Pass location to shorten_compare.
testsuite/
* gcc.dg/pr59846.c: New test.

--- gcc/c-family/c-common.h.mp  2014-01-23 16:19:49.936114468 +0100
+++ gcc/c-family/c-common.h 2014-01-23 19:31:26.276522298 +0100
@@ -799,7 +799,8 @@ extern tree shorten_binary_op (tree resu
 /* Subroutine of build_binary_op, used for comparison operations.
See if the operands have both been converted from subword integer types
and, if so, perhaps change them both back to their original type.  */
-extern tree shorten_compare (tree *, tree *, tree *, enum tree_code *);
+extern tree shorten_compare (location_t, tree *, tree *, tree *,
+enum tree_code *);
 
 extern tree pointer_int_sum (location_t, enum tree_code, tree, tree,
 bool = true);
--- gcc/c-family/c-common.c.mp  2014-01-23 16:19:49.935114463 +0100
+++ gcc/c-family/c-common.c 2014-01-23 19:31:26.279522313 +0100
@@ -3974,13 +3974,15 @@ expr_original_type (tree expr)
of build_binary_op: OP0_PTR is &OP0, OP1_PTR is &OP1,
RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE.
 
+   LOC is the location of the comparison.
+
If this function returns nonzero, it means that the comparison has
a constant value.  What this function returns is an expression for
that value.  */
 
 tree
-shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
-enum tree_code *rescode_ptr)
+shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr,
+tree *restype_ptr, enum tree_code *rescode_ptr)
 {
   tree type;
   tree op0 = *op0_ptr;
@@ -3989,7 +3991,6 @@ shorten_compare (tree *op0_ptr, tree *op
   int real1, real2;
   tree primop0, primop1;
   enum tree_code code = *rescode_ptr;
-  location_t loc = EXPR_LOC_OR_LOC (op0, input_location);
 
   /* Throw away any conversions to wider types
  already present in the operands.  */
--- gcc/cp/typeck.c.mp  2014-01-23 16:19:49.939114483 +0100
+++ gcc/cp/typeck.c 2014-01-23 19:31:26.312522476 +0100
@@ -4838,7 +4838,8 @@ cp_build_binary_op (location_t location,
  tree xop0 = op0, xop1 = op1, xresult_type = result_type;
  enum tree_code xresultcode = resultcode;
  tree val
-   = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
+   = shorten_compare (location, &xop0, &xop1, &xresult_type,
+  &xresultcode);
  if (val != 0)
return cp_convert (boolean_type_node, val, complain);
  op0 = xop0, op1 = xop1;
--- gcc/c/c-typeck.c.mp 2014-01-23 19:30:54.392378861 +0100
+++ gcc/c/c-typeck.c2014-01-23 19:31:26.324522535 +0100
@@ -3388,11 +3388,11 @@ parser_build_binary_op (location_t locat
   /* Check for cases such as x+y< p; /* { dg-warning "14:comparison is always false due to 
limited range of data type" } */
+}
+
+_Bool
+fn2 (unsigned int p)
+{
+  return 0UL <= p; /* { dg-warning "14:comparison is always true due to 
limited range of data type" } */
+}
+
+_Bool
+fn3 (unsigned int p)
+{
+  return p >= 0U; /* { dg-warning "12:comparison of unsigned expression >= 0 
is always true" } */
+}
+
+_Bool
+fn4 (unsigned int p)
+{
+  return p < 0U; /* { dg-warning "12:comparison of unsigned expression < 0 is 
always false" } */
+}
+
+_Bool
+fn5 (_Bool p)
+{
+  return p || !p; /* { dg-warning "12:logical" } */
+}
+
+_Bool
+fn6 (_Bool p)
+{
+  return p && !p; /* { dg-warning "12:logical" } */
+}

Marek


Re: [Patch] PR55189 enable -Wreturn-type by default

2014-01-23 Thread Jason Merrill

On 01/16/2014 02:44 PM, Jason Merrill wrote:

To avoid spurious warnings on code with infinite loops we could add a
simple check for infinite loops and suppress the warning in that case.
Basically, if we see a loop with an always-true condition and no breaks.


Like so:

Tested x86_64-pc-linux-gnu, applying to trunk.

commit 9e1ee1aae068265870982c7b615c9e18136ab38a
Author: Jason Merrill 
Date:   Thu Jan 16 16:39:58 2014 -0500

	PR c++/55189
	* cp-tree.h (struct language_function): Add infinite_loop and
	infinite_loops.
	(current_function_infinite_loop): New.
	* semantics.c (begin_maybe_infinite_loop, end_maybe_infinite_loop)
	(break_maybe_infinite_loop): New.
	(finish_while_stmt_cond, finish_while_stmt, begin_do_stmt)
	(finish_do_stmt, finish_for_cond, finish_for_stmt)
	(begin_range_for_stmt): Use them.
	* decl.c (finish_function): Don't warn about missing return
	if current_function_infinite_loop.
	* pt.c (instantiate_decl): Copy current_function_infinite_loop.
	* parser.c (cp_parser_jump_statement): Call break_maybe_infinite_loop.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 96af562f..ab75db8 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1127,6 +1127,7 @@ struct GTY(()) language_function {
   BOOL_BITFIELD returns_value : 1;
   BOOL_BITFIELD returns_null : 1;
   BOOL_BITFIELD returns_abnormally : 1;
+  BOOL_BITFIELD infinite_loop: 1;
   BOOL_BITFIELD x_in_function_try_handler : 1;
   BOOL_BITFIELD x_in_base_initializer : 1;
 
@@ -1136,6 +1137,9 @@ struct GTY(()) language_function {
   htab_t GTY((param_is(struct named_label_entry))) x_named_labels;
   cp_binding_level *bindings;
   vec *x_local_names;
+  /* Tracking possibly infinite loops.  This is a vec only because
+ vec doesn't work with gtype.  */
+  vec *infinite_loops;
   htab_t GTY((param_is (struct cxx_int_tree_map))) extern_decl_map;
 };
 
@@ -1194,6 +1198,12 @@ struct GTY(()) language_function {
 #define current_function_returns_abnormally \
   cp_function_chain->returns_abnormally
 
+/* Set to 0 at beginning of a function definition, set to 1 if we see an
+   obvious infinite loop.  This can have false positives and false
+   negatives, so it should only be used as a heuristic.  */
+
+#define current_function_infinite_loop cp_function_chain->infinite_loop
+
 /* Nonzero if we are processing a base initializer.  Zero elsewhere.  */
 #define in_base_initializer cp_function_chain->x_in_base_initializer
 
@@ -5671,6 +5681,7 @@ extern bool perform_or_defer_access_check	(tree, tree, tree,
 extern int stmts_are_full_exprs_p		(void);
 extern void init_cp_semantics			(void);
 extern tree do_poplevel(tree);
+extern void break_maybe_infinite_loop		(void);
 extern void add_decl_expr			(tree);
 extern tree maybe_cleanup_point_expr_void	(tree);
 extern tree finish_expr_stmt			(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5906653..bfe1daf 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14000,6 +14000,8 @@ finish_function (int flags)
   && !current_function_returns_value && !current_function_returns_null
   /* Don't complain if we abort or throw.  */
   && !current_function_returns_abnormally
+  /* Don't complain if there's an infinite loop.  */
+  && !current_function_infinite_loop
   /* Don't complain if we are declared noreturn.  */
   && !TREE_THIS_VOLATILE (fndecl)
   && !DECL_NAME (DECL_RESULT (fndecl))
@@ -14064,6 +14066,7 @@ finish_function (int flags)
   f->x_return_value = NULL;
   f->bindings = NULL;
   f->extern_decl_map = NULL;
+  f->infinite_loops = NULL;
 }
   /* Clear out the bits we don't need.  */
   local_names = NULL;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3bc943b..9440df6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10636,6 +10636,8 @@ cp_parser_jump_statement (cp_parser* parser)
 	  gcc_assert ((in_statement & IN_SWITCH_STMT)
 		  || in_statement == IN_ITERATION_STMT);
 	  statement = finish_break_stmt ();
+	  if (in_statement == IN_ITERATION_STMT)
+	break_maybe_infinite_loop ();
 	  break;
 	case IN_OMP_BLOCK:
 	  error_at (token->location, "invalid exit from OpenMP structured block");
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2e7cf60..400a143 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19670,6 +19670,10 @@ instantiate_decl (tree d, int defer_ok,
 	 so that finish_function knows where we are.  */
 	  input_location
 	= DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus;
+
+	  /* Remember if we saw an infinite loop in the template.  */
+	  current_function_infinite_loop
+	= DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop;
 	}
 
   /* We don't need the local specializations any more.  */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index eb04266..d911cd5 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -486,6 +486,62 @@ push_cleanup (tree decl, tree cleanup, bool eh_only)
   CLEANUP_BODY (stmt) = push_s

Re: [Patch] PR55189 enable -Wreturn-type by default

2014-01-23 Thread Sylvestre Ledru
On 23/01/2014 10:48, Jason Merrill wrote:
> On 01/16/2014 02:44 PM, Jason Merrill wrote:
>> To avoid spurious warnings on code with infinite loops we could add a
>> simple check for infinite loops and suppress the warning in that case.
>> Basically, if we see a loop with an always-true condition and no breaks.
>
> Like so:
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
>
Thanks for that!

S



Re: [PATCH] PR59909, Fix powerpcle64 power8 bootstrap (quad memory support)

2014-01-23 Thread David Edelsohn
On Wed, Jan 22, 2014 at 1:50 PM, Michael Meissner
 wrote:
> The current trunk will not bootstrap on a powerpcle64 power8 box if
> --with-cpu=power8 is selected.  This has been traced down to the fact that we
> did not swap the double words when we used the quad memory instructions.
>
> In this patch, I split the ISA 2.07 quad memory support into two parts, one 
> for
> the non-atomic quad memory support instructions, and the other for atomic quad
> memory support.  In big endian systems, both forms are generated, while in
> little endian systems only the atomic instructions are generated, since the
> overhead of swapping the words would diminish the appeal of using the
> non-atomic quad memory instructions.
>
> At a future date, I would like to optimize the quad memory atomic instructions
> not to do the swapping in some cases.  That optimization is not in these
> patches.
>
> I'm attaching two versions of the patch.  The first version is against the
> current trunk.  The second version is against the 4.8 compiler in the IBM
> branch.
>
> This has been tested by doing a full bootstrap on a power8 box in little 
> endian
> mode.  There are no regressions in the powerpc tests.  Is this patch ok to
> apply?
>
> 2014-01-22  Michael Meissner  
>
> PR target/59909
> * doc/invoke.texi (RS/6000 and PowerPC Options): Document
> -mquad-memory-atomic.  Update -mquad-memory documentation to say
> it is only used for non-atomic loads/stores.
>
> * config/rs6000/predicates.md (quad_int_reg_operand): Allow either
> -mquad-memory or -mquad-memory-atomic switches.
>
> * config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Add
> -mquad-memory-atomic to ISA 2.07 support.
>
> * config/rs6000/rs6000.opt (-mquad-memory-atomic): Add new switch
> to separate support of normal quad word memory operations (ldq,
> stq) from the atomic quad word memory operations.
>
> * config/rs6000/rs6000.c (rs6000_option_override_internal): Add
> support to separate non-atomic quad word operations from atomic
> quad word operations.  Disable non-atomic quad word operations in
> little endian mode so that we don't have to swap words after the
> load and before the store.
> (quad_load_store_p): Add comment about atomic quad word support.
> (rs6000_opt_masks): Add -mquad-memory-atomic.
>
> * config/rs6000/rs6000.h (TARGET_SYNC_TI): Add support for
> -mquad-memory-atomic.
> (TARGET_SYNC_HI_QI): Likewise.
>
> * config/rs6000/sync.md (qswap_pred1): Add support for swapping
> double word registers with quad word atomic instructions in little
> endian mode.
> (qswap_pred2): Likewise.
> (qswap_other): Likewise.
> (qswap_): Likewise.
> (load_lockedti): Likewise.
> (load_lockedpti): Likewise.
> (store_conditionalti): Likewise.
> (store_conditionalpti): Likewise.
>
> * gcc/config/rs6000/rs6000.md (UNSPEC_TI_PTI_SWAP): New UNSPEC for
> dealing with quad word atomic instructions in little endian mode.
>
> * gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
> Define __QUAD_MEMORY__ and __QUAD_MEMORY_ATOMIC__ based on what
> type of quad memory support is available.

The patch is okay, but please clarify the sync.md ChangeLog to mention
what you did for the patterns, like new patterns, new attrs, which
patterns are changed to swap double words in LE mode.

Thanks, David


Handle XOR in canonicalize_condition

2014-01-23 Thread Richard Sandiford
This patch fixes gcc.dg/unroll_1.c for MIPS16.  There were two problems,
one in the testcase itself and one in the rtl code.

The testcase problem was that gcc.dg/unroll_1.c forces loop2_unroll to
be run via -fenable-rtl-loop2_unroll but it doesn't explicitly force the
associated init pass (loop2) to be run as well.  This only happens because
-fmove-loop-invariants is usually the default for -O2.  It isn't the default
on MIPS16 though, so neither loop2 nor loop2_unroll were being run.  The
patch adds an explicit -fenable-rtl-loop2 to get around this.

The other problem is related to the way that MIPS16 tests for equality.
Conditional branches test register $24, and the only instructions that
set $24 are MOVE and CMP(I), which is actually an XOR rather than a
subtraction.  So branches for equality typically look like:

   (set (reg:SI cond) (xor:SI (reg:SI X) (const_int Y)))
   (set (pc)
(if_then_else (eq (reg:SI cond) (const_int 0))
  (label_ref ...)
  (pc)))

get_condition didn't recognise this form and so loop-iv.c couldn't
figure out the number of iterations.

I fixed that by handling (eq (xor ...) (const_int 0)) and
(ne (xor ...) (const_int 0)) in canonicalize_condition, in a similar
way to (compare ...).

The existing (compare ...) conditions both test:

 ((GET_MODE_CLASS (mode) == MODE_CC)
   != (GET_MODE_CLASS (inner_mode) == MODE_CC))
  && mode != VOIDmode
  && inner_mode != VOIDmode)

with the comment:

  /* ??? We may not combine comparisons done in a CCmode with
 comparisons not done in a CCmode.  This is to aid targets
 like Alpha that have an IEEE compliant EQ instruction, and
 a non-IEEE compliant BEQ instruction.  The use of CCmode is
 actually artificial, simply to prevent the combination, but
 should not affect other platforms.

 However, we must allow VOIDmode comparisons to match either
 CCmode or non-CCmode comparison, because some ports have
 modeless comparisons inside branch patterns.

 ??? This mode check should perhaps look more like the mode check
 in simplify_comparison in combine.  */

The IEEE thing obviously isn't a worry for XOR, but it still seemed more
consistent to handle all cases in the same way.  I therefore split the
condition out into a separate test.

Tested on mips64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
* rtlanal.c (canonicalize_condition): Split out duplicated mode check.
Handle XOR.

gcc/testsuite/
* gcc.dg/unroll_1.c: Add -fenable-rtl-loop2.

Index: gcc/rtlanal.c
===
--- gcc/rtlanal.c   2014-01-23 19:12:05.089232340 +
+++ gcc/rtlanal.c   2014-01-23 19:12:15.168333561 +
@@ -5051,23 +5051,24 @@ canonicalize_condition (rtx insn, rtx co
 
 ??? This mode check should perhaps look more like the mode check
 in simplify_comparison in combine.  */
-
- if ((GET_CODE (SET_SRC (set)) == COMPARE
-  || (((code == NE
-|| (code == LT
-&& val_signbit_known_set_p (inner_mode,
-STORE_FLAG_VALUE))
+ if (((GET_MODE_CLASS (mode) == MODE_CC)
+  != (GET_MODE_CLASS (inner_mode) == MODE_CC))
+ && mode != VOIDmode
+ && inner_mode != VOIDmode)
+   break;
+ if (GET_CODE (SET_SRC (set)) == COMPARE
+ || (((code == NE
+   || (code == LT
+   && val_signbit_known_set_p (inner_mode,
+   STORE_FLAG_VALUE))
 #ifdef FLOAT_STORE_FLAG_VALUE
-|| (code == LT
-&& SCALAR_FLOAT_MODE_P (inner_mode)
-&& (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
-REAL_VALUE_NEGATIVE (fsfv)))
+   || (code == LT
+   && SCALAR_FLOAT_MODE_P (inner_mode)
+   && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
+   REAL_VALUE_NEGATIVE (fsfv)))
 #endif
-))
-  && COMPARISON_P (SET_SRC (set
- && (((GET_MODE_CLASS (mode) == MODE_CC)
-  == (GET_MODE_CLASS (inner_mode) == MODE_CC))
- || mode == VOIDmode || inner_mode == VOIDmode))
+   ))
+ && COMPARISON_P (SET_SRC (set
x = SET_SRC (set);
  else if (((code == EQ
 || (code == GE
@@ -5080,15 +5081,18 @@ canonicalize_condition (rtx insn, rtx co
 REAL_VALUE_NEGATIVE (fsfv)))
 #endif
 ))
-  && COMPARISON_P (SET_SRC (set))
-  && (((GET_MODE_CLA

Re: [PATCH] PR59909, Fix powerpcle64 power8 bootstrap (quad memory support)

2014-01-23 Thread Michael Meissner
On Thu, Jan 23, 2014 at 01:58:15PM -0500, David Edelsohn wrote:
> The patch is okay, but please clarify the sync.md ChangeLog to mention
> what you did for the patterns, like new patterns, new attrs, which
> patterns are changed to swap double words in LE mode.

In looking to write better comments, I discovered that the new patterns were
wrong in that they didn't properly swap words on quad atomics, so I will be
submitting a tweaked patch after testing.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797



Re: [GOOGLE] Builtins handling in IVOPT

2014-01-23 Thread Xinliang David Li
Two patches are ok with the following change

* change PARAM_AVG_LOOP_NITER to PARAM_IVOPT_AVG_LOOP_NITER;

(The base version of the patch is not correct).

thanks,

David

On Wed, Jan 22, 2014 at 9:52 PM, Wei Mi  wrote:
> Comments added. I create another patch to add the parameter for AVG_LOOP_ITER.
> Both patches are attached.
>
> Thanks,
> Wei.
>
> On Wed, Jan 22, 2014 at 4:42 PM, Xinliang David Li  wrote:
>> On Wed, Jan 22, 2014 at 2:23 PM, Wei Mi  wrote:
>>> This patch handles the mem access builtins in ivopt. The original
>>> problem described here:
>>> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02648.html
>>>
>>> Bootstrapped and passed regression test. Performance test ok for
>>> plain, fdo and lipo. Ok for google 4.8 branch?
>>>
>>> Thanks,
>>> Wei.
>>>
>>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/expr.c
>>> 2013-12-21 21:16:11.006695060 -0800
>>> +++ gcc/expr.c  2013-12-09 11:16:22.698063077 -0800
>>> @@ -7537,7 +7537,21 @@
>>>   tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
>>> return expand_expr (tem, target, tmode, modifier);
>>>}
>>> +case TARGET_MEM_REF:
>>> +  {
>>
>> Add more comments here to describe the new code.
>>
>>> +   struct mem_address addr;
>>> +   int old_cse_not_expected;
>>> +   addr_space_t as
>>> + = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0;
>>>
>>> +   get_address_description (exp, &addr);
>>> +   result = addr_for_mem_ref (&addr, as, true);
>>> +   old_cse_not_expected = cse_not_expected;
>>> +   cse_not_expected = 1;
>>> +   result = memory_address_addr_space (tmode, result, as);
>>> +   cse_not_expected = old_cse_not_expected;
>>> +   return result;
>>> +  }
>>>  case CONST_DECL:
>>>/* Expand the initializer like constants above.  */
>>>result = XEXP (expand_expr_constant (DECL_INITIAL (exp),
>>> @@ -9579,10 +9593,14 @@
>>> struct mem_address addr;
>>> enum insn_code icode;
>>> unsigned int align;
>>> +   int old_cse_not_expected;
>>>
>>> get_address_description (exp, &addr);
>>> op0 = addr_for_mem_ref (&addr, as, true);
>>> +   old_cse_not_expected = cse_not_expected;
>>
>> Comments on the change.
>>
>>> +   cse_not_expected = 1;
>>> op0 = memory_address_addr_space (mode, op0, as);
>>> +   cse_not_expected = old_cse_not_expected;
>>> temp = gen_rtx_MEM (mode, op0);
>>> set_mem_attributes (temp, exp, 0);
>>> set_mem_addr_space (temp, as);
>>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/target.def
>>> 2013-12-21 21:16:10.926694446 -0800
>>> +++ gcc/target.def  2013-12-09 10:46:07.794472365 -0800
>>> @@ -1119,6 +1119,14 @@
>>>  #undef HOOK_PREFIX
>>>  #define HOOK_PREFIX "TARGET_"
>>>
>>> +DEFHOOK
>>> +(builtin_has_mem_ref_p,
>>> + "This hook return whether the @var{i}th param of the 
>>> @var{builtin_function}\n\
>>> +is a memory reference. If @var{i} is -1, return whether the
>>> @var{builtin_function}\n\
>>> +contains any memory reference type param.",
>>> + bool, (int builtin_function, int i),
>>> + default_builtin_has_mem_ref_p)
>>> +
>>>  /* Allow target specific overriding of option settings after options have
>>>been changed by an attribute or pragma or when it is reset at the
>>>end of the code affected by an attribute or pragma.  */
>>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/gimple.c
>>>   2013-12-21 21:16:11.066695519 -0800
>>> +++ gcc/gimple.c2013-12-09 10:50:09.096289179 -0800
>>> @@ -2574,7 +2574,8 @@
>>>  is_gimple_addressable (tree t)
>>>  {
>>>return (is_gimple_id (t) || handled_component_p (t)
>>> - || TREE_CODE (t) == MEM_REF);
>>> + || TREE_CODE (t) == MEM_REF
>>> + || TREE_CODE (t) == TARGET_MEM_REF);
>>>  }
>>>
>>>  /* Return true if T is a valid gimple constant.  */
>>> @@ -2625,7 +2626,8 @@
>>>op = TREE_OPERAND (op, 0);
>>>  }
>>>
>>> -  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF)
>>> +  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF
>>> +  || TREE_CODE (op) == TARGET_MEM_REF)
>>>  return true;
>>>
>>>switch (TREE_CODE (op))
>>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/targhooks.c
>>>2013-12-21 21:16:10.926694446 -0800
>>> +++ gcc/targhooks.c 2013-12-09 10:45:50.154339207 -0800
>>> @@ -543,6 +543,13 @@
>>>  }
>>>
>>>  bool
>>> +default_builtin_has_mem_ref_p (int built_in_function ATTRIBUTE_UNUSED,
>>> +  int i ATTRIBUTE_UNUSED)
>>> +{
>>> +  return false;
>>> +}
>>> +
>>> +bool
>>>  hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
>>> cumulative_args_t ca ATTRIBUTE_UNUSED,
>>> enum machine_mode mode ATTRIBUTE_UNUSED,
>>> --- 
>>> /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/tree-ssa-loop-ivopts.c
>>> 2014-01-22 11:57:10.420073494 -0800
>>> +++ gcc/tree-ssa-loop-ivo

patch to fix PR59915

2014-01-23 Thread Vladimir Makarov
  The following patch fixes

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

  The patch was successfully bootstrapped and tested on x86/x86-64 and
ppc64 (with -mlra).

  Committed as rev. 207007.

2014-01-23  Vladimir Makarov  

PR regression/59915
* lra-constraints.c (simplify_operand_subreg): Spill pseudo if
there is a danger of looping.


Index: lra-constraints.c
===
--- lra-constraints.c	(revision 206976)
+++ lra-constraints.c	(working copy)
@@ -1291,9 +1291,20 @@ simplify_operand_subreg (int nop, enum m
&& ! LRA_SUBREG_P (operand))
   || CONSTANT_P (reg) || GET_CODE (reg) == PLUS || MEM_P (reg))
 {
-  /* The class will be defined later in curr_insn_transform.  */
-  enum reg_class rclass
-	= (enum reg_class) targetm.preferred_reload_class (reg, ALL_REGS);
+  enum reg_class rclass;
+
+  if (REG_P (reg)
+	  && curr_insn_set != NULL_RTX
+	  && (REG_P (SET_SRC (curr_insn_set))
+	  || GET_CODE (SET_SRC (curr_insn_set)) == SUBREG))
+	/* There is big probability that we will get the same class
+	   for the new pseudo and we will get the same insn which
+	   means infinite looping.  So spill the new pseudo.  */
+	rclass = NO_REGS;
+  else
+	/* The class will be defined later in curr_insn_transform.  */
+	rclass
+	  = (enum reg_class) targetm.preferred_reload_class (reg, ALL_REGS);
 
   if (get_reload_reg (curr_static_id->operand[nop].type, reg_mode, reg,
 			  rclass, "subreg reg", &new_reg))


Re: [C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread Joseph S. Myers
On Thu, 23 Jan 2014, Marek Polacek wrote:

> 2014-01-23  Marek Polacek  
> 
>   PR c/59846
> c-family/
>   * c-common.c (shorten_compare): Add location_t parameter.
>   * c-common.h (shorten_binary_op): Adjust declaration.
> cp/
>   * typeck.c (cp_build_binary_op): Pass location to shorten_compare.
> c/
>   * c-typeck.c (parser_build_binary_op): Use location instead of
>   input_location.
>   (build_binary_op): Pass location to shorten_compare.
> testsuite/
>   * gcc.dg/pr59846.c: New test.

OK.

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


[jit] Introduce add_stmt helper method.

2014-01-23 Thread David Malcolm
Committed to dmalcolm/jit branch:

gcc/jit/
* internal-api.h (gcc::jit::function::add_stmt): New.

* internal-api.c (gcc::jit::function::add_eval): Replace use of
tsi_link_stmt with call to add_stmt.
(gcc::jit::function::add_assignment): Likewise.
(gcc::jit::function::add_conditional): Likewise.
(gcc::jit::function::place_forward_label): Likewise.
(gcc::jit::function::add_jump): Likewise.
(gcc::jit::function::add_return): Likewise.
---
 gcc/jit/ChangeLog.jit  | 12 
 gcc/jit/internal-api.c | 12 ++--
 gcc/jit/internal-api.h |  5 +
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index c899c9a..2018094 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,3 +1,15 @@
+2014-01-23  David Malcolm  
+
+   * internal-api.h (gcc::jit::function::add_stmt): New.
+
+   * internal-api.c (gcc::jit::function::add_eval): Replace use of
+   tsi_link_stmt with call to add_stmt.
+   (gcc::jit::function::add_assignment): Likewise.
+   (gcc::jit::function::add_conditional): Likewise.
+   (gcc::jit::function::place_forward_label): Likewise.
+   (gcc::jit::function::add_jump): Likewise.
+   (gcc::jit::function::add_return): Likewise.
+
 2014-01-21  David Malcolm  
 
* internal-api.c (gcc::jit::function::add_comment): New.
diff --git a/gcc/jit/internal-api.c b/gcc/jit/internal-api.c
index a92c797..f7a2618 100644
--- a/gcc/jit/internal-api.c
+++ b/gcc/jit/internal-api.c
@@ -889,7 +889,7 @@ add_eval (location *loc,
   if (loc)
 set_tree_location (rvalue->as_tree (), loc);
 
-  tsi_link_after (&m_stmt_iter, rvalue->as_tree (), TSI_CONTINUE_LINKING);
+  add_stmt (rvalue->as_tree ());
 }
 
 void
@@ -918,7 +918,7 @@ add_assignment (location *loc,
t_lvalue, t_rvalue);
   if (loc)
 set_tree_location (stmt, loc);
-  tsi_link_after (&m_stmt_iter, stmt, TSI_CONTINUE_LINKING);
+  add_stmt (stmt);
 }
 
 void
@@ -977,7 +977,7 @@ add_conditional (location *loc,
true_jump, false_jump);
   if (loc)
 set_tree_location (stmt, loc);
-  tsi_link_after (&m_stmt_iter, stmt, TSI_CONTINUE_LINKING);
+  add_stmt (stmt);
 }
 
 gcc::jit::label *
@@ -1005,7 +1005,7 @@ place_forward_label (location *loc, label *lab)
 lab->as_label_decl ());
   if (loc)
 set_tree_location (lab->m_label_expr, loc);
-  tsi_link_after (&m_stmt_iter, lab->m_label_expr, TSI_CONTINUE_LINKING);
+  add_stmt (lab->m_label_expr);
 }
 
 void
@@ -1025,7 +1025,7 @@ add_jump (location *loc,
   tree stmt = build1 (GOTO_EXPR, void_type_node, target->as_label_decl ());
   if (loc)
 set_tree_location (stmt, loc);
-  tsi_link_after (&m_stmt_iter, stmt, TSI_CONTINUE_LINKING);
+  add_stmt (stmt);
 
   /*
   from c-typeck.c:
@@ -1069,7 +1069,7 @@ add_return (location *loc,
   set_tree_location (modify_retval, loc);
   set_tree_location (return_stmt, loc);
 }
-  tsi_link_after (&m_stmt_iter, return_stmt, TSI_CONTINUE_LINKING);
+  add_stmt (return_stmt);
 }
 
 gcc::jit::loop *
diff --git a/gcc/jit/internal-api.h b/gcc/jit/internal-api.h
index 1ec2ea1..7a5c92a 100644
--- a/gcc/jit/internal-api.h
+++ b/gcc/jit/internal-api.h
@@ -354,6 +354,11 @@ public:
   context *m_ctxt;
 
 private:
+  void add_stmt (tree stmt)
+  {
+tsi_link_after (&m_stmt_iter, stmt, TSI_CONTINUE_LINKING);
+  }
+
   void
   set_tree_location (tree t, location *loc)
   {
-- 
1.7.11.7



[RFA][PATCH] Fix tree-optimization/59919

2014-01-23 Thread Jeff Law
As noted in the PR, we have a call to a non-returning function which 
occurs within a function that calls setjmp.


The non-returning call ends its containing basic block and there are no 
normal outgoing edges from that block.  Because the containing function 
calls setjmp, there is an abnormal edge from the block containing the 
non-returning call.


ie:

;;   basic block 2, loop depth 0, count 0, freq 1, maybe hot
;;prev block 0, next block 3, flags: (NEW, REACHABLE)
;;pred:   ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
  bar (p_3(D));
;;succ:   3 [100.0%]  (ABNORMAL,EXECUTABLE)

;;   basic block 3, loop depth 0, count 0, freq 1, maybe hot
;;   Invalid sum of incoming frequencies 15000, should be 1
;;prev block 2, next block 4, flags: (NEW, REACHABLE, IRREDUCIBLE_LOOP)
;;pred:   2 [100.0%]  (ABNORMAL,EXECUTABLE)
;;3 [50.0%]  (ABNORMAL,DFS_BACK,IRREDUCIBLE_LOOP,EXECUTABLE)
  setjmp (_4(D));
  _6 = &p_3(D)->i;
  foo (_6);
;;succ:   3 [50.0%]  (ABNORMAL,DFS_BACK,IRREDUCIBLE_LOOP,EXECUTABLE)
;;4 [50.0%]  (FALLTHRU,EXECUTABLE)

;;   basic block 4, loop depth 0, count 0, freq 5000, maybe hot
;;prev block 3, next block 1, flags: (NEW, REACHABLE)
;;pred:   3 [50.0%]  (FALLTHRU,EXECUTABLE)
  return;

We want to insert an ASSERT_EXPR for the call to bar to assert that p_3 
is non-null (because of the non-null attribute)


The code to insert ASSERT_EXPRs doesn't know where to insert the 
ASSERT_EXPR and aborts.


This patch simply avoids registering ASSERT_EXPR insertions that arise 
as a result of non-returning calls.


Bootstrapped and regression tested on x86_64-unknown-linux-gnu.  OK for 
the trunk?


Jeff

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2998c72..e27f5b1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2014-01-23  Jeff Law  
+
+   PR tree-optimization/59919
+   * tree-vrp.c (find_assert_locations_1): Do not register asserts
+   for non-returning calls.
+
 2014-01-23  Pat Haugen  
 
* config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 564d425..44e135a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-23  Jeff Law  
+
+   PR tree-optimization/59919
+   * gcc.c-torture/compile/pr59919.c: New test.
+
 2014-01-23  Paolo Carlini  
 
PR c++/58980
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr59919.c 
b/gcc/testsuite/gcc.c-torture/compile/pr59919.c
new file mode 100644
index 000..6809caa
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr59919.c
@@ -0,0 +1,18 @@
+typedef int jmp_buf[10];
+struct S
+{
+  int i;
+  jmp_buf buf;
+};
+
+void setjmp (jmp_buf);
+void foo (int *);
+__attribute__ ((__noreturn__, __nonnull__)) void bar (struct S *);
+
+void
+baz (struct S *p)
+{
+  bar (p);
+  setjmp (p->buf);
+  foo (&p->i);
+}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index f6da192..3d43d93 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -5891,8 +5891,13 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
}
}
 
- register_new_assert_for (op, op, comp_code, value, bb, NULL, si);
- need_assert = true;
+ /* Do not register any assertions for a non-returning call.  */
+ if (!is_gimple_call (stmt) || !gimple_call_noreturn_p (stmt))
+   {
+ register_new_assert_for (op, op, comp_code,
+  value, bb, NULL, si);
+ need_assert = true;
+   }
}
}
 


[jit] Fix how locals are created; add BIND_EXPR

2014-01-23 Thread David Malcolm
Committed to dmalcolm/jit:

Attempting to add test coverage uncovered that locals weren't being
associated with their functions, leading to crashes later on in the
compile for various valid constructs.

To fix this, we now set the DECL_CONTEXT of locals to be the
FUNCTION_DECL.  To do so, we also need to put them within a BIND_EXPR
otherwise gimplify_var_or_parm_decl dies, with:
   !DECL_SEEN_IN_BIND_EXPR_P (decl)

Hence we now create a BIND_EXPR for every function with a body, moving
the statement list within it.

gcc/jit/
* internal-api.h (gcc::jit::function): Add field
"m_inner_bind_expr".
* internal-api.c (gcc::jit::function::function): Create a BIND_EXPR
for all non-imported functions, and put the statement list within
it.
(gcc::jit::function::gt_ggc_mx): Visit m_inner_bind_expr.
(gcc::jit::function::new_local): Set the DECL_CONTEXT of the new
local to be the function's BIND_EXPR, and prepend the new local
to said BIND_EXPR's BIND_EXPR_VARS chain.
(gcc::jit::function::postprocess): Set the DECL_SAVED_TREE of the
FUNCTION_DECL to be the BIND_EXPR, rather than the statement list.
The latter is now contained within the former.

gcc/testsuite/
* jit.dg/test-reading-struct.c: New test, to provide test coverage
of gcc_jit_type_get_const and gcc_jit_lvalue_access_field, in the
process uncovering bugs in how locals were handled.
* jit.dg/test-combination.c: Add usage of test-reading-struct.c.
---
 gcc/jit/ChangeLog.jit  |  15 
 gcc/jit/internal-api.c |  13 ++-
 gcc/jit/internal-api.h |   1 +
 gcc/testsuite/ChangeLog.jit|   7 ++
 gcc/testsuite/jit.dg/test-combination.c|   7 ++
 gcc/testsuite/jit.dg/test-reading-struct.c | 136 +
 6 files changed, 178 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/jit.dg/test-reading-struct.c

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index 2018094..41f52f2 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,5 +1,20 @@
 2014-01-23  David Malcolm  
 
+   * internal-api.h (gcc::jit::function): Add field
+   "m_inner_bind_expr".
+   * internal-api.c (gcc::jit::function::function): Create a BIND_EXPR
+   for all non-imported functions, and put the statement list within
+   it.
+   (gcc::jit::function::gt_ggc_mx): Visit m_inner_bind_expr.
+   (gcc::jit::function::new_local): Set the DECL_CONTEXT of the new
+   local to be the function's BIND_EXPR, and prepend the new local
+   to said BIND_EXPR's BIND_EXPR_VARS chain.
+   (gcc::jit::function::postprocess): Set the DECL_SAVED_TREE of the
+   FUNCTION_DECL to be the BIND_EXPR, rather than the statement list.
+   The latter is now contained within the former.
+
+2014-01-23  David Malcolm  
+
* internal-api.h (gcc::jit::function::add_stmt): New.
 
* internal-api.c (gcc::jit::function::add_eval): Replace use of
diff --git a/gcc/jit/internal-api.c b/gcc/jit/internal-api.c
index f7a2618..d0d49cc 100644
--- a/gcc/jit/internal-api.c
+++ b/gcc/jit/internal-api.c
@@ -782,12 +782,16 @@ gcc::jit::function::
 function(gcc::jit::context *ctxt, tree fndecl, enum gcc_jit_function_kind kind)
 : m_ctxt(ctxt),
   m_inner_fndecl (fndecl),
+  m_inner_bind_expr (NULL),
   m_kind (kind)
 {
   if (m_kind != GCC_JIT_FUNCTION_IMPORTED)
 {
+  /* Create a BIND_EXPR, and within it, a statement list.  */
   m_stmt_list = alloc_stmt_list ();
   m_stmt_iter = tsi_start (m_stmt_list);
+  m_inner_bind_expr =
+   build3 (BIND_EXPR, void_type_node, NULL, m_stmt_list, NULL);
 }
   else
 {
@@ -800,6 +804,7 @@ gcc::jit::function::
 gt_ggc_mx ()
 {
   gt_ggc_m_9tree_node (m_inner_fndecl);
+  gt_ggc_m_9tree_node (m_inner_bind_expr);
   gt_ggc_m_9tree_node (m_stmt_list);
 }
 
@@ -821,6 +826,12 @@ new_local (location *loc,
   tree inner = build_decl (UNKNOWN_LOCATION, VAR_DECL,
   get_identifier (name),
   type->as_tree ());
+  DECL_CONTEXT (inner) = this->m_inner_fndecl;
+
+  /* Prepend to BIND_EXPR_VARS: */
+  DECL_CHAIN (inner) = BIND_EXPR_VARS (m_inner_bind_expr);
+  BIND_EXPR_VARS (m_inner_bind_expr) = inner;
+
   if (loc)
 set_tree_location (inner, loc);
   return new lvalue (m_ctxt, inner);
@@ -855,7 +866,7 @@ postprocess ()
 
   /* how to add to function? the following appears to be how to
 set the body of a m_inner_fndecl: */
-  DECL_SAVED_TREE(m_inner_fndecl) = m_stmt_list;
+  DECL_SAVED_TREE(m_inner_fndecl) = m_inner_bind_expr;
   //debug_tree (m_inner_fndecl);
 
   /* Convert to gimple: */
diff --git a/gcc/jit/internal-api.h b/gcc/jit/internal-api.h
index 7a5c92a..be1216a 100644
--- a/gcc/jit/internal-api.h
+++ b/gcc/jit/internal-api.h
@@ -367,6 +367,7 @@ private:
 
 private:
   tree m_inner_fndecl;
+  t

Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread Eric Botcazou
>   * config/i38/x86-tune.def: Disable X86_TUNE_ACCUMULATE_OUTGOING_ARGS
>   for generic and recent AMD chips

The ChangeLog reads:

2014-01-22  Jan Hubicka  

* config/i386/x86-tune.def (X86_TUNE_ACCUMULATE_OUTGOING_ARGS):
Enable for generic and recent AMD targets.

Very confusing...

-- 
Eric Botcazou


[jit] Add GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE

2014-01-23 Thread David Malcolm
Committed to dmalcolm/jit:

Add a debug flag for dumping the generated assembler to stderr:
  GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE

This is technically an ABI change, since the value is added before
some existing values, but we don't yet guarantee an ABI.

gcc/jit/
* libgccjit.h (enum gcc_jit_bool_option): New value:
GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE.

* internal-api.c (gcc::jit::context::compile): Call
dump_generated_code if the user has requested it.
(gcc::jit::context::dump_generated_code): New, copying
from the .s file to stderr.

* internal-api.h (gcc::jit::context::dump_generated_code): New.
---
 gcc/jit/ChangeLog.jit  | 12 
 gcc/jit/internal-api.c | 19 +++
 gcc/jit/internal-api.h |  2 ++
 gcc/jit/libgccjit.h|  4 
 4 files changed, 37 insertions(+)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index 41f52f2..f4127d1 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,5 +1,17 @@
 2014-01-23  David Malcolm  
 
+   * libgccjit.h (enum gcc_jit_bool_option): New value:
+   GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE.
+
+   * internal-api.c (gcc::jit::context::compile): Call
+   dump_generated_code if the user has requested it.
+   (gcc::jit::context::dump_generated_code): New, copying
+   from the .s file to stderr.
+
+   * internal-api.h (gcc::jit::context::dump_generated_code): New.
+
+2014-01-23  David Malcolm  
+
* internal-api.h (gcc::jit::function): Add field
"m_inner_bind_expr".
* internal-api.c (gcc::jit::function::function): Create a BIND_EXPR
diff --git a/gcc/jit/internal-api.c b/gcc/jit/internal-api.c
index d0d49cc..869185a 100644
--- a/gcc/jit/internal-api.c
+++ b/gcc/jit/internal-api.c
@@ -1302,6 +1302,9 @@ compile ()
   goto error;
 }
 
+  if (m_bool_options[GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE])
+  dump_generated_code ();
+
   timevar_push (TV_ASSEMBLE);
 
   /* Gross hacks follow:
@@ -1398,6 +1401,22 @@ invoke_code_factory ()
 }
 }
 
+void
+gcc::jit::context::
+dump_generated_code ()
+{
+  char buf[4096];
+  size_t sz;
+  FILE *f_in = fopen (m_path_s_file, "r");
+  if (!f_in)
+return;
+
+  while ( (sz = fread (buf, 1, sizeof (buf), f_in)) )
+fwrite (buf, 1, sz, stderr);
+
+  fclose (f_in);
+}
+
 static int
 line_comparator (const void *lhs, const void *rhs)
 {
diff --git a/gcc/jit/internal-api.h b/gcc/jit/internal-api.h
index be1216a..b226c23 100644
--- a/gcc/jit/internal-api.h
+++ b/gcc/jit/internal-api.h
@@ -176,6 +176,8 @@ public:
   as_truth_value (tree expr, location *loc);
 
 private:
+  void dump_generated_code ();
+
   source_file *
   get_source_file (const char *filename);
 
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 8a6682b..baf1541 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -158,6 +158,10 @@ enum gcc_jit_bool_option
  are performed.  The dump resembles C code.  */
   GCC_JIT_BOOL_OPTION_DUMP_INITIAL_GIMPLE,
 
+  /* If true, gcc_jit_context_compile will dump the final
+ generated code to stderr, in the form of assembly language.  */
+  GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
+
   /* If true, gcc_jit_context_compile will print information to stderr
  on the actions it is performing, followed by a profile showing
  the time taken and memory usage of each phase.
-- 
1.7.11.7



Re: Two build != host fixes

2014-01-23 Thread Alan Modra
On Wed, Jan 22, 2014 at 09:21:46PM -0700, Jeff Law wrote:
> > * Makefile.in (BUILD_CPPFLAGS): Do not use ALL_CPPFLAGS.
> > * configure.ac : Define
> > GENERATOR_FILE.  Comment.  Use CXX_FOR_BUILD, CXXFLAGS_FOR_BUILD
> > and LD_FOR_BUILD too.
> > * configure: Regenerate.
> The configure.ac changes look fine to me.

Thanks!  That part alone ought to fix the in-tree gmp breakage.

> Not sure about the Makefile.in changes, probably because I simply
> don't understand this mess anymore.  Is it the $INCLUDES or
> $CPPFLAGS from ALL_CPPFLAGS that causes the problem?  I'm guessing
> the latter since it's substituted via @CPPFLAGS@.
> 
> If so, shouldn't we use BUILD_CPPFLAGS=$INCLUDES $(CPPINC)?

INCLUDES is the problem.

INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
   -I$(srcdir)/../include @INCINTL@ \
   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
   $(CLOOGINC) $(ISLINC)

That's where we potentially have GMPINC fouling the build compile with
host headers, ditto for GLOOGINC and ISLINC.  DECNUMINC and
BACKTRACEINC are in-tree so don't cause any problem, but we don't need
either of those when running COMPILER_FOR_BUILD for any of gen*.

Of course, then your question becomes, why exclude CPPFLAGS?  (And if
CPPFLAGS needs to be excluded here, then I should have just used
CPPFLAGS=-DGENERATOR_FILE for the recursive configure call..)  I'm not
sure now, I'll have to do some digging.  Also as to why @INCINTL@ was
removed, when gettext is potentially needed for the gen programs.

-- 
Alan Modra
Australia Development Lab, IBM


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread Jan Hubicka
> > * config/i38/x86-tune.def: Disable X86_TUNE_ACCUMULATE_OUTGOING_ARGS
> > for generic and recent AMD chips
> 
> The ChangeLog reads:
> 
> 2014-01-22  Jan Hubicka  
> 
> * config/i386/x86-tune.def (X86_TUNE_ACCUMULATE_OUTGOING_ARGS):
> Enable for generic and recent AMD targets.
> 
> Very confusing...
Sorry, will fix it.

I looked into the movups.  The problem here is that ix86_expand_push is
not given a memory destination argument (because push expander is not)
and it builds it by itself.  The alignment then ends up being 8.
I am not 100% sure if the following code is safe (if I change alignment
in the testcase we end up using DImode push so it works). Perhaps we want
to remove the push expanders and make ix86_expand_move to handle this case
so we preserve other mem info too?

Honza

* i386.c (ix86_expand_push): Set alignment based on argument
boundary.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 206946)
+++ config/i386/i386.c  (working copy)
@@ -17230,6 +17230,9 @@
 ix86_expand_push (enum machine_mode mode, rtx x)
 {
   rtx tmp;
+  unsigned int align = ix86_function_arg_boundary (mode, NULL);
+  if (align > MAX_SUPPORTED_STACK_ALIGNMENT)
+align = MAX_SUPPORTED_STACK_ALIGNMENT;
 
   tmp = expand_simple_binop (Pmode, PLUS, stack_pointer_rtx,
 GEN_INT (-GET_MODE_SIZE (mode)),
@@ -17239,6 +17242,11 @@
 
   tmp = gen_rtx_MEM (mode, stack_pointer_rtx);
 
+  /* We use push of non-integer parameters only to store function
+ arguments.  */
+  if (MEM_ALIGN (tmp) < align)
+set_mem_align (tmp, align);
+
   /* When we push an operand onto stack, it has to be aligned at least
  at the function argument boundary.  However since we don't have
  the argument type, we can't determine the actual argument


Re: [C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread H.J. Lu
On Thu, Jan 23, 2014 at 10:44 AM, Marek Polacek  wrote:
> On Thu, Jan 23, 2014 at 05:50:23PM +, Joseph S. Myers wrote:
>> On Thu, 23 Jan 2014, Marek Polacek wrote:
>>
>> > shorten_compare can produce a better locinfo if we pass location
>> > from {,cp_}build_binary_op to it; op0/op1 there don't have location.
>> > Furthermore, I see no reason why use input_location in
>> > parser_build_binary_op when we can use more accurate location.
>> >
>> > I don't know if/how I can test the column info using dejagnu, so
>> > no testcase attached.  But to give you an idea, instead of
>>
>> The approach used is
>>
>> /* { dg-warning "14:comparison is always false" } */
>>
>> or similar, with the column number put at the start of the dg-error /
>> dg-warning text.
>
> Argh, not sure how I missed that.  So with a testcase this time.
>
> OK now?
>
> 2014-01-23  Marek Polacek  
>
> PR c/59846
> c-family/
> * c-common.c (shorten_compare): Add location_t parameter.
> * c-common.h (shorten_binary_op): Adjust declaration.
> cp/
> * typeck.c (cp_build_binary_op): Pass location to shorten_compare.
> c/
> * c-typeck.c (parser_build_binary_op): Use location instead of
> input_location.
> (build_binary_op): Pass location to shorten_compare.
> testsuite/
> * gcc.dg/pr59846.c: New test.
>

It failed on Linux/x86:

FAIL: gcc.dg/pr59846.c (test for excess errors)
FAIL: gcc.dg/pr59846.c  (test for warnings, line 14)
FAIL: gcc.dg/pr59846.c  (test for warnings, line 8)

-- 
H.J.


Re: [C PATCH] Improve locinfo a bit (PR c/59846)

2014-01-23 Thread Marek Polacek
On Thu, Jan 23, 2014 at 03:18:55PM -0800, H.J. Lu wrote:
> It failed on Linux/x86:
> 
> FAIL: gcc.dg/pr59846.c (test for excess errors)
> FAIL: gcc.dg/pr59846.c  (test for warnings, line 14)
> FAIL: gcc.dg/pr59846.c  (test for warnings, line 8)

Ooops, yeah.  I'll install a fix tomorrow.

Marek


Re: [PATCH #2] PR59909, Fix powerpcle64 power8 bootstrap (quad memory support)

2014-01-23 Thread Michael Meissner
This is my fixed patch that correctly swaps the words for atomic quad memory
accesses in little endian.  It would be nice in the future to eliminate some of
the extra moves for things like compare and add.

I have tested this with a bootstrap (using --with-cpu=power8) on a little
endian power8 system, and I verified the example program works.  I'm running
the rest of the test suite right now.  Assuming the test suite doesn't show
anything wrong, is it ok to commit?

[gcc]
2014-01-23  Michael Meissner  

PR target/59909
* doc/invoke.texi (RS/6000 and PowerPC Options): Document
-mquad-memory-atomic.  Update -mquad-memory documentation to say
it is only used for non-atomic loads/stores.

* config/rs6000/predicates.md (quad_int_reg_operand): Allow either
-mquad-memory or -mquad-memory-atomic switches.

* config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Add
-mquad-memory-atomic to ISA 2.07 support.

* config/rs6000/rs6000.opt (-mquad-memory-atomic): Add new switch
to separate support of normal quad word memory operations (ldq,
stq) from the atomic quad word memory operations.

* config/rs6000/rs6000.c (rs6000_option_override_internal): Add
support to separate non-atomic quad word operations from atomic
quad word operations.  Disable non-atomic quad word operations in
little endian mode so that we don't have to swap words after the
load and before the store.
(quad_load_store_p): Add comment about atomic quad word support.
(rs6000_opt_masks): Add -mquad-memory-atomic to the list of
options printed with -mdebug=reg.

* config/rs6000/rs6000.h (TARGET_SYNC_TI): Use
-mquad-memory-atomic as the test for whether we have quad word
atomic instructions.
(TARGET_SYNC_HI_QI): If either -mquad-memory-atomic,
-mquad-memory, or -mp8-vector are used, allow byte/half-word
atomic operations.

* config/rs6000/sync.md (load_lockedti): Insure that the address
is a proper indexed or indirect address for the lqarx instruction.
On little endian systems, swap the hi/lo registers after the lqarx
instruction.
(load_lockedpti): Use indexed_or_indirect_operand predicate to
insure the address is valid for the lqarx instruction.
(store_conditionalti): Insure that the address is a proper indexed
or indirect address for the stqcrx. instruction.  On little endian
systems, swap the hi/lo registers before doing the stqcrx.
instruction.
(store_conditionalpti): Use indexed_or_indirect_operand predicate to
insure the address is valid for the stqcrx. instruction.

* gcc/config/rs6000/rs6000.md (UNSPEC_TI_PTI_SWAP): New UNSPEC for
dealing with quad word atomic instructions in little endian mode.

* gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
Define __QUAD_MEMORY__ and __QUAD_MEMORY_ATOMIC__ based on what
type of quad memory support is available.

[gcc/testsuite]
2014-01-23  Michael Meissner  

PR target/59909
* gcc.target/powerpc/quad-atomic.c: New file to test power8 quad
word atomic functions at runtime.


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 206895)
+++ gcc/doc/invoke.texi (working copy)
@@ -919,6 +919,7 @@ See RS/6000 and PowerPC Options.
 -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
 -mcrypto -mno-crypto -mdirect-move -mno-direct-move @gol
 -mquad-memory -mno-quad-memory @gol
+-mquad-memory-atomic -mno-quad-memory-atomic @gol
 -mcompat-align-parm -mno-compat-align-parm}
 
 @emph{RX Options}
@@ -18853,7 +18854,8 @@ following options:
 -mpopcntb -mpopcntd  -mpowerpc64 @gol
 -mpowerpc-gpopt  -mpowerpc-gfxopt  -msingle-float -mdouble-float @gol
 -msimple-fpu -mstring  -mmulhw  -mdlmzb  -mmfpgpr -mvsx @gol
--mcrypto -mdirect-move -mpower8-fusion -mpower8-vector -mquad-memory}
+-mcrypto -mdirect-move -mpower8-fusion -mpower8-vector @gol
+-mquad-memory -mquad-memory-atomic}
 
 The particular options set for any particular CPU varies between
 compiler versions, depending on what setting seems to produce optimal
@@ -19040,10 +19042,18 @@ the vector instructions.
 @itemx -mno-quad-memory
 @opindex mquad-memory
 @opindex mno-quad-memory
-Generate code that uses (does not use) the quad word memory
+Generate code that uses (does not use) the non-atomic quad word memory
 instructions.  The @option{-mquad-memory} option requires use of
 64-bit mode.
 
+@item -mquad-memory-atomic
+@itemx -mno-quad-memory-atomic
+@opindex mquad-memory-atomic
+@opindex mno-quad-memory-atomic
+Generate code that uses (does not use) the atomi

[PATCH, rs6000] Avoid optimization problem for VEC_PERM_EXPR

2014-01-23 Thread Bill Schmidt
Hi,

While testing another patch, I hit a regression at -O2 for two of the
vector shuffle tests.  This patch fixes the problem.

The problem was introduced with the little endian fixes for
VEC_PERM_EXPR.  The original change performed the necessary
transformation at expand time, but this is incorrect.  This creates a
technically incorrect representation in the RTL, and RTL simplification
can subsequently fold the expression in an unexpected way.  The correct
fix is to delay the transformation until final code generation.

Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
regressions.  Is this ok for trunk?  I will also plan to backport this
to ibm/gcc-4_8-branch after burn-in.

Thanks,
Bill


2014-01-23  Bill Schmidt  

* config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Remove
correction for little endian...
* config/rs6000/vsx.md (vsx_xxpermdi2__1): ...and move it to
here.



Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 206889)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -30115,22 +30121,6 @@ rs6000_expand_vec_perm_const_1 (rtx target, rtx op
   vmode = GET_MODE (target);
   gcc_assert (GET_MODE_NUNITS (vmode) == 2);
   dmode = mode_for_vector (GET_MODE_INNER (vmode), 4);
-
-  /* For little endian, swap operands and invert/swap selectors
-to get the correct xxpermdi.  The operand swap sets up the
-inputs as a little endian array.  The selectors are swapped
-because they are defined to use big endian ordering.  The
-selectors are inverted to get the correct doublewords for
-little endian ordering.  */
-  if (!BYTES_BIG_ENDIAN)
-   {
- int n;
- perm0 = 3 - perm0;
- perm1 = 3 - perm1;
- n = perm0, perm0 = perm1, perm1 = n;
- x = op0, op0 = op1, op1 = x;
-   }
-
   x = gen_rtx_VEC_CONCAT (dmode, op0, op1);
   v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1));
   x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v));
Index: gcc/config/rs6000/vsx.md
===
--- gcc/config/rs6000/vsx.md(revision 206889)
+++ gcc/config/rs6000/vsx.md(working copy)
@@ -1634,9 +1634,26 @@
 (match_operand 4 "const_2_to_3_operand" "")])))]
   "VECTOR_MEM_VSX_P (mode)"
 {
-  int mask = (INTVAL (operands[3]) << 1) | (INTVAL (operands[4]) - 2);
+  int op3, op4, mask;
+
+  if (BYTES_BIG_ENDIAN)
+{
+  op3 = INTVAL (operands[3]);
+  op4 = INTVAL (operands[4]);
+}
+  else
+{
+  op3 = 3 - INTVAL (operands[4]);
+  op4 = 3 - INTVAL (operands[3]);
+}
+
+  mask = (op3 << 1) | (op4 - 2);
   operands[3] = GEN_INT (mask);
-  return "xxpermdi %x0,%x1,%x2,%3";
+
+  if (BYTES_BIG_ENDIAN)
+return "xxpermdi %x0,%x1,%x2,%3";
+  else
+return "xxpermdi %x0,%x2,%x1,%3";
 }
   [(set_attr "type" "vecperm")])
 




Re: [PATCH] add __attribute__ ((designated_init))

2014-01-23 Thread Tom Tromey
Joseph> I think the test should also cover cases with designators such
Joseph> as .d.x = 1.

>> +static tree handle_designated_init (tree *, tree, tree, int, bool *);

Joseph> handle_designated_init_attribute would seem a better name.

>> +  error ("designated_init attribute is only valid on struct type");

Joseph> % (or use %qE with the attribute name as
Joseph> passed to the function, as is usual for such diagnostics).

FWIW I just noticed that handle_returns_nonnull_attribute doesn't do
this.

In this error, should I use "%" rather than just plain "struct"
as well?

I've fixed up the patch according to your comments.

Tom

b/gcc/ChangeLog:
2014-01-23  Tom Tromey  

PR c/59855
* doc/invoke.texi (Warning Options): Document -Wdesignated-init.
* doc/extend.texi (Type Attributes): Document designated_init
attribute.

b/gcc/c-family/ChangeLog:
2014-01-23  Tom Tromey  

PR c/59855
* c.opt (Wdesignated-init): New option.
* c-common.c (c_common_attribute_table): Add "designated_init".
(handle_designated_init): New function.

b/gcc/c/ChangeLog:
2014-01-23  Tom Tromey  

* c-typeck.c (struct constructor_stack) : New
field.
(really_start_incremental_init, push_init_level): Initialize
designator_depth.
(pop_init_level): Set global designator_depth.
(process_init_element): Check for designated_init attribute.

b/gcc/testsuite/ChangeLog:
2014-01-23  Tom Tromey  

PR c/59855
* gcc.dg/Wdesignated-init.c: New file.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 35958ea..a50d6d9 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -377,6 +377,7 @@ static tree handle_omp_declare_simd_attribute (tree *, 
tree, tree, int,
   bool *);
 static tree handle_omp_declare_target_attribute (tree *, tree, tree, int,
 bool *);
+static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *);
 
 static void check_function_nonnull (tree, int, tree *);
 static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
@@ -766,6 +767,8 @@ const struct attribute_spec c_common_attribute_table[] =
  handle_omp_declare_simd_attribute, false },
   { "omp declare target", 0, 0, true, false, false,
  handle_omp_declare_target_attribute, false },
+  { "designated_init",0, 0, false, true, false,
+ handle_designated_init_attribute, false },
   { NULL, 0, 0, false, false, false, NULL, false }
 };
 
@@ -9133,6 +9136,21 @@ handle_returns_nonnull_attribute (tree *node, tree, 
tree, int,
   return NULL_TREE;
 }
 
+/* Handle a "designated_init" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_designated_init_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+  if (TREE_CODE (*node) != RECORD_TYPE)
+{
+  error ("%qE attribute is only valid on struct type", name);
+  *no_add_attrs = true;
+}
+  return NULL_TREE;
+}
+
 
 /* Check for valid arguments being passed to a function with FNTYPE.
There are NARGS arguments in the array ARGARRAY.  */
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 38ae58e..29ac4d0 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -355,6 +355,10 @@ Wdeprecated
 C C++ ObjC ObjC++ Var(warn_deprecated) Init(1) Warning
 Warn if a deprecated compiler feature, class, method, or field is used
 
+Wdesignated-init
+C ObjC Var(warn_designated_init) Init(0) Warning LangEnabledBy(C ObjC,Wall)
+Warn about positional initialization of structs requiring designated 
initializers
+
 Wdiv-by-zero
 C ObjC C++ ObjC++ Var(warn_div_by_zero) Init(1) Warning
 Warn about compile-time integer division by zero
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 92304b0..84f917f 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -6887,6 +6887,7 @@ struct constructor_stack
   char outer;
   char incremental;
   char designated;
+  int designator_depth;
 };
 
 static struct constructor_stack *constructor_stack;
@@ -7058,6 +7059,7 @@ really_start_incremental_init (tree type)
   p->outer = 0;
   p->incremental = constructor_incremental;
   p->designated = constructor_designated;
+  p->designator_depth = designator_depth;
   p->next = 0;
   constructor_stack = p;
 
@@ -7203,6 +7205,7 @@ push_init_level (int implicit, struct obstack * 
braced_init_obstack)
   p->outer = 0;
   p->incremental = constructor_incremental;
   p->designated = constructor_designated;
+  p->designator_depth = designator_depth;
   p->next = constructor_stack;
   p->range_stack = 0;
   constructor_stack = p;
@@ -7503,6 +7506,7 @@ pop_init_level (int implicit, struct obstack * 
braced_init_obstack)
   constructor_erroneous = p->erroneous;
   constructor_incremental 

[PATCH, rs6000] Implement -maltivec=be for vec_mergeh and vec_mergel Altivec builtins

2014-01-23 Thread Bill Schmidt
Hi,

This patch continues the series of changes to the Altivec builtins to
accommodate big-endian element order when targeting a little endian
machine.  Here the focus is on the vector merge-high and merge-low
operations.

The primary change is in altivec.md.  As an example, look at the pattern
altivec_vmrghw.  Previously, this was represented with a single
define_insn.  Now it's been split into a define_expand to create the
RTL, and a define_insn (*altivec_vmrghw_endian) to generate the hardware
instruction.  This is because we need a different selection vector when
using -maltivec=be and targeting LE.  (Normally LE and BE can use the
same selection vector, and GCC takes care of interpreting the indices as
left-to-right or right-to-left.)  The new define_insn also substitutes
vmrglw with swapped operands for vmrghw for little-endian mode, since
the hardware instruction has "big-endian bias" in the interpretation of
"high" and "low."

Because -maltivec=be applies only to programmer-specified builtins, we
need to adjust internal uses of altivec_vmrghw and friends.  Thus we
have a new define_insn altivec_vmrghw_internal that generates the
hardware instruction directly with none of the above transformations.
New unspecs are needed for these internal forms.

The VSX flavors of merge-high and merge-low are a little simpler (see
vsx.md).  Here we already had a define_expand where the instructions are
generated by separate xxpermdi patterns, and there are no internal uses
to worry about.  So we only need to change the selection vector in the
generated RTL.

There are four new test cases that cover all of the supported data
types.  Tests are divided between those that require only VMX
instructions and those that require VSX instructions.  There are also
variants for -maltivec and -maltivec=be.

Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
regressions.  Ok for trunk?

Thanks,
Bill


gcc:

2014-01-23  Bill Schmidt  

* config/rs6000/rs6000.c (altivec_expand_vec_perm_const):  Use
CODE_FOR_altivec_vmrg*_internal rather than
CODE_FOR_altivec_vmrg*.
* config/rs6000/vsx.md (vsx_mergel_): Adjust for
-maltivec=be with LE targets.
(vsx_mergeh_): Likewise.
* config/rs6000/altivec.md (UNSPEC_VMRG[HL][BHW]_INTERNAL): New
unspecs.
(mulv8hi3): Use gen_altivec_vmrg[hl]w_internal.
(altivec_vmrghb): Replace with define_expand and new
*altivec_vmrghb_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrghb_internal): New define_insn.
(altivec_vmrghh): Replace with define_expand and new
*altivec_vmrghh_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrghh_internal): New define_insn.
(altivec_vmrghw): Replace with define_expand and new
*altivec_vmrghw_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrghw_internal): New define_insn.
(*altivec_vmrghsf): Adjust for endianness.
(altivec_vmrglb): Replace with define_expand and new
*altivec_vmrglb_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrglb_internal): New define_insn.
(altivec_vmrglh): Replace with define_expand and new
*altivec_vmrglh_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrglh_internal): New define_insn.
(altivec_vmrglw): Replace with define_expand and new
*altivec_vmrglw_endian insn; adjust for -maltivec=be with LE
targets.
(altivec_vmrglw_internal): New define_insn.
(*altivec_vmrglsf): Adjust for endianness.
(vec_widen_umult_hi_v16qi): Use gen_altivec_vmrghh_internal.
(vec_widen_umult_lo_v16qi): Use gen_altivec_vmrglh_internal.
(vec_widen_smult_hi_v16qi): Use gen_altivec_vmrghh_internal.
(vec_widen_smult_lo_v16qi): Use gen_altivec_vmrglh_internal.
(vec_widen_umult_hi_v8hi): Use gen_altivec_vmrghw_internal.
(vec_widen_umult_lo_v8hi): Use gen_altivec_vmrglw_internal.
(vec_widen_smult_hi_v8hi): Use gen_altivec_vmrghw_internal.
(vec_widen_smult_lo_v8hi): Use gen_altivec_vmrglw_internal.

gcc/testsuite:

2014-01-23  Bill Schmidt  

* gcc.dg/vmx/merge-be-order.c: New.
* gcc.dg/vmx/merge.c: New.
* gcc.dg/vmx/merge-vsx-be-order.c: New.
* gcc.dg/vmx/merge-vsx.c: New.


Index: gcc/testsuite/gcc.dg/vmx/merge-be-order.c
===
--- gcc/testsuite/gcc.dg/vmx/merge-be-order.c   (revision 0)
+++ gcc/testsuite/gcc.dg/vmx/merge-be-order.c   (revision 0)
@@ -0,0 +1,96 @@
+/* { dg-options "-maltivec=be -mabi=altivec -std=gnu99 -mno-vsx" } */
+
+#include "harness.h"
+
+static void test()
+{
+  /* Input vectors.  */
+  vector unsigned char vuca = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+  vector unsigned char vucb
+= {16,17,18,19,20,21,22,23,24,25,26,27,28,2

[Google gcc-4_8] always emit __gcov_get_profile_prefix when linking libgcov.a

2014-01-23 Thread Rong Xu
Hi,

This patch is for google/gcc-4_8 branch. It fixes a regression in
earlier libgcov refactoring.

Thanks,

-Rong

2014-01-23  Rong Xu  

* libgcov-driver.c (__gcov_get_profile_prefix): Always emit
this function.

Index: libgcov-driver.c
===
--- libgcov-driver.c(revision 206736)
+++ libgcov-driver.c(working copy)
@@ -68,6 +68,8 @@ extern struct gcov_info *get_gcov_list (void) ATTR
these symbols will always need to be resolved.  */
 void (*__gcov_dummy_ref1)(void) = &__gcov_reset;
 void (*__gcov_dummy_ref2)(void) = &__gcov_dump;
+extern char *__gcov_get_profile_prefix (void);
+char *(*__gcov_dummy_ref3)(void) = &__gcov_get_profile_prefix;

 /* Default callback function for profile instrumentation callback.  */
 extern void __coverage_callback (gcov_type, int);


Re: [Google gcc-4_8] always emit __gcov_get_profile_prefix when linking libgcov.a

2014-01-23 Thread Xinliang David Li
ok.

David

On Thu, Jan 23, 2014 at 4:21 PM, Rong Xu  wrote:
> Hi,
>
> This patch is for google/gcc-4_8 branch. It fixes a regression in
> earlier libgcov refactoring.
>
> Thanks,
>
> -Rong
>
> 2014-01-23  Rong Xu  
>
> * libgcov-driver.c (__gcov_get_profile_prefix): Always emit
> this function.
>
> Index: libgcov-driver.c
> ===
> --- libgcov-driver.c(revision 206736)
> +++ libgcov-driver.c(working copy)
> @@ -68,6 +68,8 @@ extern struct gcov_info *get_gcov_list (void) ATTR
> these symbols will always need to be resolved.  */
>  void (*__gcov_dummy_ref1)(void) = &__gcov_reset;
>  void (*__gcov_dummy_ref2)(void) = &__gcov_dump;
> +extern char *__gcov_get_profile_prefix (void);
> +char *(*__gcov_dummy_ref3)(void) = &__gcov_get_profile_prefix;
>
>  /* Default callback function for profile instrumentation callback.  */
>  extern void __coverage_callback (gcov_type, int);


Re: [PATCH] Set correct probability for ORDER/UNORDER jumps

2014-01-23 Thread Xinliang David Li
Is it possible to add a test case?

David

On Wed, Jan 22, 2014 at 6:08 PM, Dehao Chen  wrote:
> During floating point comparison, compiler inserts conditional jumps
> to check if the operand is NAN. These type of checks are normally
> false. However, compiler sets the probability the same as the original
> float-compare conditional jump. This patch sets the probability of
> these conditional jumps as 1%.
>
> Bootstrapped and passed regression test.
>
> OK for trunk?
>
> Thanks,
> Dehao
>
> gcc/ChangeLog:
> 2014-01-22  Dehao Chen  
>
> * dojump.c (do_compare_rtx_and_jump): Sets correct probability for
> compiler inserted conditional jumps for NAN float check.
>
> Index: gcc/dojump.c
> ===
> --- gcc/dojump.c (revision 206945)
> +++ gcc/dojump.c (working copy)
> @@ -1103,6 +1103,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt
>
>else
>  {
> +  int first_prob = prob;
> +  if (first_code == UNORDERED)
> + first_prob = REG_BR_PROB_BASE / 100;
> +  else if (first_code == ORDERED)
> + first_prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100;
>if (and_them)
>   {
>rtx dest_label;
> @@ -1116,11 +1121,13 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt
>else
>  dest_label = if_false_label;
>do_compare_rtx_and_jump (op0, op1, first_code,
> unsignedp, mode,
> -   size, dest_label, NULL_RTX, prob);
> +   size, dest_label, NULL_RTX,
> +   first_prob);
>   }
>else
>  do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, 
> mode,
> - size, NULL_RTX, if_true_label, prob);
> + size, NULL_RTX, if_true_label,
> + first_prob);
>  }
>   }


Re: [PATCH #2] PR59909, Fix powerpcle64 power8 bootstrap (quad memory support)

2014-01-23 Thread David Edelsohn
On Thu, Jan 23, 2014 at 6:35 PM, Michael Meissner
 wrote:
> This is my fixed patch that correctly swaps the words for atomic quad memory
> accesses in little endian.  It would be nice in the future to eliminate some 
> of
> the extra moves for things like compare and add.
>
> I have tested this with a bootstrap (using --with-cpu=power8) on a little
> endian power8 system, and I verified the example program works.  I'm running
> the rest of the test suite right now.  Assuming the test suite doesn't show
> anything wrong, is it ok to commit?
>
> [gcc]
> 2014-01-23  Michael Meissner  
>
> PR target/59909
> * doc/invoke.texi (RS/6000 and PowerPC Options): Document
> -mquad-memory-atomic.  Update -mquad-memory documentation to say
> it is only used for non-atomic loads/stores.
>
> * config/rs6000/predicates.md (quad_int_reg_operand): Allow either
> -mquad-memory or -mquad-memory-atomic switches.
>
> * config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Add
> -mquad-memory-atomic to ISA 2.07 support.
>
> * config/rs6000/rs6000.opt (-mquad-memory-atomic): Add new switch
> to separate support of normal quad word memory operations (ldq,
> stq) from the atomic quad word memory operations.
>
> * config/rs6000/rs6000.c (rs6000_option_override_internal): Add
> support to separate non-atomic quad word operations from atomic
> quad word operations.  Disable non-atomic quad word operations in
> little endian mode so that we don't have to swap words after the
> load and before the store.
> (quad_load_store_p): Add comment about atomic quad word support.
> (rs6000_opt_masks): Add -mquad-memory-atomic to the list of
> options printed with -mdebug=reg.
>
> * config/rs6000/rs6000.h (TARGET_SYNC_TI): Use
> -mquad-memory-atomic as the test for whether we have quad word
> atomic instructions.
> (TARGET_SYNC_HI_QI): If either -mquad-memory-atomic,
> -mquad-memory, or -mp8-vector are used, allow byte/half-word
> atomic operations.
>
> * config/rs6000/sync.md (load_lockedti): Insure that the address
> is a proper indexed or indirect address for the lqarx instruction.
> On little endian systems, swap the hi/lo registers after the lqarx
> instruction.
> (load_lockedpti): Use indexed_or_indirect_operand predicate to
> insure the address is valid for the lqarx instruction.
> (store_conditionalti): Insure that the address is a proper indexed
> or indirect address for the stqcrx. instruction.  On little endian
> systems, swap the hi/lo registers before doing the stqcrx.
> instruction.
> (store_conditionalpti): Use indexed_or_indirect_operand predicate to
> insure the address is valid for the stqcrx. instruction.
>
> * gcc/config/rs6000/rs6000.md (UNSPEC_TI_PTI_SWAP): New UNSPEC for
> dealing with quad word atomic instructions in little endian mode.
>
> * gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
> Define __QUAD_MEMORY__ and __QUAD_MEMORY_ATOMIC__ based on what
> type of quad memory support is available.
>
> [gcc/testsuite]
> 2014-01-23  Michael Meissner  
>
> PR target/59909
> * gcc.target/powerpc/quad-atomic.c: New file to test power8 quad
> word atomic functions at runtime.

Okay.

Thanks, David


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread Jan Hubicka
Hi,
this is improved patch I am testing.  The basic idea is to remove push
expanders for cases where we do not have push instruction anyway.
emit_move_insns then resorts to unconditonally call move expander
with push operand.  I expended ix86_expand_vector_move to handle
it gracefully and for that I borrowed emit_move_resolve_push
function from expr.c since it seemed pointless to preserve
duplicated logic in ix86_expand_push.

I can easily imagine that scheduling around function call sequences
matters, so I also updated push/pop expanders to preserve memory attributes.

Eventually I found the attributes to be blank because of logic in expr.c
that clears alias info when sibcall is enabled.  We can now do better
by only disabling it in functions that actually do sibcalls.

Bootstrap/regtest running on x86_64-linux, OK for the non-i386 parts
if it passes?

Honza

* expr.c (emit_move_resolve_push): Export; be bit more selective
on when to clear alias set.
* expr.h (emit_move_resolve_push): Declare.
* function.h (struct function): Add tail_call_marked.
* tree-tailcall.c (optimize_tail_call): Set tail_call_marked.
* config/i386/i386-protos.h (ix86_expand_push): Remove.
* config/i386/i386.md (TImode move expander): De not call
ix86_expand_push.
(FP push expanders): Preserve memory attributes.
* config/i386/sse.md (push1): Remove.
* config/i386/i386.c (ix86_expand_vector_move): Handle push
operation.
(ix86_expand_push): Remove.
* config/i386/mmx.md (push1): Remove.
Index: expr.c
===
--- expr.c  (revision 206946)
+++ expr.c  (working copy)
@@ -3221,7 +3221,7 @@
 /* A subroutine of emit_move_insn_1.  X is a push_operand in MODE.
Return an equivalent MEM that does not use an auto-increment.  */
 
-static rtx
+rtx
 emit_move_resolve_push (enum machine_mode mode, rtx x)
 {
   enum rtx_code code = GET_CODE (XEXP (x, 0));
@@ -4070,7 +4070,7 @@
 {
   set_mem_attributes (dest, type, 1);
 
-  if (flag_optimize_sibling_calls)
+  if (cfun->tail_call_marked)
/* Function incoming arguments may overlap with sibling call
   outgoing arguments and we cannot allow reordering of reads
   from function arguments with stores to outgoing arguments
Index: expr.h
===
--- expr.h  (revision 206946)
+++ expr.h  (working copy)
@@ -413,6 +413,7 @@
 
 extern rtx emit_move_complex_push (enum machine_mode, rtx, rtx);
 extern rtx emit_move_complex_parts (rtx, rtx);
+extern rtx emit_move_resolve_push (enum machine_mode, rtx);
 
 /* Push a block of length SIZE (perhaps variable)
and return an rtx to address the beginning of the block.  */
Index: function.h
===
--- function.h  (revision 206946)
+++ function.h  (working copy)
@@ -667,6 +667,9 @@
   /* Nonzero if the current function contains any loops with
  nonzero value in loop->simduid.  */
   unsigned int has_simduid_loops : 1;
+
+  /* Set when the tail call has been identified.  */
+  unsigned int tail_call_marked : 1;
 };
 
 /* Add the decl D to the local_decls list of FUN.  */
Index: tree-tailcall.c
===
--- tree-tailcall.c (revision 206946)
+++ tree-tailcall.c (working copy)
@@ -909,6 +909,7 @@
   gimple stmt = gsi_stmt (t->call_gsi);
 
   gimple_call_set_tail (stmt, true);
+  cfun->tail_call_marked = true;
   if (dump_file && (dump_flags & TDF_DETAILS))
 {
  fprintf (dump_file, "Found tail call ");
Index: config/i386/i386-protos.h
===
--- config/i386/i386-protos.h   (revision 206946)
+++ config/i386/i386-protos.h   (working copy)
@@ -84,7 +84,6 @@
 extern void ix86_expand_move (enum machine_mode, rtx[]);
 extern void ix86_expand_vector_move (enum machine_mode, rtx[]);
 extern void ix86_expand_vector_move_misalign (enum machine_mode, rtx[]);
-extern void ix86_expand_push (enum machine_mode, rtx);
 extern rtx ix86_fixup_binary_operands (enum rtx_code,
   enum machine_mode, rtx[]);
 extern void ix86_fixup_binary_operands_no_copy (enum rtx_code,
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 206946)
+++ config/i386/i386.md (working copy)
@@ -1818,8 +1818,6 @@
 {
   if (TARGET_64BIT)
 ix86_expand_move (TImode, operands);
-  else if (push_operand (operands[0], TImode))
-ix86_expand_push (TImode, operands[1]);
   else
 ix86_expand_vector_move (TImode, operands);
   DONE;
@@ -2665,7 +2663,11 @@
(match_operand:TF 1 "sse_reg_operand"))]
   "TARGET_SSE && reload_completed"
   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
-

Re: [PATCH, rs6000] Avoid optimization problem for VEC_PERM_EXPR

2014-01-23 Thread David Edelsohn
On Thu, Jan 23, 2014 at 6:43 PM, Bill Schmidt
 wrote:
> Hi,
>
> While testing another patch, I hit a regression at -O2 for two of the
> vector shuffle tests.  This patch fixes the problem.
>
> The problem was introduced with the little endian fixes for
> VEC_PERM_EXPR.  The original change performed the necessary
> transformation at expand time, but this is incorrect.  This creates a
> technically incorrect representation in the RTL, and RTL simplification
> can subsequently fold the expression in an unexpected way.  The correct
> fix is to delay the transformation until final code generation.
>
> Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
> regressions.  Is this ok for trunk?  I will also plan to backport this
> to ibm/gcc-4_8-branch after burn-in.
>
> Thanks,
> Bill
>
>
> 2014-01-23  Bill Schmidt  
>
> * config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Remove
> correction for little endian...
> * config/rs6000/vsx.md (vsx_xxpermdi2__1): ...and move it to
> here.

Okay. Would you please move the comment also?

Thanks, David


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread H.J. Lu
On Thu, Jan 23, 2014 at 4:39 PM, Jan Hubicka  wrote:
> Hi,
> this is improved patch I am testing.  The basic idea is to remove push
> expanders for cases where we do not have push instruction anyway.
> emit_move_insns then resorts to unconditonally call move expander
> with push operand.  I expended ix86_expand_vector_move to handle
> it gracefully and for that I borrowed emit_move_resolve_push
> function from expr.c since it seemed pointless to preserve
> duplicated logic in ix86_expand_push.
>
> I can easily imagine that scheduling around function call sequences
> matters, so I also updated push/pop expanders to preserve memory attributes.
>
> Eventually I found the attributes to be blank because of logic in expr.c
> that clears alias info when sibcall is enabled.  We can now do better
> by only disabling it in functions that actually do sibcalls.
>
> Bootstrap/regtest running on x86_64-linux, OK for the non-i386 parts
> if it passes?
>
> Honza
>
> * expr.c (emit_move_resolve_push): Export; be bit more selective
> on when to clear alias set.
> * expr.h (emit_move_resolve_push): Declare.
> * function.h (struct function): Add tail_call_marked.
> * tree-tailcall.c (optimize_tail_call): Set tail_call_marked.
> * config/i386/i386-protos.h (ix86_expand_push): Remove.
> * config/i386/i386.md (TImode move expander): De not call
> ix86_expand_push.
> (FP push expanders): Preserve memory attributes.
> * config/i386/sse.md (push1): Remove.
> * config/i386/i386.c (ix86_expand_vector_move): Handle push
> operation.
> (ix86_expand_push): Remove.
> * config/i386/mmx.md (push1): Remove.
...

> --- config/i386/i386.md (revision 206946)
> +++ config/i386/i386.md (working copy)
> @@ -1818,8 +1818,6 @@
>  {
>if (TARGET_64BIT)
>  ix86_expand_move (TImode, operands);
> -  else if (push_operand (operands[0], TImode))
> -ix86_expand_push (TImode, operands[1]);
>else
>  ix86_expand_vector_move (TImode, operands);
>DONE;
> @@ -2665,7 +2663,11 @@
> (match_operand:TF 1 "sse_reg_operand"))]
>"TARGET_SSE && reload_completed"
>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
> -   (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
> +   (set (match_dup 0) (match_dup 1))]
> +{
> +  /* Preserve memory attributes. */
> +  operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);
> +})
>
>  (define_insn "*pushxf"
>[(set (match_operand:XF 0 "push_operand" "=<,<")
> @@ -2691,8 +2693,12 @@
> (match_operand:XF 1 "fp_register_operand"))]
>"reload_completed"
>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
> -   (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
> -  "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
> +   (set (match_dup 0) (match_dup 1))]
> +{
> +  operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));
> +  /* Preserve memory attributes. */
> +  operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);
> +})
>
>  (define_insn "*pushdf"
>[(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
> @@ -2713,7 +2719,11 @@
> (match_operand:DF 1 "any_fp_register_operand"))]
>"reload_completed"
>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
> -   (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
> +   (set (match_dup 0) (match_dup 1))]
> +{
> +  /* Preserve memory attributes. */
> +  operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);
> +})
>
>  (define_insn "*pushsf_rex64"
>[(set (match_operand:SF 0 "push_operand" "=X,X,X")
> @@ -2747,8 +2757,12 @@
> (match_operand:SF 1 "any_fp_register_operand"))]
>"reload_completed"
>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
> -   (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
> -  "operands[2] = GEN_INT (-);")
> +   (set (match_dup 0) (match_dup 1))]
> +{
> +  operands[2] = GEN_INT (-);
> +  /* Preserve memory attributes. */
> +  operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);
> +})
>

This piece code is wrong for x32:

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

I am testing:

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index ddc3be6..92e8fd0 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -2765,7 +2765,20 @@
   "reload_completed"
   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
(set (mem:SF (reg:P SP_REG)) (match_dup 1))]
-  "operands[2] = GEN_INT (-);")
+{
+  rtx op = XEXP (operands[0], 0);
+  if (GET_CODE (op) == PRE_DEC)
+{
+  gcc_assert (!TARGET_64BIT);
+  op = GEN_INT (-4);
+}
+  else
+{
+  op = XEXP (XEXP (op, 1), 1);
+  gcc_assert (CONST_INT_P (op));
+}
+  operands[2] = op;
+})

 (define_split
   [(set (match_operand:SF 0 "push_operand")


-- 
H.J.


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread Jan Hubicka
> This piece code is wrong for x32:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59929

Though an independent bug ;)
> 
> I am testing:
> 
> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> index ddc3be6..92e8fd0 100644
> --- a/gcc/config/i386/i386.md
> +++ b/gcc/config/i386/i386.md
> @@ -2765,7 +2765,20 @@
>"reload_completed"
>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
> (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
> -  "operands[2] = GEN_INT (-);")
> +{
> +  rtx op = XEXP (operands[0], 0);
> +  if (GET_CODE (op) == PRE_DEC)
> +{
> +  gcc_assert (!TARGET_64BIT);
> +  op = GEN_INT (-4);
> +}
> +  else
> +{
> +  op = XEXP (XEXP (op, 1), 1);
> +  gcc_assert (CONST_INT_P (op));
> +}
> +  operands[2] = op;
> +})

Not pretty, but I can not think of much more compact way, so OK
if it passes.
> 
>  (define_split
>[(set (match_operand:SF 0 "push_operand")
> 
> 
> -- 
> H.J.


Go patch committed: Convert named types before flattening

2014-01-23 Thread Ian Lance Taylor
This patch to the Go frontend from Chris Manghane converts named types
before the flattening pass.  This will permit the flattening pass to get
the size of types where necessary.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 124e26b93f79 go/go.cc
--- a/go/go.cc	Wed Jan 22 11:10:28 2014 -0800
+++ b/go/go.cc	Thu Jan 23 17:00:16 2014 -0800
@@ -119,6 +119,9 @@
   // Use temporary variables to force order of evaluation.
   ::gogo->order_evaluations();
 
+  // Convert named types to backend representation.
+  ::gogo->convert_named_types();
+
   // Flatten the parse tree.
   ::gogo->flatten();
 
diff -r 124e26b93f79 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed Jan 22 11:10:28 2014 -0800
+++ b/go/gogo-tree.cc	Thu Jan 23 17:00:16 2014 -0800
@@ -755,7 +755,6 @@
 void
 Gogo::write_globals()
 {
-  this->convert_named_types();
   this->build_interface_method_tables();
 
   Bindings* bindings = this->current_bindings();


Re: [PATCH, rs6000] Avoid optimization problem for VEC_PERM_EXPR

2014-01-23 Thread Bill Schmidt


On Thu, 2014-01-23 at 19:42 -0500, David Edelsohn wrote:
> On Thu, Jan 23, 2014 at 6:43 PM, Bill Schmidt
>  wrote:
> > Hi,
> >
> > While testing another patch, I hit a regression at -O2 for two of the
> > vector shuffle tests.  This patch fixes the problem.
> >
> > The problem was introduced with the little endian fixes for
> > VEC_PERM_EXPR.  The original change performed the necessary
> > transformation at expand time, but this is incorrect.  This creates a
> > technically incorrect representation in the RTL, and RTL simplification
> > can subsequently fold the expression in an unexpected way.  The correct
> > fix is to delay the transformation until final code generation.
> >
> > Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
> > regressions.  Is this ok for trunk?  I will also plan to backport this
> > to ibm/gcc-4_8-branch after burn-in.
> >
> > Thanks,
> > Bill
> >
> >
> > 2014-01-23  Bill Schmidt  
> >
> > * config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Remove
> > correction for little endian...
> > * config/rs6000/vsx.md (vsx_xxpermdi2__1): ...and move it to
> > here.
> 
> Okay. Would you please move the comment also?

Oh, sure.  Will do.

Bill
> 
> Thanks, David
> 



[jit] Add contrib/jit-coverage-report.py

2014-01-23 Thread David Malcolm
Whilst reimplementing the API to remove the need to use callbacks, I
noticed that although all the tests were passing, some API functions
were still stubbed out in my new implementation i.e. we're missing test
coverage.

The following script (crudely) determines which API symbols are used
in which test cases, and prints a coverage report.

In particular the only remaining symbol with no coverage is
"gcc_jit_rvalue_access_field".

Committed to dmalcolm/jit branch:

contrib/
* jit-coverage-report.py: New file: a script to print crude
code-coverage information for the libgccjit API.
---
 contrib/ChangeLog.jit  |  4 +++
 contrib/jit-coverage-report.py | 67 ++
 2 files changed, 71 insertions(+)
 create mode 100644 contrib/ChangeLog.jit
 create mode 100644 contrib/jit-coverage-report.py

diff --git a/contrib/ChangeLog.jit b/contrib/ChangeLog.jit
new file mode 100644
index 000..79be84d
--- /dev/null
+++ b/contrib/ChangeLog.jit
@@ -0,0 +1,4 @@
+2014-01-23  David Malcolm  
+
+   * jit-coverage-report.py: New file: a script to print crude
+   code-coverage information for the libgccjit API.
diff --git a/contrib/jit-coverage-report.py b/contrib/jit-coverage-report.py
new file mode 100644
index 000..529336f
--- /dev/null
+++ b/contrib/jit-coverage-report.py
@@ -0,0 +1,67 @@
+#! /usr/bin/python
+#
+# Print a report on which libgccjit.so symbols are used in which test
+# cases, and which lack test coverage.  Tested with Python 2.7 and 3.2
+# To be run from the root directory of the source tree.
+#
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# Written by David Malcolm .
+#
+# This script is Free Software, and it can be copied, distributed and
+# modified as defined in the GNU General Public License.  A copy of
+# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
+
+from collections import Counter
+import glob
+import re
+import sys
+
+def parse_map_file(path):
+"""
+Parse libgccjit.map, returning the symbols in the API as a list of str.
+"""
+syms = []
+with open(path) as f:
+for line in f:
+m = re.match('^\s+([a-z_]+);$', line)
+if m:
+syms.append(m.group(1))
+return syms
+
+def parse_test_case(path):
+"""
+Locate all symbol-like things in a C test case, yielding
+them as a sequence of str.
+"""
+with open(path) as f:
+for line in f:
+for m in re.finditer('([_A-Za-z][_A-Za-z0-9]*)', line):
+yield m.group(1)
+
+def find_test_cases():
+for path in glob.glob('gcc/testsuite/jit.dg/*.[ch]'):
+yield path
+
+api_syms = parse_map_file('gcc/jit/libgccjit.map')
+
+syms_in_test_cases = {}
+for path in find_test_cases():
+syms_in_test_cases[path] = list(parse_test_case(path))
+
+uses = Counter()
+for sym in sorted(api_syms):
+print('symbol: %s' % sym)
+uses[sym] = 0
+for path in syms_in_test_cases:
+count = syms_in_test_cases[path].count(sym)
+uses[sym] += count
+if count:
+print('  uses in %s: %i' % (path, count))
+if uses[sym] == 0:
+print('  NEVER USED')
+sys.stdout.write('\n')
+
+layout = '%40s  %5s  %s'
+print(layout % ('SYMBOL', 'USES', 'HISTOGRAM'))
+for sym, count in uses.most_common():
+print(layout % (sym, count, '*' * count if count else 'UNUSED'))
-- 
1.7.11.7



RE: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals

2014-01-23 Thread Bernd Edlinger
Hi,
On Thu, 23 Jan 2014 18:12:45, Jakub Jelinek wrote:
> 
> On Wed, Jan 22, 2014 at 09:16:02AM +0100, Dodji Seketeli wrote:
>> +static fcache*
>> +add_file_to_cache_tab (const char *file_path)
>> +{
>> +
>> + FILE *fp = fopen (file_path, "r");
>> + if (ferror (fp))
>> + {
>> + fclose (fp);
>> + return NULL;
>> + }
> 
> I've seen various segfaults here when playing with preprocessed sources
> from PRs (obviously don't have the original source files).
> When fopen fails, it just returns NULL, so I don't see why you just don't
> do
> if (fp == NULL)
> return fp;
> 
> Jakub

This would be a good idea for test cases too.
However the test system always calls the compiler with
-fno-diagnostics-show-caret so I doubt your test case
is actually testing anything when it is called from the
test environment with that option.

Bernd.

Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-23 Thread H.J. Lu
On Thu, Jan 23, 2014 at 4:54 PM, Jan Hubicka  wrote:
>> This piece code is wrong for x32:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59929
>
> Though an independent bug ;)
>>
>> I am testing:
>>
>> diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
>> index ddc3be6..92e8fd0 100644
>> --- a/gcc/config/i386/i386.md
>> +++ b/gcc/config/i386/i386.md
>> @@ -2765,7 +2765,20 @@
>>"reload_completed"
>>[(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
>> (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
>> -  "operands[2] = GEN_INT (-);")
>> +{
>> +  rtx op = XEXP (operands[0], 0);
>> +  if (GET_CODE (op) == PRE_DEC)
>> +{
>> +  gcc_assert (!TARGET_64BIT);
>> +  op = GEN_INT (-4);
>> +}
>> +  else
>> +{
>> +  op = XEXP (XEXP (op, 1), 1);
>> +  gcc_assert (CONST_INT_P (op));
>> +}
>> +  operands[2] = op;
>> +})
>
> Not pretty, but I can not think of much more compact way, so OK
> if it passes.
>>
>>  (define_split
>>[(set (match_operand:SF 0 "push_operand")
>

This is the patch I checked in.  I will backport it to 4.8 branch
after a few days.

Thanks.


-- 
H.J.
---
Index: ChangeLog
===
--- ChangeLog(revision 207022)
+++ ChangeLog(working copy)
@@ -1,3 +1,9 @@
+2014-01-23  H.J. Lu  
+
+PR target/59929
+* config/i386/i386.md (pushsf splitter): Get stack adjustment
+from push operand if code of push isn't PRE_DEC.
+
 2014-01-23  Michael Meissner  

 PR target/59909
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog(revision 207022)
+++ testsuite/ChangeLog(working copy)
@@ -1,3 +1,8 @@
+2014-01-23  H.J. Lu  
+
+PR target/59929
+* gcc.target/i386/pr59929.c: New test.
+
 2014-01-23  Michael Meissner  

 PR target/59909
Index: testsuite/gcc.target/i386/pr59929.c
===
--- testsuite/gcc.target/i386/pr59929.c(revision 0)
+++ testsuite/gcc.target/i386/pr59929.c(revision 207023)
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+/* { dg-options "-O0 -mno-accumulate-outgoing-args" } */
+/* { dg-options "-O0 -mno-accumulate-outgoing-args -mx32
-maddress-mode=short" { target x32 } } */
+
+void
+__attribute__ ((noinline))
+test (float x1, float x2, float x3, float x4, float x5, float x6,
+  float x7, float x8, float x9, float x10, float x11, float x12,
+  float x13, float x14, float x15, float x16)
+{
+  if (x1 != 91
+  || x2 != 92
+  || x3 != 93
+  || x4 != 94
+  || x5 != 95
+  || x6 != 96
+  || x7 != 97
+  || x8 != 98
+  || x9 != 99
+  || x10 != 100
+  || x11 != 101
+  || x12 != 102
+  || x13 != 103
+  || x14 != 104
+  || x15 != 105
+  || x16 != 106)
+__builtin_abort ();
+}
+
+float x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13,
+  x14, x15, x16;
+
+int
+main ()
+{
+  x1 = 91;
+  x2 = 92;
+  x3 = 93;
+  x4 = 94;
+  x5 = 95;
+  x6 = 96;
+  x7 = 97;
+  x8 = 98;
+  x9 = 99;
+  x10 = 100;
+  x11 = 101;
+  x12 = 102;
+  x13 = 103;
+  x14 = 104;
+  x15 = 105;
+  x16 = 106;
+  test (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13,
+x14, x15, x16);
+  return 0;
+}
Index: config/i386/i386.md
===
--- config/i386/i386.md(revision 207022)
+++ config/i386/i386.md(working copy)
@@ -2765,7 +2765,20 @@
   "reload_completed"
   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
(set (mem:SF (reg:P SP_REG)) (match_dup 1))]
-  "operands[2] = GEN_INT (-);")
+{
+  rtx op = XEXP (operands[0], 0);
+  if (GET_CODE (op) == PRE_DEC)
+{
+  gcc_assert (!TARGET_64BIT);
+  op = GEN_INT (-4);
+}
+  else
+{
+  op = XEXP (XEXP (op, 1), 1);
+  gcc_assert (CONST_INT_P (op));
+}
+  operands[2] = op;
+})

 (define_split
   [(set (match_operand:SF 0 "push_operand")


Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals

2014-01-23 Thread Dodji Seketeli
Jakub Jelinek  writes:

> On Wed, Jan 22, 2014 at 09:16:02AM +0100, Dodji Seketeli wrote:
>> +static fcache*
>> +add_file_to_cache_tab (const char *file_path)
>> +{
>> +
>> +  FILE *fp = fopen (file_path, "r");
>> +  if (ferror (fp))
>> +{
>> +  fclose (fp);
>> +  return NULL;
>> +}
>
> I've seen various segfaults here when playing with preprocessed sources
> from PRs (obviously don't have the original source files).
> When fopen fails, it just returns NULL, so I don't see why you just don't
> do
>   if (fp == NULL)
> return fp;

Right, I am testing the patch below.

* input.c (add_file_to_cache_tab): Handle the case where fopen
returns NULL.

diff --git a/gcc/input.c b/gcc/input.c
index 290680c..547c177 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -293,11 +293,8 @@ add_file_to_cache_tab (const char *file_path)
 {
 
   FILE *fp = fopen (file_path, "r");
-  if (ferror (fp))
-{
-  fclose (fp);
-  return NULL;
-}
+  if (fp == NULL)
+return NULL;
 
   unsigned highest_use_count = 0;
   fcache *r = evicted_cache_tab_entry (&highest_use_count);
-- 
Dodji