Re: [PATCH 0/2] Convert s390 to atomic optabs, v2

2012-08-01 Thread Richard Guenther
On Tue, 31 Jul 2012, Richard Henderson wrote:

 On 2012-07-31 02:09, Richard Guenther wrote:
  What do we expect __builtin_compare_exchange to do for
  unaligned inputs?
 
 At the moment we expect it to SIGBUS, as a rule.
 
 We'd *like* to defer to the library routine for unaligned,
 but we don't do that yet.

I see.  So your issue is that you don't get the knowledge
that the address is even more aligned than required by the
builtin.

 Too bad about not being able to query addresses/ssa_names
 for their alignment; I thought we could do that already.

We can - just we cannot rely on type information for addresses,
mainly because people write non-conforming C code all the time
(and thus we settled on their side for middle-end semantics).
On x86_64 it's common to do

int foo (int *p)
{
   if ((uintptr_t)p  3)
 return 0;
   return *p;
}

and if we'd use type information for 'p' then we'd optimize away
the alignment test ...

So we only use type information when seeing an actual memory
reference where we make sure to keep alignment info correct
(which we don't bother to do for addresses).

Richard.


[PATCH][7/n] into-SSA TLC

2012-08-01 Thread Richard Guenther

This cleans up the way we rename all virtual operands throughout the
compiler by simply providing an abstraction for that.  
mark_sym_for_renaming is gone then.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

I will apply 6/n and 7/n later today.

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* graphite-clast-to-gimple.c (translate_clast_user): Rename
virtual operands.
* sese.c (graphite_copy_stmts_from_block): Do not rename virtual
operands here.
* tree-call-cdce.c (tree_call_cdce): Use
mark_virtual_operands_for_renaming.
* tree-eh.c (sink_clobbers): Simplify.
* tree-flow.h (mark_sym_for_renaming): Remove.
(mark_virtual_operands_for_renaming): New function.
* tree-if-conv.c (tree_if_conversion): Use
mark_virtual_operands_for_renaming.
* tree-inline.c (update_ssa_across_abnormal_edges): Likewise.
* tree-into-ssa.c (mark_sym_for_renaming): Remove.
(mark_virtual_operands_for_renaming): New function.
* tree-loop-distribution.c (tree_loop_distribution): Use
mark_virtual_operands_for_renaming.
* tree-ssa-dce.c (mark_virtual_operand_for_renaming): Do not
update stmts, use mark_virtual_operands_for_renaming.
* tree-ssa-tail-merge.c (release_last_vdef): Remove.
(replace_block_by): Adjust.
(tail_merge_optimize): Use mark_virtual_operands_for_renaming.
* tree-tailcall.c (tree_optimize_tail_calls_1): Use
mark_virtual_operands_for_renaming.
* tree-vect-slp.c (vect_slp_transform_bb): Likewise.
* tree-vectorizer.c (vectorize_loops): Likewise.

Index: trunk/gcc/graphite-clast-to-gimple.c
===
*** trunk.orig/gcc/graphite-clast-to-gimple.c   2012-07-16 14:10:04.0 
+0200
--- trunk/gcc/graphite-clast-to-gimple.c2012-07-31 15:48:12.614559839 
+0200
*** translate_clast_user (struct clast_user_
*** 1099,1104 
--- 1099,1105 
  
new_bb = next_e-src;
mark_bb_with_pbb (pbb, new_bb, bb_pbb_mapping);
+   mark_virtual_operands_for_renaming (cfun);
update_ssa (TODO_update_ssa);
  
return next_e;
Index: trunk/gcc/sese.c
===
*** trunk.orig/gcc/sese.c   2012-07-16 14:10:03.0 +0200
--- trunk/gcc/sese.c2012-07-31 15:46:35.698563204 +0200
*** graphite_copy_stmts_from_block (basic_bl
*** 604,610 
 operands.  */
copy = gimple_copy (stmt);
gsi_insert_after (gsi_tgt, copy, GSI_NEW_STMT);
-   mark_sym_for_renaming (gimple_vop (cfun));
  
maybe_duplicate_eh_stmt (copy, stmt);
gimple_duplicate_stmt_histograms (cfun, copy, cfun, stmt);
--- 604,609 
Index: trunk/gcc/tree-call-cdce.c
===
*** trunk.orig/gcc/tree-call-cdce.c 2012-07-16 14:10:02.0 +0200
--- trunk/gcc/tree-call-cdce.c  2012-07-31 15:51:26.601553133 +0200
*** tree_call_cdce (void)
*** 894,900 
free_dominance_info (CDI_POST_DOMINATORS);
/* As we introduced new control-flow we need to insert PHI-nodes
   for the call-clobbers of the remaining call.  */
!   mark_sym_for_renaming (gimple_vop (cfun));
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect
| TODO_remove_unused_locals);
  }
--- 894,900 
free_dominance_info (CDI_POST_DOMINATORS);
/* As we introduced new control-flow we need to insert PHI-nodes
   for the call-clobbers of the remaining call.  */
!   mark_virtual_operands_for_renaming (cfun);
return (TODO_update_ssa | TODO_cleanup_cfg | TODO_ggc_collect
| TODO_remove_unused_locals);
  }
Index: trunk/gcc/tree-eh.c
===
*** trunk.orig/gcc/tree-eh.c2012-07-16 14:10:02.0 +0200
--- trunk/gcc/tree-eh.c 2012-07-31 16:53:53.072423418 +0200
*** sink_clobbers (basic_block bb)
*** 3250,3271 
for (gsi_prev (gsi); !gsi_end_p (gsi); gsi_prev (gsi))
  {
gimple stmt = gsi_stmt (gsi);
-   tree vdef;
if (is_gimple_debug (stmt))
continue;
if (gimple_code (stmt) == GIMPLE_LABEL)
break;
unlink_stmt_vdef (stmt);
gsi_remove (gsi, false);
!   vdef = gimple_vdef (stmt);
!   if (vdef  TREE_CODE (vdef) == SSA_NAME)
!   {
! release_ssa_name (vdef);
! vdef = SSA_NAME_VAR (vdef);
! mark_sym_for_renaming (vdef);
! gimple_set_vdef (stmt, vdef);
! gimple_set_vuse (stmt, vdef);
!   }
gsi_insert_before (dgsi, stmt, GSI_SAME_STMT);
  }
  
--- 3250,3267 
for (gsi_prev (gsi); !gsi_end_p (gsi); gsi_prev (gsi))
  {
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
continue;

Re: [gimplefe] Patch for recognizing function declarations

2012-08-01 Thread Dodji Seketeli
Hello,

Sandeep Soni soni.sande...@gmail.com a écrit:

 Hi Diego,

 The following patch recognizes function declarations. I am now trying
 to create a gimple sequence of all the statements within the function
 body.
 The chagelog is as follows:

 2012-07-31   Sandeep Soni soni.sande...@gmail.com

   * parser.c (gl_token_starts_decl): Modify. Matches function decls.
   (gp_parse_parm_decl): New.
   (gp_parse_return_type): New.
   (gp_parse_function_decl): New.
   (gp_parse_decl): Modify. Adds case for function decls.

Just a random note.

For casual patch readers like myself, it would be nice to have test
cases added to commits like this, so that we have a better idea of the
syntax we are parsing against.

The functions are greatly commented in the patch, which helps, but I
think having test cases would be even better.

Thanks.

-- 
Dodji


Re: Commit: XStormy16: Add __clrsbhi2() to libgcc

2012-08-01 Thread nick clifton

Hi Johann,

Hi, just out of curiosity: Is there a special reason to add a
stormy16-specific implementation instead of using the code in
libgcc2.c? t-avr for example uses the C implementation in libgcc2.c
for HI. Are there disadvantages?


Apart from not using some slightly frightening makefile magic ?  No, no 
real reason.  In fact the implementation in stormy16/lib2funcs.c is 
based directly on the code in libgcc2.c.


I prefer my current approach because if it turns out that this function 
is used a lot then it will easy to replace the current C implementation 
with hand coded assembler.  But if there was a way to automate the 
detection of bit counting functions in libgcc2.c, so that when a new one 
is added we would not have to update t-avr or t-stormy16, then I would 
go with your approach.


Cheers
  Nick



Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-08-01 Thread Tobias Burnus

On 07/27/2012 07:26 PM, Mikael Morin wrote:

do you have a test case exhibiting the problem? It seems fine to me.


Your second test case was too convoluted for me - and as I wasn't at 
home, I couldn't test it. I now believe that your patch is okay; I will 
later formally review  it.


Do you intent to wrap it for final inclusion? I think it only lacks a 
dejaGNUified test case and a changelog.


 * * *

However, I found another spot where one needs to have a scalarizer; 
possibly a poor man's version is enough. Namely INTENT(OUT) handling. Do 
you have an idea how to best handle that case?


program test
  implicit none
  type t
integer, allocatable :: a
  end type t
  type(t) :: b(4,6)
  integer :: i, j

  do j = 1, 6
do i = 1, 4
  allocate (b(i,j)%a)
end do
  end do

  call sub (b(::2,::3))
  do j = 1, 6
do i = 1, 4
  print *, i, j, allocated (b(i,j)%a)
!  if (allocated (b(i,j)%a) .neqv. (mod (i-1,2) /= 0 .or. mod 
(j-1,3) /= 0))

!call abort ()
end do
  end do
contains
  subroutine sub (x)
type(t), intent(out) :: x(..)
  end subroutine sub
end program test


Tobias

PS: Note to self: Reject passing an assumed-size array to an INTENT(OUT) 
assumed-rank array, at least if it is polymorphic, finalizable, of a 
type with an allocatable ultimate component, or of a type for which 
default initialization is specified. [TS29113 seems to allow it, but 
one needs some check similar to F2008's C534. A constraint is not enough 
as it doesn't cover all cases, but the rest is the user's responsibility.]


Re: [PATCH] Improve debug info if tree DCE removes stores (PR debug/50317, fallout)

2012-08-01 Thread Richard Guenther
On Fri, Dec 2, 2011 at 8:28 PM, Jakub Jelinek ja...@redhat.com wrote:
 On Fri, Dec 02, 2011 at 02:27:40PM +0100, Richard Guenther wrote:
 This change seems wrong.  We are turning valid gimple

 # DEBUG D#2 = transfer.0  [with addres taken]

 into invalid one

 # DEBUG D#2 = transfer.0  [without address taken]

 once you update that stmt with update_stmt you'll get an SSA operand
 for transfer.0 which is not in SSA form because you fail to rewrite it
 into.

 Why do this in remove_unused_locals and not in update_address_taken?
 Or, why do it at all?

 I have a SSA operand checking patch that catches this now ...

 Here is a fix for that.  Instead of clearing TREE_ADDRESSABLE for
 unreferenced vars we allow them in target_for_debug_bind if they aren't
 referenced vars (thus we don't risk mixing VALUE tracking with the
 old style REG_EXPR/MEM_EXPR tracking of these variables).

 Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

 2011-12-02  Jakub Jelinek  ja...@redhat.com

 PR debug/50317
 * tree-ssa.c (target_for_debug_bind): Also allow is_gimple_reg_type
 vars that aren't referenced.
 (tree-ssa-live.c (remove_unused_locals): Don't clear TREE_ADDRESSABLE
 of unreferenced local vars.
 * cfgexpand.c (expand_debug_expr): For DEBUG_IMPLICIT_PTR allow also
 TREE_ADDRESSABLE vars that satisfy target_for_debug_bind.

 --- gcc/tree-ssa.c.jj   2011-11-29 08:58:52.0 +0100
 +++ gcc/tree-ssa.c  2011-12-02 15:04:03.494148642 +0100
 @@ -264,7 +264,12 @@ target_for_debug_bind (tree var)
  return NULL_TREE;

if (!is_gimple_reg (var))
 -return NULL_TREE;
 +{
 +  if (is_gimple_reg_type (TREE_TYPE (var))
 +  referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE)
 +   return var;
 +  return NULL_TREE;
 +}

With referenced-vars going away now I am running into the above use of
referenced-vars again.  So the above tries to increase the set of tracked
registers by noting that unused non-registers that might have become
registers are supposed to be tracked anyway.  But we do _not_ want to
have used non-register (but register type) variables tracked because we
do not track aliases?  Or because that would be prohibitively expensive?

That is, why is

Index: tree-ssa.c
===
--- tree-ssa.c  (revision 190031)
+++ tree-ssa.c  (working copy)
@@ -259,13 +259,9 @@ target_for_debug_bind (tree var)
   if (DECL_IGNORED_P (var))
 return NULL_TREE;

-  if (!is_gimple_reg (var))
-{
-  if (is_gimple_reg_type (TREE_TYPE (var))
-  referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE)
-   return var;
-  return NULL_TREE;
-}
+  /* var-tracking only tracks registers.  */
+  if (!is_gimple_reg_type (TREE_TYPE (var)))
+return NULL_TREE;

   return var;
 }

not what we want (minus dealing with fallout of having mixed SSA / non-SSA
after something makes var suitable for renaming into SSA form)?

Richard.

return var;
  }
 --- gcc/tree-ssa-live.c.jj  2011-12-02 01:52:27.0 +0100
 +++ gcc/tree-ssa-live.c 2011-12-02 15:04:59.601816335 +0100
 @@ -814,15 +814,7 @@ remove_unused_locals (void)
   bitmap_set_bit (global_unused_vars, DECL_UID (var));
 }
   else
 -   {
 - /* For unreferenced local vars drop TREE_ADDRESSABLE
 -bit in case it is referenced from debug stmts.  */
 - if (DECL_CONTEXT (var) == current_function_decl
 -  TREE_ADDRESSABLE (var)
 -  is_gimple_reg_type (TREE_TYPE (var)))
 -   TREE_ADDRESSABLE (var) = 0;
 - continue;
 -   }
 +   continue;
 }
else if (TREE_CODE (var) == VAR_DECL
 DECL_HARD_REGISTER (var)
 --- gcc/cfgexpand.c.jj  2011-12-02 01:52:27.0 +0100
 +++ gcc/cfgexpand.c 2011-12-02 15:24:37.982327507 +0100
 @@ -3325,7 +3325,8 @@ expand_debug_expr (tree exp)
   if ((TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (exp, 0)) == PARM_DECL
|| TREE_CODE (TREE_OPERAND (exp, 0)) == RESULT_DECL)
 -  !TREE_ADDRESSABLE (TREE_OPERAND (exp, 0)))
 +  (!TREE_ADDRESSABLE (TREE_OPERAND (exp, 0))
 + || target_for_debug_bind (TREE_OPERAND (exp, 0
 return gen_rtx_DEBUG_IMPLICIT_PTR (mode, TREE_OPERAND (exp, 0));

   if (handled_component_p (TREE_OPERAND (exp, 0)))
 @@ -3337,7 +3338,8 @@ expand_debug_expr (tree exp)
   if ((TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL)
 -  !TREE_ADDRESSABLE (decl)
 +  (!TREE_ADDRESSABLE (decl)
 + || target_for_debug_bind (decl))
(bitoffset % BITS_PER_UNIT) == 0
bitsize 

[google/main] Add -fno-section-anchors for powerpc, workround for Google ref b/6663281 (issue6443071)

2012-08-01 Thread Simon Baldwin
Workround for Google ref b/6663281

Appends -fno-section-anchors to -fprofile-{generate,use} -fripa, for powerpc
targets only.  No-op for other targets.

For google/main.  Tested for bootstrap and regression.

2012-08-01  Simon Baldwin  sim...@google.com

* gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp: Append
-fno-section-anchors to profile_option and feedback_option for
powerpc targets.  Workround for Google ref b/6663281.
* gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp: Likewise


Index: gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp
===
--- gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp(revision 190013)
+++ gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp(working copy)
@@ -45,6 +45,12 @@ load_lib profopt.exp
 set profile_option -fprofile-generate -fripa -D_PROFILE_GENERATE
 set feedback_option -fprofile-use -fripa -D_PROFILE_USE
 
+# Add -fno-section-anchors for powerpc.  Workround for Google ref b/6663281
+if {[istarget powerpc*-*-*]} {
+set profile_option $profile_option -fno-section-anchors
+set feedback_option $feedback_option -fno-section-anchors
+}
+
 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.c]] {
 # If we're only testing specific files and this isn't one of them, skip it.
 if ![runtest_file_p $runtests $src] then {
Index: gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp
===
--- gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp(revision 190013)
+++ gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp(working copy)
@@ -45,6 +45,12 @@ load_lib profopt.exp
 set profile_option -fprofile-generate -fripa
 set feedback_option -fprofile-use -fripa
 
+# Add -fno-section-anchors for powerpc.  Workround for Google ref b/6663281
+if {[istarget powerpc*-*-*]} {
+set profile_option $profile_option -fno-section-anchors
+set feedback_option $feedback_option -fno-section-anchors
+}
+
 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.C]] {
 # If we're only testing specific files and this isn't one of them, skip it.
 if ![runtest_file_p $runtests $src] then {

--
This patch is available for review at http://codereview.appspot.com/6443071


[RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Paolo Carlini

Hi,

thus I started analyzing why we are handling incorrectly some variants 
posted by Daniel. A typical example (another is about using the sizeof 
in a template argument) is:


class C {
typedef int type; // Line 2
};

templateclass T, class = typename T::type
auto f(int) - char;

templateclass
auto f(...) - char ()[2];

typedef int test[sizeof(fC(0)) == 2 ? 1 : -1]; // Error (line #11)

// static_assert(sizeof(fC(0)) == 2, ); // OK (line #13)

the first interesting bit of analysis I can offer is a comparison vs 
4.7. This is the error message with 4.7:


51213_3.C:11:47: error: size of array ‘test’ is negative

as you can see, nothing about access control! Thus, it seems to me, the 
issues we are having with mainline ultimately boil down to 
non-conforming/missing access control in pre-existing code. In current 
mainline, for comparison, we have:


51213_3.C:11:47: error: size of array ‘test’ is negative
typedef int test[sizeof(fC(0)) == 2 ? 1 : -1]; // Error (line #11)
^
51213_3.C:2:15: error: ‘typedef int C::type’ is private
typedef int type; // Line 2
^
51213_3.C:5:19: error: within this context
templateclass T, class = typename T::type

thus, what is happening is that we actually do access control, but too 
late, with the SFINAE already mishandled. Thus, it seems that, 
irrespective of the access control under SFINAE bits, we are making 
progress here, we actually do access control now, only, too late, 
because it should happen earlier, and fail in time for SFINAE.


In little more detail, in mainline we reach 
perform_or_defer_access_check from perform_overload_resolution, but 
ptr-deferring_access_checks_kind == dk_deferred, thus the former has no 
chances to call enforce_access and return false. I'm adding below the 
stacktrace. On the other hand, in the case which already works 
(commented out above), ptr-deferring_access_checks_kind == 
dk_no_deferred and everything is fine.


So, it looks like we are deferring an access check which shouldn't be 
deferred, at least should happen in time for SFINAE. At the moment, I 
have no idea why it is happening only for line #11 and not for line #13.


Jason, are those first bits of analysis enough for you to figure out 
what could be possibly going wrong? Or you have suggestions about the 
next steps? If on the other hand, you feel like just taking over from 
here (eg, the issue seems interesting enough ;) just let me know...


Thanks!
Paolo.

/

Breakpoint 2, perform_or_defer_access_check (binfo=0x76e664e0, 
decl=0x76e59ac8, diag_decl=0x76e59ac8, complain=8) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/semantics.c:327

(gdb) bt
#0 perform_or_defer_access_check (binfo=0x76e664e0, 
decl=0x76e59ac8, diag_decl=0x76e59ac8, complain=8) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/semantics.c:327
#1 0x0051f8bb in make_typename_type (context=0x76e5e888, 
name=0x76e6c8f0, tag_type=typename_type, complain=8) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/decl.c:3311
#2 0x005e8c6f in tsubst (t=0x76e5ebd0, args=0x76d16b10, 
complain=0, in_decl=0x0) at /scratch/Gcc/svn-dirs/trunk/gcc/cp/pt.c:11405
#3 0x005ce538 in tsubst_template_arg (t=0x76e5ebd0, 
args=0x76d16b10, complain=0, in_decl=0x0) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/pt.c:8917
#4 0x0060d472 in type_unification_real (tparms=0x76d16900, 
targs=0x76d16b10, xparms=0x76e6d370, xargs=0x7fffc060, 
xnargs=1, subr=0, strict=DEDUCE_CALL, flags=1, explain_p=0 '\000') at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/pt.c:15125
#5 0x0060af3f in fn_type_unification (fn=0x76e59e60, 
explicit_targs=0x76e6d500, targs=0x76d16b10, 
args=0x7fffc060, nargs=1, return_type=0x0, strict=DEDUCE_CALL, 
flags=1, explain_p=0 '\000') at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/pt.c:14648
#6 0x004de20a in add_template_candidate_real 
(candidates=0x7fffc590, tmpl=0x76e59e60, ctype=0x0, 
explicit_targs=0x76e6d500, first_arg=0x0, arglist=0x76e6d528, 
return_type=0x0, access_path=0x0, conversion_path=0x0, flags=1, obj=0x0, 
strict=DEDUCE_CALL, complain=3) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/call.c:2921
#7 0x004deb48 in add_template_candidate 
(candidates=0x7fffc590, tmpl=0x76e59e60, ctype=0x0, 
explicit_targs=0x76e6d500, first_arg=0x0, arglist=0x76e6d528, 
return_type=0x0, access_path=0x0, conversion_path=0x0, flags=1, 
strict=DEDUCE_CALL, complain=3) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/call.c:3024
#8 0x004e8375 in add_candidates (fns=0x76e6a640, 
first_arg=0x0, args=0x76e6d528, return_type=0x0, 
explicit_targs=0x76e6d500, template_only=1 '\001', 
conversion_path=0x0, access_path=0x0, flags=1, 
candidates=0x7fffc590, complain=3) at 
/scratch/Gcc/svn-dirs/trunk/gcc/cp/call.c:4939
#9 0x004e2702 in perform_overload_resolution (fn=0x76e6a6c0, 
args=0x76e6d528, candidates=0x7fffc590, 
any_viable_p=0x7fffc58f \001 \201\201\001, 

[PATCH][1/2] Remove referenced vars

2012-08-01 Thread Richard Guenther

This series aims at removing referenced vars.  It builds on the into-SSA
TLC series and the still to be posted removal of var-anns.

This first patch removes SRAs use of referenced vars.  Instead of
turning it upside-down the following simply adds a pass-local
referenced vars reverse lookup capability uid - decl.

This was the last user of referenced_var ().

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* tree-flow-inline.h (referenced_var): Remove.
* tree-ssa-coalesce.c (create_outofssa_var_map): Remove duplicate
checking code.
* tree-sra.c (candidates): New global hashtable.
(candidate): New function.
(sra_initialize): Initialize candidates.
(sra_deinitialize): Free candidates.
(disqualify_candidate): Remove candidate from candidates.
(find_var_candidates): Walk over all local decls, add candidates
to candidates hashtable.
(find_param_candidates): Add candidates to candidates hashtable.
(analyze_all_variable_accesses): Use candidate instead of
referenced_var.

Index: gcc/tree-flow-inline.h
===
*** gcc/tree-flow-inline.h.orig 2012-08-01 11:06:15.0 +0200
--- gcc/tree-flow-inline.h  2012-08-01 11:16:46.398132279 +0200
*** next_htab_element (htab_iterator *hti)
*** 98,113 
return NULL;
  }
  
- /* Get the variable with uid UID from the list of referenced vars.  */
- 
- static inline tree
- referenced_var (unsigned int uid)
- {
-   tree var = referenced_var_lookup (cfun, uid);
-   gcc_assert (var || uid == 0);
-   return var;
- }
- 
  /* Initialize ITER to point to the first referenced variable in the
 referenced_vars hashtable, and return that variable.  */
  
--- 98,103 
Index: gcc/tree-ssa-coalesce.c
===
*** gcc/tree-ssa-coalesce.c.orig2012-08-01 11:06:15.0 +0200
--- gcc/tree-ssa-coalesce.c 2012-08-01 11:16:46.399132279 +0200
*** create_outofssa_var_map (coalesce_list_p
*** 983,996 
int v1, v2, cost;
unsigned i;
  
- #ifdef ENABLE_CHECKING
-   bitmap used_in_real_ops;
-   bitmap used_in_virtual_ops;
- 
-   used_in_real_ops = BITMAP_ALLOC (NULL);
-   used_in_virtual_ops = BITMAP_ALLOC (NULL);
- #endif
- 
map = init_var_map (num_ssa_names);
  
FOR_EACH_BB (bb)
--- 983,988 
*** create_outofssa_var_map (coalesce_list_p
*** 1126,1142 
default:
  break;
}
- 
- #ifdef ENABLE_CHECKING
- /* Mark real uses and defs.  */
- FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE))
-   bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (var)));
- 
- /* Validate that virtual ops don't get used in funny ways.  */
- if (gimple_vuse (stmt))
-   bitmap_set_bit (used_in_virtual_ops,
-   DECL_UID (SSA_NAME_VAR (gimple_vuse (stmt;
- #endif /* ENABLE_CHECKING */
}
  }
  
--- 1118,1123 
*** create_outofssa_var_map (coalesce_list_p
*** 1173,1199 
}
  }
  
- #if defined ENABLE_CHECKING
-   {
- unsigned i;
- bitmap both = BITMAP_ALLOC (NULL);
- bitmap_and (both, used_in_real_ops, used_in_virtual_ops);
- if (!bitmap_empty_p (both))
-   {
-   bitmap_iterator bi;
- 
-   EXECUTE_IF_SET_IN_BITMAP (both, 0, i, bi)
- fprintf (stderr, Variable %s used in real and virtual operands\n,
-  get_name (referenced_var (i)));
-   internal_error (SSA corruption);
-   }
- 
- BITMAP_FREE (used_in_real_ops);
- BITMAP_FREE (used_in_virtual_ops);
- BITMAP_FREE (both);
-   }
- #endif
- 
return map;
  }
  
--- 1154,1159 
Index: gcc/tree-sra.c
===
*** gcc/tree-sra.c.orig 2012-08-01 11:16:45.0 +0200
--- gcc/tree-sra.c  2012-08-01 11:21:58.917121453 +0200
*** struct access
*** 224,232 
   BIT_FIELD_REF?  */
unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  We do
!  the decision and creation at different places because create_tmp_var
!  cannot be called from within FOR_EACH_REFERENCED_VAR. */
unsigned grp_to_be_replaced : 1;
  
/* Should TREE_NO_WARNING of a replacement be set?  */
--- 224,230 
   BIT_FIELD_REF?  */
unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  */
unsigned grp_to_be_replaced : 1;
  
/* Should TREE_NO_WARNING of a replacement be set?  */
*** static alloc_pool link_pool;
*** 269,276 
  /* Base (tree) - Vector (VEC(access_p,heap) *) map.  */
  static struct pointer_map_t *base_access_vec;
  
! /* Bitmap of candidates.  */
  

Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-08-01 Thread Mikael Morin
On 01/08/2012 12:00, Tobias Burnus wrote:
 On 07/27/2012 07:26 PM, Mikael Morin wrote:
 do you have a test case exhibiting the problem? It seems fine to me.
 
 Your second test case was too convoluted for me - and as I wasn't at
 home, I couldn't test it. I now believe that your patch is okay; I will
 later formally review  it.
I will formally ask for it. ;-)
 
 Do you intent to wrap it for final inclusion? I think it only lacks a
 dejaGNUified test case and a changelog.
Will do.
 
  * * *
 
 However, I found another spot where one needs to have a scalarizer;
 possibly a poor man's version is enough. Namely INTENT(OUT) handling.
Indeed.
 Do you have an idea how to best handle that case?
It seems some new code is necessary. I don't know how well it will
fit/reuse the existing though.

I have been thinking about rewriting the scalarizer in a way that would
need less bookkeeping to make things work. Nothing near a patch though,
and it's not something for 4.8. Anyway, here is the interface I had in mind:

gfc_init_loopinfo (loopinfo);
/* generate the code.  */
gfc_conv_expr (loopinfo, expr1);
gfc_conv_expr (loopinfo, expr2);
/* etc, do something, putting loopinfo every time as parameter so that
it is populated appropriately... and then: */
loopblock = gfc_scalarize (loopinfo);

the gfc_scalarize could have a big `if' in it distinguishing known rank
from assumed rank.
Maybe we could take the opportunity to make a seed for a new scalarizer.

Mikael


[PATCH] Update tree-ssa docs

2012-08-01 Thread Richard Guenther

Committed as obvious.

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* tree-ssa.texi: Remove pieces mentioning mark_sym_for_renaming.

Index: gcc/doc/tree-ssa.texi
===
--- gcc/doc/tree-ssa.texi   (revision 190034)
+++ gcc/doc/tree-ssa.texi   (working copy)
@@ -628,10 +628,7 @@ introduced to replace existing names in
 between the old and the new names are registered by calling
 @code{register_new_name_mapping} (note that if your pass creates new
 code by duplicating basic blocks, the call to @code{tree_duplicate_bb}
-will set up the necessary mappings automatically).  On the other hand,
-if your pass exposes a new symbol that should be put in SSA form for
-the first time, the new symbol should be registered with
-@code{mark_sym_for_renaming}.
+will set up the necessary mappings automatically).
 
 After the replacement mappings have been registered and new symbols
 marked for renaming, a call to @code{update_ssa} makes the registered


[PATCH][2a/2] Remove referenced vars

2012-08-01 Thread Richard Guenther

This is part one of the patch (and thus single commit) that will
remove referenced vars once we got rid of var annotations.
It removes referenced_var_lookup and all callers - which shows
you where dumping will be affected.

Bootstrap  regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* tree-dfa.c (referenced_var_lookup): Remove.
* tree-flow.h (referenced_var_lookup): Likewise.
* cfgexpand.c (update_alias_info_with_stack_vars): Remove assert.
* gimple-pretty-print.c (pp_points_to_solution): Dump UIDs
unconditionally.
* tree-into-ssa.c (dump_decl_set): Likewise.
* tree-ssa.c (target_for_debug_bind): Virtual operands are
not suitable, but all register type vars are.

Index: trunk/gcc/cfgexpand.c
===
*** trunk.orig/gcc/cfgexpand.c  2012-07-20 12:11:05.0 +0200
--- trunk/gcc/cfgexpand.c   2012-08-01 11:46:40.447070164 +0200
*** update_alias_info_with_stack_vars (void)
*** 620,632 
{
  tree decl = stack_vars[j].decl;
  unsigned int uid = DECL_PT_UID (decl);
- /* We should never end up partitioning SSA names (though they
-may end up on the stack).  Neither should we allocate stack
-space to something that is unused and thus unreferenced, except
-for -O0 where we are preserving even unreferenced variables.  */
- gcc_assert (DECL_P (decl)
-  (!optimize
- || referenced_var_lookup (cfun, DECL_UID (decl;
  bitmap_set_bit (part, uid);
  *((bitmap *) pointer_map_insert (decls_to_partitions,
   (void *)(size_t) uid)) = part;
--- 620,625 
Index: trunk/gcc/gimple-pretty-print.c
===
*** trunk.orig/gcc/gimple-pretty-print.c2012-07-26 10:46:42.0 
+0200
--- trunk/gcc/gimple-pretty-print.c 2012-08-01 11:49:41.513063937 +0200
*** pp_points_to_solution (pretty_printer *b
*** 597,617 
pp_string (buffer, { );
EXECUTE_IF_SET_IN_BITMAP (pt-vars, 0, i, bi)
{
! tree var = referenced_var_lookup (cfun, i);
! if (var)
!   {
! dump_generic_node (buffer, var, 0, dump_flags, false);
! if (DECL_PT_UID (var) != DECL_UID (var))
!   {
! pp_string (buffer, ptD.);
! pp_decimal_int (buffer, DECL_PT_UID (var));
!   }
!   }
! else
!   {
! pp_string (buffer, D.);
! pp_decimal_int (buffer, i);
!   }
  pp_character (buffer, ' ');
}
pp_character (buffer, '}');
--- 597,604 
pp_string (buffer, { );
EXECUTE_IF_SET_IN_BITMAP (pt-vars, 0, i, bi)
{
! pp_string (buffer, D.);
! pp_decimal_int (buffer, i);
  pp_character (buffer, ' ');
}
pp_character (buffer, '}');
Index: trunk/gcc/tree-dfa.c
===
*** trunk.orig/gcc/tree-dfa.c   2012-08-01 11:16:45.0 +0200
--- trunk/gcc/tree-dfa.c2012-08-01 11:49:57.773063325 +0200
*** find_referenced_vars_in (gimple stmt)
*** 430,448 
  }
  
  
- /* Lookup UID in the referenced_vars hashtable and return the associated
-variable.  */
- 
- tree
- referenced_var_lookup (struct function *fn, unsigned int uid)
- {
-   tree h;
-   struct tree_decl_minimal in;
-   in.uid = uid;
-   h = (tree) htab_find_with_hash (gimple_referenced_vars (fn), in, uid);
-   return h;
- }
- 
  /* Check if TO is in the referenced_vars hash table and insert it if not.
 Return true if it required insertion.  */
  
--- 430,435 
Index: trunk/gcc/tree-flow.h
===
*** trunk.orig/gcc/tree-flow.h  2012-08-01 11:16:45.0 +0200
--- trunk/gcc/tree-flow.h   2012-08-01 12:02:27.703037366 +0200
*** typedef struct
*** 323,329 
 !end_referenced_vars_p ((ITER));  \
 (VAR) = next_referenced_var ((ITER)))
  
- extern tree referenced_var_lookup (struct function *, unsigned int);
  #define num_referenced_vars htab_elements (gimple_referenced_vars (cfun))
  
  #define num_ssa_names (VEC_length (tree, cfun-gimple_df-ssa_names))
--- 323,328 
Index: trunk/gcc/tree-into-ssa.c
===
*** trunk.orig/gcc/tree-into-ssa.c  2012-08-01 11:16:45.0 +0200
--- trunk/gcc/tree-into-ssa.c   2012-08-01 11:50:17.248062660 +0200
*** dump_decl_set (FILE *file, bitmap set)
*** 1554,1564 
  
EXECUTE_IF_SET_IN_BITMAP (set, 0, i, bi)
{
! tree var = referenced_var_lookup (cfun, i);
! if (var)
!   

[PATCH, i386]: Prevent SImode subregs of stack pointer in addresses

2012-08-01 Thread Uros Bizjak
Hello!

For some reason simplify_subreg does not like stack pointer. We call
simplify_subreg when printing address operands, so we have to prevent
SImode subregs of stack pointers from going into the address.

2012-08-01  Uros Bizjak  ubiz...@gmail.com

* config/i386/i386.c (ix86_address_subreg_operand): Reject
stack pointer.
(ix86_print_operand_address): Assert that parts.base and parts.index
are non-NULL after call to simplify_subreg.

Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN.
The patch will be backported to 4.7 branch.

Uros.
Index: i386.c
===
--- i386.c  (revision 190005)
+++ i386.c  (working copy)
@@ -11657,6 +11657,10 @@ ix86_address_subreg_operand (rtx op)
   if (GET_MODE_SIZE (mode)  UNITS_PER_WORD)
 return false;
 
+  /* simplify_subreg does not handle stack pointer.  */
+  if (REGNO (op) == STACK_POINTER_REGNUM)
+return false;
+
   /* Allow only SUBREGs of non-eliminable hard registers.  */
   return register_no_elim_operand (op, mode);
 }
@@ -14823,6 +14827,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
   rtx tmp = SUBREG_REG (parts.base);
   parts.base = simplify_subreg (GET_MODE (parts.base),
tmp, GET_MODE (tmp), 0);
+  gcc_assert (parts.base != NULL_RTX);
 }
 
   if (parts.index  GET_CODE (parts.index) == SUBREG)
@@ -14830,6 +14835,7 @@ ix86_print_operand_address (FILE *file, rtx addr)
   rtx tmp = SUBREG_REG (parts.index);
   parts.index = simplify_subreg (GET_MODE (parts.index),
 tmp, GET_MODE (tmp), 0);
+  gcc_assert (parts.index != NULL_RTX);
 }
 
   base = parts.base;


[PATCH][2b/2] Remove referenced vars

2012-08-01 Thread Richard Guenther

This removes the referenced vars machinery (stubbing out
add_referenced_vars and gimple_referenced_vars - a patch fixing
all callers will be 2c/2).

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

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* tree-flow.h (struct gimple_df): Remove referenced_vars member.
(typedef referenced_var_iterator): Remove.
(FOR_EACH_REFERENCED_VAR): Likewise.
(num_referenced_vars): Likewise.
(debug_referenced_vars, dump_referenced_vars): Likewise.
(add_referenced_var_1, add_referenced_var): Likewise.
(remove_referenced_var): Likewise.
(find_referenced_vars_in): Likewise.
* tree-dfa.c (find_referenced_vars): Remove.
(pass_referenced_vars): Likewise.
(make_rename_temp): Do not add referenced vars.
(dump_referenced_vars): Remove.
(debug_referenced_vars): Likewise.
(dump_dfa_stats): Do not dump referenced var stats.
(find_vars_r): Remove.
(find_referenced_vars_in): Likewise.
(referenced_var_check_and_insert): Likewise.
(add_referenced_var_1): Likewise.
(remove_referenced_var): Likewise.
* tree-flow-inline.h (gimple_referenced_vars): Remove.
(first_referenced_var): Likewise.
(end_referenced_vars_p): Likewise.
(next_referenced_var): Likewise.
* tree-inline.c (copy_bb): Do not add referenced vars.
* tree-into-ssa.c (pass_build_ssa): Do not require PROP_referenced_vars.
* tree-pass.h (PROP_referenced_vars): Remove.
(pass_referenced_vars): Likewise.
* tree-profile.c (gimple_gen_edge_profiler): Do not add referenced vars.
(gimple_gen_interval_profiler): Likewise.
(gimple_gen_pow2_profiler): Likewise.
(gimple_gen_one_value_profiler): Likewise.
(gimple_gen_ic_profiler): Likewise.
(gimple_gen_average_profiler): Likewise.
(gimple_gen_ior_profiler): Likewise.
* tree-ssa-live.c (remove_unused_locals): Do not touch referenced vars.
* tree-ssa.c (init_tree_ssa): Do not allocate referenced vars.
(delete_tree_ssa): Do not free referenced vars.
* tree-cfg.c (move_stmt_op): Do not add referenced vars.
* tree-ssa-operands.c (create_vop_var): Likewise.

Index: trunk/gcc/cgraphunit.c
===
*** trunk.orig/gcc/cgraphunit.c 2012-08-01 12:38:31.0 +0200
--- trunk/gcc/cgraphunit.c  2012-08-01 12:38:40.619962135 +0200
*** init_lowered_empty_function (tree decl)
*** 1228,1235 
  
DECL_SAVED_TREE (decl) = error_mark_node;
cfun-curr_properties |=
! (PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_referenced_vars |
!  PROP_ssa | PROP_gimple_any);
  
/* Create BB for body of the function and connect it properly.  */
bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR);
--- 1228,1234 
  
DECL_SAVED_TREE (decl) = error_mark_node;
cfun-curr_properties |=
! (PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg | PROP_ssa | 
PROP_gimple_any);
  
/* Create BB for body of the function and connect it properly.  */
bb = create_basic_block (NULL, (void *) 0, ENTRY_BLOCK_PTR);
Index: trunk/gcc/gimple-fold.c
===
*** trunk.orig/gcc/gimple-fold.c2012-08-01 12:37:57.0 +0200
--- trunk/gcc/gimple-fold.c 2012-08-01 12:38:40.620962135 +0200
*** gimplify_and_update_call_from_tree (gimp
*** 653,661 
for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (i))
  {
new_stmt = gsi_stmt (i);
-   /* The replacement can expose previously unreferenced variables.  */
-   if (gimple_in_ssa_p (cfun))
-   find_referenced_vars_in (new_stmt);
/* If the new statement possibly has a VUSE, update it with exact SSA
 name we know will reach this one.  */
if (gimple_has_mem_ops (new_stmt))
--- 653,658 
Index: trunk/gcc/gimple-streamer-in.c
===
*** trunk.orig/gcc/gimple-streamer-in.c 2012-08-01 12:37:57.0 +0200
--- trunk/gcc/gimple-streamer-in.c  2012-08-01 12:38:40.621962134 +0200
*** input_bb (struct lto_input_block *ib, en
*** 310,317 
while (tag)
  {
gimple stmt = input_gimple_stmt (ib, data_in, fn, tag);
-   if (!is_gimple_debug (stmt))
-   find_referenced_vars_in (stmt);
gsi_insert_after (bsi, stmt, GSI_NEW_STMT);
  
/* After the statement, expect a 0 delimiter or the EH region
--- 310,315 
*** input_bb (struct lto_input_block *ib, en
*** 332,339 
tag = streamer_read_record_start (ib);
while (tag)
  {
!   gimple phi = input_phi (ib, bb, data_in, fn);
!   find_referenced_vars_in (phi);
tag = streamer_read_record_start (ib);
  }
  }
--- 330,336 
   

Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-08-01 Thread Tobias Burnus

On 08/01/2012 01:37 PM, Mikael Morin wrote:

However, I found another spot where one needs to have a scalarizer;
possibly a poor man's version is enough. Namely INTENT(OUT) handling.

Indeed.

Do you have an idea how to best handle that case?

It seems some new code is necessary. I don't know how well it will
fit/reuse the existing though.


I think we should try to get this working in some way for 4.8 as 
assumed-rank arrays will be used for the finalization wrapper - and it 
would be awesome to have FINAL support in 4.8.


Background: As it is unknown (at compile time) whether a polymorphic 
variable has no final subroutines or one for that rank or an elemental 
one (or some but no suitable ones) - and as there could be a different 
combination for the parent type, the current plan is to add a _final 
proc-pointer to the vtable, which points to a final wrapper procedure 
for that type. It takes (at least for arrays) an assumed-rank array and 
dispatches the calls based on the rank; for an elemental final 
subroutine, it has to scalarize it. [It's simple to add a special case 
as the array is contiguous - one just needs to call 
elemental(base_address + i*elem_size), where i = 
1,size(assumed-size-array).]


And for finalization, it would be great if one could use the INTENT(OUT) 
support. One could alternatively implement it manually on the gfortran 
AST level (gfc_code/gfc_expr) by walking through the derived type or one 
could implement a simplified version, making use of the contiguity of 
the finalized variable.




I have been thinking about rewriting the scalarizer in a way that would
need less bookkeeping to make things work. Nothing near a patch though,
and it's not something for 4.8.


I think it would be good to base it on the new array descriptor, which 
we hopefully have by that time. Additionally, we should consider to support:


a) ARRAY_RANGE_REF: That's probably somewhat independent of 
scalarization, but replaces it in some cases:

  A(:,:,5) = B(:)
can be implemented as ARRAY_RANGE_REF, if the memory is contiguous; one 
just passes an offset and (via the decl) the size of the array 
(section). See trans-expr.c for one example. A range ref is better than 
a memcpy/memmove or a loop - as the first looses the data type and some 
alias information and the second represents the structure in a more 
convoluted way. Either could be recovered by the middle end, but it 
currently isn't and doing it correctly from the beginning makes the ME 
life easier.


b) Middle-end arrays. Richard made an initial patch, cf. 
http://gcc.gnu.org/wiki/GCCGathering2011Fortran . It probably needs some 
polishing and some optimizations have to be implemented, but then it 
should work and allow for further optimizations. [Description in the 
wiki might be partially wrong; blame me - and correct it, if you find 
something.]


I think the latter requires also some thinking about how to handle 
arrays internally: In that case, the array has - at least for the 
scalarization - more than one rank (for the ME) while gfortran normally 
folds everything to rank-1 arrays. Additionally, one needs to think 
about the case where the array has nonunit strides, i.e. where the 
leftmost stride is not sizeof(declared type) but larger by a noninteger 
amount. (e.g. passing a polymorphic array to a TYPE.)


Tobias


Re: Ping: [PATCH] Fix PR46556 (straight-line strength reduction, part 2)

2012-08-01 Thread Richard Guenther
On Sun, Jul 22, 2012 at 5:19 PM, William J. Schmidt
wschm...@linux.vnet.ibm.com wrote:
 Ping...

 On Thu, 2012-06-28 at 16:45 -0500, William J. Schmidt wrote:
 Here's a relatively small piece of strength reduction that solves that
 pesky addressing bug that got me looking at this in the first place...

 The main part of the code is the stuff that was reviewed last year, but
 which needed to find a good home.  So hopefully that's in pretty good
 shape.  I recast base_cand_map as an htab again since I now need to look
 up trees other than SSA names.  I plan to put together a follow-up patch
 to change code and commentary references so that base_name becomes
 base_expr.  Doing that now would clutter up the patch too much.

 Bootstrapped and tested on powerpc64-linux-gnu with no new regressions.
 Ok for trunk?

Ok.

Thanks,
Richard.

 Thanks,
 Bill


 gcc:

   PR tree-optimization/46556
   * gimple-ssa-strength-reduction.c (enum cand_kind): Add CAND_REF.
   (base_cand_map): Change to hash table.
   (base_cand_hash): New function.
   (base_cand_free): Likewise.
   (base_cand_eq): Likewise.
   (lookup_cand): Change base_cand_map to hash table.
   (find_basis_for_candidate): Likewise.
   (base_cand_from_table): Exclude CAND_REF.
   (restructure_reference): New function.
   (slsr_process_ref): Likewise.
   (find_candidates_in_block): Call slsr_process_ref.
   (dump_candidate): Handle CAND_REF.
   (base_cand_dump_callback): New function.
   (dump_cand_chains): Change base_cand_map to hash table.
   (replace_ref): New function.
   (replace_refs): Likewise.
   (analyze_candidates_and_replace): Call replace_refs.
   (execute_strength_reduction): Change base_cand_map to hash table.

 gcc/testsuite:

   PR tree-optimization/46556
   * testsuite/gcc.dg/tree-ssa/slsr-27.c: New.
   * testsuite/gcc.dg/tree-ssa/slsr-28.c: New.
   * testsuite/gcc.dg/tree-ssa/slsr-29.c: New.


 Index: gcc/testsuite/gcc.dg/tree-ssa/slsr-27.c
 ===
 --- gcc/testsuite/gcc.dg/tree-ssa/slsr-27.c   (revision 0)
 +++ gcc/testsuite/gcc.dg/tree-ssa/slsr-27.c   (revision 0)
 @@ -0,0 +1,22 @@
 +/* { dg-do compile } */
 +/* { dg-options -O2 -fdump-tree-dom2 } */
 +
 +struct x
 +{
 +  int a[16];
 +  int b[16];
 +  int c[16];
 +};
 +
 +extern void foo (int, int, int);
 +
 +void
 +f (struct x *p, unsigned int n)
 +{
 +  foo (p-a[n], p-c[n], p-b[n]);
 +}
 +
 +/* { dg-final { scan-tree-dump-times \\* 4; 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times p_\\d\+\\(D\\) \\+ D 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times MEM\\\[\\(struct x \\*\\)D 3 dom2 
 } } */
 +/* { dg-final { cleanup-tree-dump dom2 } } */
 Index: gcc/testsuite/gcc.dg/tree-ssa/slsr-28.c
 ===
 --- gcc/testsuite/gcc.dg/tree-ssa/slsr-28.c   (revision 0)
 +++ gcc/testsuite/gcc.dg/tree-ssa/slsr-28.c   (revision 0)
 @@ -0,0 +1,26 @@
 +/* { dg-do compile } */
 +/* { dg-options -O2 -fdump-tree-dom2 } */
 +
 +struct x
 +{
 +  int a[16];
 +  int b[16];
 +  int c[16];
 +};
 +
 +extern void foo (int, int, int);
 +
 +void
 +f (struct x *p, unsigned int n)
 +{
 +  foo (p-a[n], p-c[n], p-b[n]);
 +  if (n  12)
 +foo (p-a[n], p-c[n], p-b[n]);
 +  else if (n  3)
 +foo (p-b[n], p-a[n], p-c[n]);
 +}
 +
 +/* { dg-final { scan-tree-dump-times \\* 4; 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times p_\\d\+\\(D\\) \\+ D 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times MEM\\\[\\(struct x \\*\\)D 9 dom2 
 } } */
 +/* { dg-final { cleanup-tree-dump dom2 } } */
 Index: gcc/testsuite/gcc.dg/tree-ssa/slsr-29.c
 ===
 --- gcc/testsuite/gcc.dg/tree-ssa/slsr-29.c   (revision 0)
 +++ gcc/testsuite/gcc.dg/tree-ssa/slsr-29.c   (revision 0)
 @@ -0,0 +1,28 @@
 +/* { dg-do compile } */
 +/* { dg-options -O2 -fdump-tree-dom2 } */
 +
 +struct x
 +{
 +  int a[16];
 +  int b[16];
 +  int c[16];
 +};
 +
 +extern void foo (int, int, int);
 +
 +void
 +f (struct x *p, unsigned int n)
 +{
 +  foo (p-a[n], p-c[n], p-b[n]);
 +  if (n  3)
 +{
 +  foo (p-a[n], p-c[n], p-b[n]);
 +  if (n  12)
 + foo (p-b[n], p-a[n], p-c[n]);
 +}
 +}
 +
 +/* { dg-final { scan-tree-dump-times \\* 4; 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times p_\\d\+\\(D\\) \\+ D 1 dom2 } } */
 +/* { dg-final { scan-tree-dump-times MEM\\\[\\(struct x \\*\\)D 9 dom2 
 } } */
 +/* { dg-final { cleanup-tree-dump dom2 } } */
 Index: gcc/gimple-ssa-strength-reduction.c
 ===
 --- gcc/gimple-ssa-strength-reduction.c   (revision 189025)
 +++ gcc/gimple-ssa-strength-reduction.c   (working copy)
 @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 2) Explicit multiplies, unknown constant multipliers,
no conditional increments. (data gathering complete,
  

Re: [PATCH] propagate anti-range to switch in tree-vrp

2012-08-01 Thread Richard Guenther
On Sat, Jul 21, 2012 at 3:57 PM, Tom de Vries tom_devr...@mentor.com wrote:
 Jakub,

 this patch adds propagation of anti-ranges to switches.

 The test-case is this:
 ...
 void
 f3 (int s)
 {
   if (s  3 == -2)
 /* s in range [ -16, -9].  */
 ;
   else
 {
   /* s in range ~[-16, -9], so none of the case labels can be taken.  */
   switch (s)
 {
 case -16:
 case -12:
 case -9:
   link_error ();
   break;
 default:
   break;
 }
 }
 }
 ...

 The call to link_error is unreachable but tree-vrp fails to analyze that.

 Using the patch, the switch is replaced by the default case.

 Bootstrapped and reg-tested (Ada inclusive) on x86_64.

 OK for trunk?

Ok.

Thanks,
Richard.

 Thanks,
 - Tom

 2012-07-21  Tom de Vries  t...@codesourcery.com

 * tree-vrp.c (find_case_label_ranges): New function.
 (vrp_visit_switch_stmt, simplify_switch_using_ranges): Use
 find_case_label_ranges instead of find_case_label_range.  Handle 
 second
 range.

 * gcc.dg/tree-ssa/vrp72.c: New test.


Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs

2012-08-01 Thread Richard Guenther
On Wed, Aug 1, 2012 at 2:37 PM, Tobias Burnus bur...@net-b.de wrote:
 On 08/01/2012 01:37 PM, Mikael Morin wrote:

 However, I found another spot where one needs to have a scalarizer;
 possibly a poor man's version is enough. Namely INTENT(OUT) handling.

 Indeed.

 Do you have an idea how to best handle that case?

 It seems some new code is necessary. I don't know how well it will
 fit/reuse the existing though.


 I think we should try to get this working in some way for 4.8 as
 assumed-rank arrays will be used for the finalization wrapper - and it would
 be awesome to have FINAL support in 4.8.

 Background: As it is unknown (at compile time) whether a polymorphic
 variable has no final subroutines or one for that rank or an elemental one
 (or some but no suitable ones) - and as there could be a different
 combination for the parent type, the current plan is to add a _final
 proc-pointer to the vtable, which points to a final wrapper procedure for
 that type. It takes (at least for arrays) an assumed-rank array and
 dispatches the calls based on the rank; for an elemental final subroutine,
 it has to scalarize it. [It's simple to add a special case as the array is
 contiguous - one just needs to call elemental(base_address + i*elem_size),
 where i = 1,size(assumed-size-array).]

 And for finalization, it would be great if one could use the INTENT(OUT)
 support. One could alternatively implement it manually on the gfortran AST
 level (gfc_code/gfc_expr) by walking through the derived type or one could
 implement a simplified version, making use of the contiguity of the
 finalized variable.



 I have been thinking about rewriting the scalarizer in a way that would
 need less bookkeeping to make things work. Nothing near a patch though,
 and it's not something for 4.8.


 I think it would be good to base it on the new array descriptor, which we
 hopefully have by that time. Additionally, we should consider to support:

 a) ARRAY_RANGE_REF: That's probably somewhat independent of scalarization,
 but replaces it in some cases:
   A(:,:,5) = B(:)
 can be implemented as ARRAY_RANGE_REF, if the memory is contiguous; one just
 passes an offset and (via the decl) the size of the array (section). See
 trans-expr.c for one example. A range ref is better than a memcpy/memmove or
 a loop - as the first looses the data type and some alias information and
 the second represents the structure in a more convoluted way. Either could
 be recovered by the middle end, but it currently isn't and doing it
 correctly from the beginning makes the ME life easier.

 b) Middle-end arrays. Richard made an initial patch, cf.
 http://gcc.gnu.org/wiki/GCCGathering2011Fortran . It probably needs some
 polishing and some optimizations have to be implemented, but then it should
 work and allow for further optimizations. [Description in the wiki might be
 partially wrong; blame me - and correct it, if you find something.]

Well, I wouldn't concentrate on this one ;)

 I think the latter requires also some thinking about how to handle arrays
 internally: In that case, the array has - at least for the scalarization -
 more than one rank (for the ME) while gfortran normally folds everything to
 rank-1 arrays. Additionally, one needs to think about the case where the
 array has nonunit strides, i.e. where the leftmost stride is not
 sizeof(declared type) but larger by a noninteger amount. (e.g. passing a
 polymorphic array to a TYPE.)

c) Do _not_ fold everything to rank-1 arrays (this makes data
dependence analysis
harder).  If you know the rank of an array use an intermediate array
pointer type
to access the data, like the following C example:

void foo (void *data, int n, int m)
{
  int (*a)[n][m] = (int (*)[n][m]) data;
  int i, j;
  for (i = 0; i  n; ++i)
for (j = 0; j  m; ++j)
  (*a)[i][j] = 0;
}


d) Think about Frontend optimizations again - using the ISL part of GRAPHITE
on the GFortran IL, possibly driving the scalarizer with the result.

Richard.

 Tobias


Re: [google/main] Add -fno-section-anchors for powerpc, workround for Google ref b/6663281 (issue6443071)

2012-08-01 Thread Diego Novillo

On 12-08-01 03:49 , Simon Baldwin wrote:

Workround for Google ref b/6663281

Appends -fno-section-anchors to -fprofile-{generate,use} -fripa, for powerpc
targets only.  No-op for other targets.

For google/main.  Tested for bootstrap and regression.

2012-08-01  Simon Baldwin  sim...@google.com

* gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp: Append
-fno-section-anchors to profile_option and feedback_option for
powerpc targets.  Workround for Google ref b/6663281.
* gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp: Likewise


OK.


Diego.


Re: PING [PATCH] Fix PR libstdc++/54036, problem negating DFP NaNs

2012-08-01 Thread Jason Merrill

On 07/31/2012 06:46 PM, Peter Bergner wrote:

I'd like to ping the following libstdc++ DFP patch that fixes PR54036:

   http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00959.html


I don't normally review library patches; I've added Benjamin to CC, as 
he's one of the library maintainers.


Jason




[PATCH, committed] Strength reduction clean-up (base name = base expr)

2012-08-01 Thread William J. Schmidt
This cleans up terminology in strength reduction.  What used to be a
base SSA name is now sometimes other tree expressions, so the term base
name is replaced by base expression throughout.

Bootstrapped and tested with no new regressions on
powerpc64-unknown-linux-gnu; committed as obvious.

Thanks,
Bill


2012-08-01  Bill Schmidt  wschm...@linux.ibm.com

* gimple-ssa-strength-reduction.c (struct slsr_cand_d): Change
base_name to base_expr.
(struct cand_chain_d): Likewise.
(base_cand_hash): Likewise.
(base_cand_eq): Likewise.
(record_potential_basis): Likewise.
(alloc_cand_and_find_basis): Likewise.
(create_mul_ssa_cand): Likewise.
(create_mul_imm_cand): Likewise.
(create_add_ssa_cand): Likewise.
(create_add_imm_cand): Likewise.
(slsr_process_cast): Likewise.
(slsr_process_copy): Likewise.
(dump_candidate): Likewise.
(base_cand_dump_callback): Likewise.
(unconditional_cands_with_known_stride_p): Likewise.
(cand_increment): Likewise.


Index: gcc/gimple-ssa-strength-reduction.c
===
--- gcc/gimple-ssa-strength-reduction.c (revision 190037)
+++ gcc/gimple-ssa-strength-reduction.c (working copy)
@@ -166,8 +166,8 @@ struct slsr_cand_d
   /* The candidate statement S1.  */
   gimple cand_stmt;
 
-  /* The base SSA name B.  */
-  tree base_name;
+  /* The base expression B:  often an SSA name, but not always.  */
+  tree base_expr;
 
   /* The stride S.  */
   tree stride;
@@ -175,7 +175,7 @@ struct slsr_cand_d
   /* The index constant i.  */
   double_int index;
 
-  /* The type of the candidate.  This is normally the type of base_name,
+  /* The type of the candidate.  This is normally the type of base_expr,
  but casts may have occurred when combining feeding instructions.
  A candidate can only be a basis for candidates of the same final type.
  (For CAND_REFs, this is the type to be used for operand 1 of the
@@ -216,12 +216,13 @@ typedef struct slsr_cand_d slsr_cand, *slsr_cand_t
 typedef const struct slsr_cand_d *const_slsr_cand_t;
 
 /* Pointers to candidates are chained together as part of a mapping
-   from SSA names to the candidates that use them as a base name.  */
+   from base expressions to the candidates that use them.  */
 
 struct cand_chain_d
 {
-  /* SSA name that serves as a base name for the chain of candidates.  */
-  tree base_name;
+  /* Base expression for the chain of candidates:  often, but not
+ always, an SSA name.  */
+  tree base_expr;
 
   /* Pointer to a candidate.  */
   slsr_cand_t cand;
@@ -253,7 +254,7 @@ static struct pointer_map_t *stmt_cand_map;
 /* Obstack for candidates.  */
 static struct obstack cand_obstack;
 
-/* Hash table embodying a mapping from base names to chains of candidates.  */
+/* Hash table embodying a mapping from base exprs to chains of candidates.  */
 static htab_t base_cand_map;
 
 /* Obstack for candidate chains.  */
@@ -272,7 +273,7 @@ lookup_cand (cand_idx idx)
 static hashval_t
 base_cand_hash (const void *p)
 {
-  tree base_expr = ((const_cand_chain_t) p)-base_name;
+  tree base_expr = ((const_cand_chain_t) p)-base_expr;
   return iterative_hash_expr (base_expr, 0);
 }
 
@@ -291,10 +292,10 @@ base_cand_eq (const void *p1, const void *p2)
 {
   const_cand_chain_t const chain1 = (const_cand_chain_t) p1;
   const_cand_chain_t const chain2 = (const_cand_chain_t) p2;
-  return operand_equal_p (chain1-base_name, chain2-base_name, 0);
+  return operand_equal_p (chain1-base_expr, chain2-base_expr, 0);
 }
 
-/* Use the base name from candidate C to look for possible candidates
+/* Use the base expr from candidate C to look for possible candidates
that can serve as a basis for C.  Each potential basis must also
appear in a block that dominates the candidate statement and have
the same stride and type.  If more than one possible basis exists,
@@ -308,7 +309,7 @@ find_basis_for_candidate (slsr_cand_t c)
   cand_chain_t chain;
   slsr_cand_t basis = NULL;
 
-  mapping_key.base_name = c-base_name;
+  mapping_key.base_expr = c-base_expr;
   chain = (cand_chain_t) htab_find (base_cand_map, mapping_key);
 
   for (; chain; chain = chain-next)
@@ -337,8 +338,8 @@ find_basis_for_candidate (slsr_cand_t c)
   return 0;
 }
 
-/* Record a mapping from the base name of C to C itself, indicating that
-   C may potentially serve as a basis using that base name.  */
+/* Record a mapping from the base expression of C to C itself, indicating that
+   C may potentially serve as a basis using that base expression.  */
 
 static void
 record_potential_basis (slsr_cand_t c)
@@ -347,7 +348,7 @@ record_potential_basis (slsr_cand_t c)
   void **slot;
 
   node = (cand_chain_t) obstack_alloc (chain_obstack, sizeof (cand_chain));
-  node-base_name = c-base_name;
+  node-base_expr = c-base_expr;
   node-cand = c;
   node-next = NULL;
   slot = htab_find_slot 

Re: PR53914, rs6000 constraints and reload queries

2012-08-01 Thread Alan Modra
Hi David,
This is the last of my vendetta against the o constraint in the
rs6000 backend.  Remaining are a few places in rs6000.md where the
operand predicate is offsettable_mem_operand, and one instance in
spe.md.  I believe none of these can run into mode_dependent_address
causing insn does not statisfy its constraints.  Also, with Y
replacing o everywhere a 64-bit gpr is loaded or stored, we can
remove the +0 wrapper you added for pr13674.

I also add some testcases with this patch.  dfmode_off and tfmode_off
will fail on e500, but the generated code at -O2 is so awful that I'm
inclined to think it should remain that way until someone fixes it!

Bootstrapped and regression tested powerpc64-linux.  OK to apply?

gcc/
* config/rs6000/rs6000.c (legitimize_reload_address): Remove code
handling non-aligned ld/std.
* config/rs6000/paired.md (movv2sf_paired): Use 'Y' instead of 'o'.
* config/rs6000/vsx.md (vsx_mov, vsx_movti): Likewise.
* config/rs6000/altivec.md (altivec_mov, altivec_movti): Likewise.
* config/rs6000/dfp.md (movtd_internal): Use 'm' instead of 'o'.
gcc/testsuite/
* gcc.target/powerpc/dimode_off.c: New.
* gcc.target/powerpc/timode_off.c: New.
* gcc.target/powerpc/dfmode_off.c: New.
* gcc.target/powerpc/tfmode_off.c: New.

Index: gcc/testsuite/gcc.target/powerpc/dimode_off.c
===
--- gcc/testsuite/gcc.target/powerpc/dimode_off.c   (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/dimode_off.c   (revision 0)
@@ -0,0 +1,50 @@
+/* { dg-do assemble } */
+/* { dg-options -O2 -fno-align-functions -mtraceback=no -save-temps } */
+
+void w1 (void *x, long long y) { *(long long *) (x + 32767) = y; }
+void w2 (void *x, long long y) { *(long long *) (x + 32766) = y; }
+void w3 (void *x, long long y) { *(long long *) (x + 32765) = y; }
+void w4 (void *x, long long y) { *(long long *) (x + 32764) = y; }
+void w5 (void *x, long long y) { *(long long *) (x + 32763) = y; }
+void w6 (void *x, long long y) { *(long long *) (x + 32762) = y; }
+void w7 (void *x, long long y) { *(long long *) (x + 32761) = y; }
+void w8 (void *x, long long y) { *(long long *) (x + 32760) = y; }
+void w9 (void *x, long long y) { *(long long *) (x + 32759) = y; }
+void w10 (void *x, long long y) { *(long long *) (x + 32758) = y; }
+void w11 (void *x, long long y) { *(long long *) (x + 32757) = y; }
+void w12 (void *x, long long y) { *(long long *) (x + 32756) = y; }
+void w13 (void *x, long long y) { *(long long *) (x + 32755) = y; }
+void w14 (void *x, long long y) { *(long long *) (x + 32754) = y; }
+void w15 (void *x, long long y) { *(long long *) (x + 32753) = y; }
+void w16 (void *x, long long y) { *(long long *) (x + 32752) = y; }
+void w17 (void *x, long long y) { *(long long *) (x + 32751) = y; }
+void w18 (void *x, long long y) { *(long long *) (x + 32750) = y; }
+void w19 (void *x, long long y) { *(long long *) (x + 32749) = y; }
+void w20 (void *x, long long y) { *(long long *) (x + 32748) = y; }
+
+long long r1 (void *x) { return *(long long *) (x + 32767); }
+long long r2 (void *x) { return *(long long *) (x + 32766); }
+long long r3 (void *x) { return *(long long *) (x + 32765); }
+long long r4 (void *x) { return *(long long *) (x + 32764); }
+long long r5 (void *x) { return *(long long *) (x + 32763); }
+long long r6 (void *x) { return *(long long *) (x + 32762); }
+long long r7 (void *x) { return *(long long *) (x + 32761); }
+long long r8 (void *x) { return *(long long *) (x + 32760); }
+long long r9 (void *x) { return *(long long *) (x + 32759); }
+long long r10 (void *x) { return *(long long *) (x + 32758); }
+long long r11 (void *x) { return *(long long *) (x + 32757); }
+long long r12 (void *x) { return *(long long *) (x + 32756); }
+long long r13 (void *x) { return *(long long *) (x + 32755); }
+long long r14 (void *x) { return *(long long *) (x + 32754); }
+long long r15 (void *x) { return *(long long *) (x + 32753); }
+long long r16 (void *x) { return *(long long *) (x + 32752); }
+long long r17 (void *x) { return *(long long *) (x + 32751); }
+long long r18 (void *x) { return *(long long *) (x + 32750); }
+long long r19 (void *x) { return *(long long *) (x + 32749); }
+long long r20 (void *x) { return *(long long *) (x + 32748); }
+
+/* { dg-final { object-size text == 440 { target { lp64 } } } } */
+/* 32-bit test should really be == 512 bytes, see pr54110 */
+/* { dg-final { object-size text = 640 { target { ilp32 } } } } */
+/* { dg-final { scan-assembler-not (st|l)fd } } */
+/* { dg-final { cleanup-saved-temps dimode_off } } */
Index: gcc/testsuite/gcc.target/powerpc/timode_off.c
===
--- gcc/testsuite/gcc.target/powerpc/timode_off.c   (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/timode_off.c   (revision 0)
@@ -0,0 +1,51 @@
+/* { dg-do assemble { target { lp64 } } } */
+/* { 

[1/3] remove var_ann: tlc for out-of-ssa

2012-08-01 Thread Michael Matz
Hi,

this tidies ssa liveness calculation a bit (related to out-of-ssa).  In 
particular it doesn't make use of var annotations to compress the index 
space from partitions to base variable indices anymore, but instead a 
hashmap built on the fly when we need it.  The basevars itself actually 
aren't needed at all (currently only for checking), only a mapping for 
which ssa names belong to the same base variable.

Regstrapped with the other two patches on x86_64-linux.  Okay for trunk?


Ciao,
Michael.
* tree-flow.h (struct var_ann_d): Remove base_var_processed and
base_index members.
* tree-ssa-live.h (struct _var_map): Remove basevars member.
(VAR_ANN_BASE_INDEX): Remove.
* tree-ssa-live.c (var_map_base_init): Use a hash table instead
of var annotation to compress index space.  Don't deal with above
removed members.
(var_map_base_fini): Don't free basevars.
(init_var_map): Don't clear basevars.

Index: tree-flow.h
===
*** tree-flow.h.orig2012-08-01 15:59:27.0 +0200
--- tree-flow.h 2012-08-01 15:59:35.0 +0200
*** enum need_phi_state {
*** 178,192 
  
  
  struct GTY(()) var_ann_d {
-   /* Used when building base variable structures in a var_map.  */
-   unsigned base_var_processed : 1;
- 
/* Nonzero if this variable was used after SSA optimizations were
   applied.  We set this when translating out of SSA form.  */
unsigned used : 1;
- 
-   /* Used by var_map for the base index of ssa base variables.  */
-   unsigned base_index;
  };
  
  
--- 178,186 
Index: tree-ssa-live.h
===
*** tree-ssa-live.h.orig2012-08-01 15:58:34.0 +0200
--- tree-ssa-live.h 2012-08-01 15:59:35.0 +0200
*** along with GCC; see the file COPYING3.
*** 31,43 
  /* Used to create the variable mapping when we go out of SSA form.
  
 Mapping from an ssa_name to a partition number is maintained, as well as
!partition number to back to ssa_name. A partition can also be represented
!by a non-ssa_name variable.  This allows ssa_names and their partition to
!be coalesced with live on entry compiler variables, as well as eventually
!having real compiler variables assigned to each partition as part of the
!final stage of going of of ssa.
! 
!Non-ssa_names maintain their partition index in the variable annotation.
  
 This data structure also supports views, which work on a subset of all
 partitions.  This allows the coalescer to decide what partitions are
--- 31,37 
  /* Used to create the variable mapping when we go out of SSA form.
  
 Mapping from an ssa_name to a partition number is maintained, as well as
!partition number back to ssa_name.
  
 This data structure also supports views, which work on a subset of all
 partitions.  This allows the coalescer to decide what partitions are
*** typedef struct _var_map
*** 72,87 
  
/* Map of partitions numbers to base variable table indexes.  */
int *partition_to_base_index;
- 
-   /* Table of base variable's.  */
-   VEC (tree, heap) *basevars;
  } *var_map;
  
  
- /* Index to the basevar table of a non ssa-name variable.  */
- #define VAR_ANN_BASE_INDEX(ann) (ann-base_index)
- 
- 
  /* Value used to represent no partition number.  */
  #define NO_PARTITION  -1
  
--- 66,74 
Index: tree-ssa-live.c
===
*** tree-ssa-live.c.orig2012-08-01 15:58:34.0 +0200
--- tree-ssa-live.c 2012-08-01 15:59:35.0 +0200
*** static void  verify_live_on_entry (tree_
*** 59,117 
  static void
  var_map_base_init (var_map map)
  {
!   int x, num_part, num;
tree var;
!   var_ann_t ann;
  
-   num = 0;
num_part = num_var_partitions (map);
  
/* If a base table already exists, clear it, otherwise create it.  */
!   if (map-partition_to_base_index != NULL)
! {
!   free (map-partition_to_base_index);
!   VEC_truncate (tree, map-basevars, 0);
! }
!   else
! map-basevars = VEC_alloc (tree, heap, MAX (40, (num_part / 10)));
! 
map-partition_to_base_index = (int *) xmalloc (sizeof (int) * num_part);
  
/* Build the base variable list, and point partitions at their bases.  */
for (x = 0; x  num_part; x++)
  {
var = partition_to_var (map, x);
!   if (TREE_CODE (var) == SSA_NAME)
!var = SSA_NAME_VAR (var);
!   ann = var_ann (var);
/* If base variable hasn't been seen, set it up.  */
!   if (!ann-base_var_processed)
! {
! ann-base_var_processed = 1;
! VAR_ANN_BASE_INDEX (ann) = num++;
! VEC_safe_push (tree, heap, map-basevars, var);
}
!   map-partition_to_base_index[x] = VAR_ANN_BASE_INDEX (ann);
  }
  
!   

[2/3] remove var_ann: Remove used flag

2012-08-01 Thread Michael Matz
Hi,

this removes the last member of var_ann_d, a bit used only locally in 
remove_unused_locals, so we can as well just use a bitmap.  (The funny 
renaming of the member I had to do because gengtype doesn't like empty 
structs, the whole thing will be removed momentarily with the third 
patch).

The only remaining semantic of var_ann now is if it's non-zero it's a 
non-global variable that was put into referenced_vars.

Regstrapped on x86_64-linux (with the other two patches).  Okay for trunk?


Ciao,
Michael.
-- 
* tree-flow.h (struct var_ann_d): Rename used member.
(set_is_used): Don't declare.
* tree-flow-inline.h (clear_is_used): Remove.
(set_is_used, is_used_p): Move to ...
* tree-ssa-live.c (set_is_used, is_used_p): ... here, and use
on the side bitmap.
(usedvars): New bitmap.
(dump_scope_block): Don't dump unusedness.
(remove_unused_locals): Allocate and free usedvars.
* tree-nrv.c (tree_nrv): Don't clear used flags here.

Index: gcc/tree-flow-inline.h
===
*** gcc.orig/tree-flow-inline.h 2012-08-01 15:58:33.0 +0200
--- gcc/tree-flow-inline.h  2012-08-01 16:00:42.0 +0200
*** phi_arg_index_from_use (use_operand_p us
*** 558,590 
   return index;
  }
  
- /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
- 
- static inline void
- set_is_used (tree var)
- {
-   var_ann_t ann = var_ann (var);
-   ann-used = true;
- }
- 
- /* Clear VAR's used flag.  */
- 
- static inline void
- clear_is_used (tree var)
- {
-   var_ann_t ann = var_ann (var);
-   ann-used = false;
- }
- 
- /* Return true if VAR is marked as used.  */
- 
- static inline bool
- is_used_p (tree var)
- {
-   var_ann_t ann = var_ann (var);
-   return ann-used;
- }
- 
  /* Return true if T (assumed to be a DECL) is a global variable.
 A variable is considered global if its storage is not automatic.  */
  
--- 558,563 
Index: gcc/tree-flow.h
===
*** gcc.orig/tree-flow.h2012-08-01 15:59:35.0 +0200
--- gcc/tree-flow.h 2012-08-01 16:00:42.0 +0200
*** enum need_phi_state {
*** 180,186 
  struct GTY(()) var_ann_d {
/* Nonzero if this variable was used after SSA optimizations were
   applied.  We set this when translating out of SSA form.  */
!   unsigned used : 1;
  };
  
  
--- 180,186 
  struct GTY(()) var_ann_d {
/* Nonzero if this variable was used after SSA optimizations were
   applied.  We set this when translating out of SSA form.  */
!   unsigned donotuse : 1;
  };
  
  
*** extern enum move_pos movement_possibilit
*** 741,747 
  char *get_lsm_tmp_name (tree, unsigned);
  
  /* In tree-flow-inline.h  */
- static inline void set_is_used (tree);
  static inline bool unmodifiable_var_p (const_tree);
  static inline bool ref_contains_array_ref (const_tree);
  
--- 741,746 
Index: gcc/tree-nrv.c
===
*** gcc.orig/tree-nrv.c 2012-08-01 15:58:33.0 +0200
--- gcc/tree-nrv.c  2012-08-01 16:00:42.0 +0200
*** tree_nrv (void)
*** 261,268 
SET_DECL_VALUE_EXPR (found, result);
DECL_HAS_VALUE_EXPR_P (found) = 1;
  
-   /* FOUND is no longer used.  Ensure it gets removed.  */
-   clear_is_used (found);
return 0;
  }
  
--- 261,266 
Index: gcc/tree-ssa-live.c
===
*** gcc.orig/tree-ssa-live.c2012-08-01 15:59:35.0 +0200
--- gcc/tree-ssa-live.c 2012-08-01 16:00:42.0 +0200
*** partition_view_bitmap (var_map map, bitm
*** 329,334 
--- 329,352 
  }
  
  
+ static bitmap usedvars;
+ 
+ /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
+ 
+ static inline void
+ set_is_used (tree var)
+ {
+   bitmap_set_bit (usedvars, DECL_UID (var));
+ }
+ 
+ /* Return true if VAR is marked as used.  */
+ 
+ static inline bool
+ is_used_p (tree var)
+ {
+   return bitmap_bit_p (usedvars, DECL_UID (var));
+ }
+ 
  static inline void mark_all_vars_used (tree *, void *data);
  
  /* Helper function for mark_all_vars_used, called via walk_tree.  */
*** dump_scope_block (FILE *file, int indent
*** 623,636 
fprintf (file,  \n);
for (var = BLOCK_VARS (scope); var; var = DECL_CHAIN (var))
  {
-   bool used = false;
- 
-   if (var_ann (var))
-   used = is_used_p (var);
- 
fprintf (file, %*s, indent, );
print_generic_decl (file, var, flags);
!   fprintf (file, %s\n, used ?  :  (unused));
  }
for (i = 0; i  BLOCK_NUM_NONLOCALIZED_VARS (scope); i++)
  {
--- 641,649 
fprintf (file,  \n);
for (var = BLOCK_VARS (scope); var; var = DECL_CHAIN (var))
  {
fprintf (file, %*s, indent, );
print_generic_decl 

PING: PATCH: Properly handle arg_pointer and frame_pointer in DWARF output

2012-08-01 Thread H.J. Lu
On Sat, Apr 28, 2012 at 8:11 AM, H.J. Lu hongjiu...@intel.com wrote:
 Hi,

 arg_pointer and frame_pointer are handled as special cases in
 based_loc_descr.

 (plus:DI (reg/f:DI 16 argp)
 (const_int -20 [0xffec]))

 is perfectly valid when Pmode == DImode and DWARF2_ADDR_SIZE is 32bit
 with ptr_mode == SImode.  This patch fixes ICE on the 2 testcases here.
 OK for trunk?

 Thanks.


 H.J.
 
 gcc/

 2012-04-06  H.J. Lu  hongjiu...@intel.com

 PR debug/52857
 * dwarf2out.c (mem_loc_descriptor): Allow arg_pointer_rtx and
 frame_pointer_rtx for based_loc_descr.

 gcc/testsuite/

 2012-04-06  H.J. Lu  hongjiu...@intel.com

 PR debug/52857
 * gcc.target/i386/pr52857-1.c: New.
 * gcc.target/i386/pr52857-2.c: Likewise.

 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
 index ca88fc5..515a824 100644
 --- a/gcc/dwarf2out.c
 +++ b/gcc/dwarf2out.c
 @@ -11655,6 +11657,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
  case REG:
if (GET_MODE_CLASS (mode) != MODE_INT
   || (GET_MODE_SIZE (mode)  DWARF2_ADDR_SIZE
 +  rtl != arg_pointer_rtx
 +  rtl != frame_pointer_rtx
  #ifdef POINTERS_EXTEND_UNSIGNED
(mode != Pmode || mem_mode == VOIDmode)
  #endif
 @@ -11927,7 +11931,9 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
  case PLUS:
  plus:
if (is_based_loc (rtl)
 -  GET_MODE_SIZE (mode) = DWARF2_ADDR_SIZE
 +  (GET_MODE_SIZE (mode) = DWARF2_ADDR_SIZE
 + || XEXP (rtl, 0) == arg_pointer_rtx
 + || XEXP (rtl, 0) == frame_pointer_rtx)
GET_MODE_CLASS (mode) == MODE_INT)
 mem_loc_result = based_loc_descr (XEXP (rtl, 0),
   INTVAL (XEXP (rtl, 1)),
 diff --git a/gcc/testsuite/gcc.target/i386/pr52857-1.c 
 b/gcc/testsuite/gcc.target/i386/pr52857-1.c
 new file mode 100644
 index 000..16fd78f
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/pr52857-1.c
 @@ -0,0 +1,10 @@
 +/* { dg-do compile { target { ! { ia32 } } } } */
 +/* { dg-options -g -O -mx32 -maddress-mode=long } */
 +
 +extern void get_BID128 (int *);
 +void
 +__bid128_div (void)
 +{
 +  int res;
 +  get_BID128 (res);
 +}
 diff --git a/gcc/testsuite/gcc.target/i386/pr52857-2.c 
 b/gcc/testsuite/gcc.target/i386/pr52857-2.c
 new file mode 100644
 index 000..879240a
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/pr52857-2.c
 @@ -0,0 +1,8 @@
 +/* { dg-do compile { target { ! { ia32 } } } } */
 +/* { dg-options -g -O -mx32 -maddress-mode=long } */
 +
 +void uw_init_context_1 (void *);
 +void _Unwind_ForcedUnwind (void)
 +{
 +  uw_init_context_1 (__builtin_dwarf_cfa ());
 +}

PING.

-- 
H.J.


[3/3] remove var_ann: die

2012-08-01 Thread Michael Matz
Hi,

On Wed, 1 Aug 2012, Michael Matz wrote:

 The only remaining semantic of var_ann now is if it's non-zero it's a 
 non-global variable that was put into referenced_vars.

And that's removed in this patch.  Most of the time it's not very 
interesting to know if a variable was put in referenced vars or not, in 
the inliner we can use a different mean.

So, this finally gets rid of the ugly variable annotations and hence a 
pointer for each var_decl, parm_decl and result_decl.

Regstrapped on x86_64-linux with the other two patches, no regressions.  
Okay for trunk?


Ciao,
Michael.
-- 
* tree-complex.c (init_parameter_lattice_values): Don't call var_ann.
* tree-dfa.c (struct dfa_stats_d): Remove num_var_anns member.
(dump_dfa_stats): Don't dump stats about var anns.
(collect_dfa_stats): Don't collect them.
(add_referenced_var_1): Don't set var annotation pointers.
(remove_referenced_var): Ditto, and only remove it it's in the
hash table.

* tree-flow-inline.h (var_ann): Remove.
* tree-flow.h (struct var_ann_d, var_ann_t): Remove.

* tree-inline.c (remapped_type): Remove.
(can_be_nonlocal): Most variable will be considered live here,
return false earlier.
(remap_decls): Don't call var_ann, all variables will be considered
referenced here.
(copy_debug_stmt): Ditto, and use is_global_var.

* tree-into-ssa.c (rewrite_debug_stmt_uses): Use get_current_def to
determine if a variable was referred to, not var_ann.
* tree-ssa-live.c (remove_unused_scope_block_p): Don't check var_ann.
(remove_unused_locals): Ditto.
* tree-ssa.c (delete_tree_ssa): Don't free/clear var ann pointers.
* tree-tailcall.c (arg_needs_copy_p): Don't check var_ann.
* tree.c (copy_node_stat): Don't clear var ann pointer.
* tree.h (tree_result_decl, tree_parm_decl, tree_var_decl): Remove
ann member.
(DECL_VAR_ANN_PTR): Remove.

Index: gcc/tree-complex.c
===
*** gcc.orig/tree-complex.c 2012-08-01 15:58:32.0 +0200
--- gcc/tree-complex.c  2012-08-01 16:00:51.0 +0200
*** init_parameter_lattice_values (void)
*** 176,182 
  
for (parm = DECL_ARGUMENTS (cfun-decl); parm ; parm = DECL_CHAIN (parm))
  if (is_complex_reg (parm)
-var_ann (parm) != NULL
 (ssa_name = gimple_default_def (cfun, parm)) != NULL_TREE)
VEC_replace (complex_lattice_t, complex_lattice_values,
   SSA_NAME_VERSION (ssa_name), VARYING);
--- 176,181 
Index: gcc/tree-dfa.c
===
*** gcc.orig/tree-dfa.c 2012-08-01 15:59:27.0 +0200
--- gcc/tree-dfa.c  2012-08-01 16:00:51.0 +0200
*** along with GCC; see the file COPYING3.
*** 46,52 
  /* Counters used to display DFA and SSA statistics.  */
  struct dfa_stats_d
  {
-   long num_var_anns;
long num_defs;
long num_uses;
long num_phis;
--- 46,51 
*** dump_dfa_stats (FILE *file)
*** 303,313 
fprintf (file, fmt_str_1, Referenced variables, (unsigned 
long)num_referenced_vars,
   SCALE (size), LABEL (size));
  
-   size = dfa_stats.num_var_anns * sizeof (struct var_ann_d);
-   total += size;
-   fprintf (file, fmt_str_1, Variables annotated, dfa_stats.num_var_anns,
-  SCALE (size), LABEL (size));
- 
size = dfa_stats.num_uses * sizeof (tree *);
total += size;
fprintf (file, fmt_str_1, USE operands, dfa_stats.num_uses,
--- 302,307 
*** collect_dfa_stats (struct dfa_stats_d *d
*** 374,382 
  
memset ((void *)dfa_stats_p, 0, sizeof (struct dfa_stats_d));
  
-   /* Count all the variable annotations.  */
-   dfa_stats_p-num_var_anns = htab_elements (gimple_referenced_vars (cfun));
- 
/* Walk all the statements in the function counting references.  */
FOR_EACH_BB (bb)
  {
--- 368,373 
*** add_referenced_var_1 (tree var, struct f
*** 561,571 
/* Insert VAR into the referenced_vars hash table if it isn't present
   and allocate its var-annotation.  */
if (referenced_var_check_and_insert (var, fn))
! {
!   gcc_checking_assert (!*DECL_VAR_ANN_PTR (var));
!   *DECL_VAR_ANN_PTR (var) = ggc_alloc_cleared_var_ann_d ();
!   return true;
! }
  
return false;
  }
--- 552,558 
/* Insert VAR into the referenced_vars hash table if it isn't present
   and allocate its var-annotation.  */
if (referenced_var_check_and_insert (var, fn))
! return true;
  
return false;
  }
*** add_referenced_var_1 (tree var, struct f
*** 576,582 
  void
  remove_referenced_var (tree var)
  {
-   var_ann_t v_ann;
struct tree_decl_minimal in;
void **loc;
unsigned int uid = DECL_UID (var);
--- 563,568 
*** remove_referenced_var 

Re: PING [PATCH] Fix PR libstdc++/54036, problem negating DFP NaNs

2012-08-01 Thread Paolo Carlini

Hi,

On 08/01/2012 12:46 AM, Peter Bergner wrote:

I'd like to ping the following libstdc++ DFP patch that fixes PR54036:

   http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00959.html
I think the patch is essentially Ok, but I would recommend giving Janis 
a chance to comment (say 24/48 h).


Note that the patch only touches libstdc++-v3 code, thus the testcases 
should be added to libstdc++-v3/testsuite/decimal and the patch itself 
was missing a CC to libstdc++@.


Thanks!
Paolo.


Re: [RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Jason Merrill
I think the problem is that we're deferring access control due to 
tentative parsing on line 11, and not on line 13.  I guess we need a


push_deferring_access_checks (dk_no_deferred);
pop_deferring_access_checks ();

around the substitution of default template args in type_unification_real.

Jason


Re: [1/3] remove var_ann: tlc for out-of-ssa

2012-08-01 Thread Richard Guenther
On Wed, Aug 1, 2012 at 4:05 PM, Michael Matz m...@suse.de wrote:
 Hi,

 this tidies ssa liveness calculation a bit (related to out-of-ssa).  In
 particular it doesn't make use of var annotations to compress the index
 space from partitions to base variable indices anymore, but instead a
 hashmap built on the fly when we need it.  The basevars itself actually
 aren't needed at all (currently only for checking), only a mapping for
 which ssa names belong to the same base variable.

 Regstrapped with the other two patches on x86_64-linux.  Okay for trunk?

Ok.

Thanks,
Richard.


 Ciao,
 Michael.
 * tree-flow.h (struct var_ann_d): Remove base_var_processed and
 base_index members.
 * tree-ssa-live.h (struct _var_map): Remove basevars member.
 (VAR_ANN_BASE_INDEX): Remove.
 * tree-ssa-live.c (var_map_base_init): Use a hash table instead
 of var annotation to compress index space.  Don't deal with above
 removed members.
 (var_map_base_fini): Don't free basevars.
 (init_var_map): Don't clear basevars.

 Index: tree-flow.h
 ===
 *** tree-flow.h.orig2012-08-01 15:59:27.0 +0200
 --- tree-flow.h 2012-08-01 15:59:35.0 +0200
 *** enum need_phi_state {
 *** 178,192 


   struct GTY(()) var_ann_d {
 -   /* Used when building base variable structures in a var_map.  */
 -   unsigned base_var_processed : 1;
 -
 /* Nonzero if this variable was used after SSA optimizations were
applied.  We set this when translating out of SSA form.  */
 unsigned used : 1;
 -
 -   /* Used by var_map for the base index of ssa base variables.  */
 -   unsigned base_index;
   };


 --- 178,186 
 Index: tree-ssa-live.h
 ===
 *** tree-ssa-live.h.orig2012-08-01 15:58:34.0 +0200
 --- tree-ssa-live.h 2012-08-01 15:59:35.0 +0200
 *** along with GCC; see the file COPYING3.
 *** 31,43 
   /* Used to create the variable mapping when we go out of SSA form.

  Mapping from an ssa_name to a partition number is maintained, as well as
 !partition number to back to ssa_name. A partition can also be represented
 !by a non-ssa_name variable.  This allows ssa_names and their partition to
 !be coalesced with live on entry compiler variables, as well as eventually
 !having real compiler variables assigned to each partition as part of the
 !final stage of going of of ssa.
 !
 !Non-ssa_names maintain their partition index in the variable annotation.

  This data structure also supports views, which work on a subset of all
  partitions.  This allows the coalescer to decide what partitions are
 --- 31,37 
   /* Used to create the variable mapping when we go out of SSA form.

  Mapping from an ssa_name to a partition number is maintained, as well as
 !partition number back to ssa_name.

  This data structure also supports views, which work on a subset of all
  partitions.  This allows the coalescer to decide what partitions are
 *** typedef struct _var_map
 *** 72,87 

 /* Map of partitions numbers to base variable table indexes.  */
 int *partition_to_base_index;
 -
 -   /* Table of base variable's.  */
 -   VEC (tree, heap) *basevars;
   } *var_map;


 - /* Index to the basevar table of a non ssa-name variable.  */
 - #define VAR_ANN_BASE_INDEX(ann) (ann-base_index)
 -
 -
   /* Value used to represent no partition number.  */
   #define NO_PARTITION  -1

 --- 66,74 
 Index: tree-ssa-live.c
 ===
 *** tree-ssa-live.c.orig2012-08-01 15:58:34.0 +0200
 --- tree-ssa-live.c 2012-08-01 15:59:35.0 +0200
 *** static void  verify_live_on_entry (tree_
 *** 59,117 
   static void
   var_map_base_init (var_map map)
   {
 !   int x, num_part, num;
 tree var;
 !   var_ann_t ann;

 -   num = 0;
 num_part = num_var_partitions (map);

 /* If a base table already exists, clear it, otherwise create it.  */
 !   if (map-partition_to_base_index != NULL)
 ! {
 !   free (map-partition_to_base_index);
 !   VEC_truncate (tree, map-basevars, 0);
 ! }
 !   else
 ! map-basevars = VEC_alloc (tree, heap, MAX (40, (num_part / 10)));
 !
 map-partition_to_base_index = (int *) xmalloc (sizeof (int) * num_part);

 /* Build the base variable list, and point partitions at their bases.  */
 for (x = 0; x  num_part; x++)
   {
 var = partition_to_var (map, x);
 !   if (TREE_CODE (var) == SSA_NAME)
 !var = SSA_NAME_VAR (var);
 !   ann = var_ann (var);
 /* If base variable hasn't been seen, set it up.  */
 !   if (!ann-base_var_processed)
 ! {
 ! ann-base_var_processed = 1;
 ! VAR_ANN_BASE_INDEX (ann) = num++;
 

Re: [2/3] remove var_ann: Remove used flag

2012-08-01 Thread Richard Guenther
On Wed, Aug 1, 2012 at 4:09 PM, Michael Matz m...@suse.de wrote:
 Hi,

 this removes the last member of var_ann_d, a bit used only locally in
 remove_unused_locals, so we can as well just use a bitmap.  (The funny
 renaming of the member I had to do because gengtype doesn't like empty
 structs, the whole thing will be removed momentarily with the third
 patch).

 The only remaining semantic of var_ann now is if it's non-zero it's a
 non-global variable that was put into referenced_vars.

 Regstrapped on x86_64-linux (with the other two patches).  Okay for trunk?

Ok.   Would be nice to now unify global and local var handling with a single
bitmap.

Thanks,
Richard.


 Ciao,
 Michael.
 --
 * tree-flow.h (struct var_ann_d): Rename used member.
 (set_is_used): Don't declare.
 * tree-flow-inline.h (clear_is_used): Remove.
 (set_is_used, is_used_p): Move to ...
 * tree-ssa-live.c (set_is_used, is_used_p): ... here, and use
 on the side bitmap.
 (usedvars): New bitmap.
 (dump_scope_block): Don't dump unusedness.
 (remove_unused_locals): Allocate and free usedvars.
 * tree-nrv.c (tree_nrv): Don't clear used flags here.

 Index: gcc/tree-flow-inline.h
 ===
 *** gcc.orig/tree-flow-inline.h 2012-08-01 15:58:33.0 +0200
 --- gcc/tree-flow-inline.h  2012-08-01 16:00:42.0 +0200
 *** phi_arg_index_from_use (use_operand_p us
 *** 558,590 
return index;
   }

 - /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
 -
 - static inline void
 - set_is_used (tree var)
 - {
 -   var_ann_t ann = var_ann (var);
 -   ann-used = true;
 - }
 -
 - /* Clear VAR's used flag.  */
 -
 - static inline void
 - clear_is_used (tree var)
 - {
 -   var_ann_t ann = var_ann (var);
 -   ann-used = false;
 - }
 -
 - /* Return true if VAR is marked as used.  */
 -
 - static inline bool
 - is_used_p (tree var)
 - {
 -   var_ann_t ann = var_ann (var);
 -   return ann-used;
 - }
 -
   /* Return true if T (assumed to be a DECL) is a global variable.
  A variable is considered global if its storage is not automatic.  */

 --- 558,563 
 Index: gcc/tree-flow.h
 ===
 *** gcc.orig/tree-flow.h2012-08-01 15:59:35.0 +0200
 --- gcc/tree-flow.h 2012-08-01 16:00:42.0 +0200
 *** enum need_phi_state {
 *** 180,186 
   struct GTY(()) var_ann_d {
 /* Nonzero if this variable was used after SSA optimizations were
applied.  We set this when translating out of SSA form.  */
 !   unsigned used : 1;
   };


 --- 180,186 
   struct GTY(()) var_ann_d {
 /* Nonzero if this variable was used after SSA optimizations were
applied.  We set this when translating out of SSA form.  */
 !   unsigned donotuse : 1;
   };


 *** extern enum move_pos movement_possibilit
 *** 741,747 
   char *get_lsm_tmp_name (tree, unsigned);

   /* In tree-flow-inline.h  */
 - static inline void set_is_used (tree);
   static inline bool unmodifiable_var_p (const_tree);
   static inline bool ref_contains_array_ref (const_tree);

 --- 741,746 
 Index: gcc/tree-nrv.c
 ===
 *** gcc.orig/tree-nrv.c 2012-08-01 15:58:33.0 +0200
 --- gcc/tree-nrv.c  2012-08-01 16:00:42.0 +0200
 *** tree_nrv (void)
 *** 261,268 
 SET_DECL_VALUE_EXPR (found, result);
 DECL_HAS_VALUE_EXPR_P (found) = 1;

 -   /* FOUND is no longer used.  Ensure it gets removed.  */
 -   clear_is_used (found);
 return 0;
   }

 --- 261,266 
 Index: gcc/tree-ssa-live.c
 ===
 *** gcc.orig/tree-ssa-live.c2012-08-01 15:59:35.0 +0200
 --- gcc/tree-ssa-live.c 2012-08-01 16:00:42.0 +0200
 *** partition_view_bitmap (var_map map, bitm
 *** 329,334 
 --- 329,352 
   }


 + static bitmap usedvars;
 +
 + /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
 +
 + static inline void
 + set_is_used (tree var)
 + {
 +   bitmap_set_bit (usedvars, DECL_UID (var));
 + }
 +
 + /* Return true if VAR is marked as used.  */
 +
 + static inline bool
 + is_used_p (tree var)
 + {
 +   return bitmap_bit_p (usedvars, DECL_UID (var));
 + }
 +
   static inline void mark_all_vars_used (tree *, void *data);

   /* Helper function for mark_all_vars_used, called via walk_tree.  */
 *** dump_scope_block (FILE *file, int indent
 *** 623,636 
 fprintf (file,  \n);
 for (var = BLOCK_VARS (scope); var; var = DECL_CHAIN (var))
   {
 -   bool used = false;
 -
 -   if (var_ann (var))
 -   used = is_used_p (var);
 -
 fprintf (file, %*s, indent, );
 print_generic_decl (file, var, flags);
 !   fprintf (file, %s\n, used ?  :  

Re: [3/3] remove var_ann: die

2012-08-01 Thread Richard Guenther
On Wed, Aug 1, 2012 at 4:13 PM, Michael Matz m...@suse.de wrote:
 Hi,

 On Wed, 1 Aug 2012, Michael Matz wrote:

 The only remaining semantic of var_ann now is if it's non-zero it's a
 non-global variable that was put into referenced_vars.

 And that's removed in this patch.  Most of the time it's not very
 interesting to know if a variable was put in referenced vars or not, in
 the inliner we can use a different mean.

 So, this finally gets rid of the ugly variable annotations and hence a
 pointer for each var_decl, parm_decl and result_decl.

 Regstrapped on x86_64-linux with the other two patches, no regressions.
 Okay for trunk?

Ok!

Thanks,
Richard.


 Ciao,
 Michael.
 --
 * tree-complex.c (init_parameter_lattice_values): Don't call var_ann.
 * tree-dfa.c (struct dfa_stats_d): Remove num_var_anns member.
 (dump_dfa_stats): Don't dump stats about var anns.
 (collect_dfa_stats): Don't collect them.
 (add_referenced_var_1): Don't set var annotation pointers.
 (remove_referenced_var): Ditto, and only remove it it's in the
 hash table.

 * tree-flow-inline.h (var_ann): Remove.
 * tree-flow.h (struct var_ann_d, var_ann_t): Remove.

 * tree-inline.c (remapped_type): Remove.
 (can_be_nonlocal): Most variable will be considered live here,
 return false earlier.
 (remap_decls): Don't call var_ann, all variables will be considered
 referenced here.
 (copy_debug_stmt): Ditto, and use is_global_var.

 * tree-into-ssa.c (rewrite_debug_stmt_uses): Use get_current_def to
 determine if a variable was referred to, not var_ann.
 * tree-ssa-live.c (remove_unused_scope_block_p): Don't check var_ann.
 (remove_unused_locals): Ditto.
 * tree-ssa.c (delete_tree_ssa): Don't free/clear var ann pointers.
 * tree-tailcall.c (arg_needs_copy_p): Don't check var_ann.
 * tree.c (copy_node_stat): Don't clear var ann pointer.
 * tree.h (tree_result_decl, tree_parm_decl, tree_var_decl): Remove
 ann member.
 (DECL_VAR_ANN_PTR): Remove.

 Index: gcc/tree-complex.c
 ===
 *** gcc.orig/tree-complex.c 2012-08-01 15:58:32.0 +0200
 --- gcc/tree-complex.c  2012-08-01 16:00:51.0 +0200
 *** init_parameter_lattice_values (void)
 *** 176,182 

 for (parm = DECL_ARGUMENTS (cfun-decl); parm ; parm = DECL_CHAIN (parm))
   if (is_complex_reg (parm)
 -var_ann (parm) != NULL
  (ssa_name = gimple_default_def (cfun, parm)) != NULL_TREE)
 VEC_replace (complex_lattice_t, complex_lattice_values,
SSA_NAME_VERSION (ssa_name), VARYING);
 --- 176,181 
 Index: gcc/tree-dfa.c
 ===
 *** gcc.orig/tree-dfa.c 2012-08-01 15:59:27.0 +0200
 --- gcc/tree-dfa.c  2012-08-01 16:00:51.0 +0200
 *** along with GCC; see the file COPYING3.
 *** 46,52 
   /* Counters used to display DFA and SSA statistics.  */
   struct dfa_stats_d
   {
 -   long num_var_anns;
 long num_defs;
 long num_uses;
 long num_phis;
 --- 46,51 
 *** dump_dfa_stats (FILE *file)
 *** 303,313 
 fprintf (file, fmt_str_1, Referenced variables, (unsigned 
 long)num_referenced_vars,
SCALE (size), LABEL (size));

 -   size = dfa_stats.num_var_anns * sizeof (struct var_ann_d);
 -   total += size;
 -   fprintf (file, fmt_str_1, Variables annotated, dfa_stats.num_var_anns,
 -  SCALE (size), LABEL (size));
 -
 size = dfa_stats.num_uses * sizeof (tree *);
 total += size;
 fprintf (file, fmt_str_1, USE operands, dfa_stats.num_uses,
 --- 302,307 
 *** collect_dfa_stats (struct dfa_stats_d *d
 *** 374,382 

 memset ((void *)dfa_stats_p, 0, sizeof (struct dfa_stats_d));

 -   /* Count all the variable annotations.  */
 -   dfa_stats_p-num_var_anns = htab_elements (gimple_referenced_vars (cfun));
 -
 /* Walk all the statements in the function counting references.  */
 FOR_EACH_BB (bb)
   {
 --- 368,373 
 *** add_referenced_var_1 (tree var, struct f
 *** 561,571 
 /* Insert VAR into the referenced_vars hash table if it isn't present
and allocate its var-annotation.  */
 if (referenced_var_check_and_insert (var, fn))
 ! {
 !   gcc_checking_assert (!*DECL_VAR_ANN_PTR (var));
 !   *DECL_VAR_ANN_PTR (var) = ggc_alloc_cleared_var_ann_d ();
 !   return true;
 ! }

 return false;
   }
 --- 552,558 
 /* Insert VAR into the referenced_vars hash table if it isn't present
and allocate its var-annotation.  */
 if (referenced_var_check_and_insert (var, fn))
 ! return true;

 return false;
   }
 *** add_referenced_var_1 (tree var, struct f
 *** 576,582 
   void
   remove_referenced_var 

Re: PING [PATCH] Fix PR libstdc++/54036, problem negating DFP NaNs

2012-08-01 Thread Janis Johnson
On 08/01/2012 07:29 AM, Paolo Carlini wrote:
 Hi,
 
 On 08/01/2012 12:46 AM, Peter Bergner wrote:
 I'd like to ping the following libstdc++ DFP patch that fixes PR54036:

http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00959.html
 I think the patch is essentially Ok, but I would recommend giving Janis 
 a chance to comment (say 24/48 h).

It looks fine to me.

 Note that the patch only touches libstdc++-v3 code, thus the testcases 
 should be added to libstdc++-v3/testsuite/decimal and the patch itself 
 was missing a CC to libstdc++@.

I agree.

Janis


rfa: merge handling of locals and globals in remove_unused_locals

2012-08-01 Thread Michael Matz
Hi,

On Wed, 1 Aug 2012, Richard Guenther wrote:

 Ok.  Would be nice to now unify global and local var handling with a 
 single bitmap.

Yeah, wanted to do that as follow-up.  Namely like so.  Regstrapping on 
x86_64-linux in progress on top of your remove-referenced-vars patches.  
Okay for trunk?


Ciao,
Michael.
-- 
* tree-ssa-live.c (set_is_used): Return a bool.
(mark_all_vars_used): Don't take data argument.
(mark_all_vars_used_1): Adjust calls to above, merge handling
of local and global vars.
(remove_unused_scope_block_p): Don't take global_unused_vars,
merge handling of local and global vars.
(remove_unused_locals): Don't allocate/fill/pass global_unused_vars,
use is_used_p for local and global vars.

Index: gcc/tree-ssa-live.c
===
*** gcc.orig/tree-ssa-live.c2012-08-01 17:21:39.0 +0200
--- gcc/tree-ssa-live.c 2012-08-01 17:22:01.0 +0200
*** partition_view_bitmap (var_map map, bitm
*** 331,342 
  
  static bitmap usedvars;
  
! /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
  
! static inline void
  set_is_used (tree var)
  {
!   bitmap_set_bit (usedvars, DECL_UID (var));
  }
  
  /* Return true if VAR is marked as used.  */
--- 331,343 
  
  static bitmap usedvars;
  
! /* Mark VAR as used, so that it'll be preserved during rtl expansion.
!Returns true if VAR wasn't marked before.  */
  
! static inline bool
  set_is_used (tree var)
  {
!   return bitmap_set_bit (usedvars, DECL_UID (var));
  }
  
  /* Return true if VAR is marked as used.  */
*** is_used_p (tree var)
*** 347,360 
return bitmap_bit_p (usedvars, DECL_UID (var));
  }
  
! static inline void mark_all_vars_used (tree *, void *data);
  
  /* Helper function for mark_all_vars_used, called via walk_tree.  */
  
  static tree
! mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data)
  {
-   bitmap global_unused_vars = (bitmap)data;
tree t = *tp;
enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
tree b;
--- 348,360 
return bitmap_bit_p (usedvars, DECL_UID (var));
  }
  
! static inline void mark_all_vars_used (tree *);
  
  /* Helper function for mark_all_vars_used, called via walk_tree.  */
  
  static tree
! mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data 
ATTRIBUTE_UNUSED)
  {
tree t = *tp;
enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
tree b;
*** mark_all_vars_used_1 (tree *tp, int *wal
*** 370,378 
   fields do not contain vars.  */
if (TREE_CODE (t) == TARGET_MEM_REF)
  {
!   mark_all_vars_used (TMR_BASE (t), data);
!   mark_all_vars_used (TMR_INDEX (t), data);
!   mark_all_vars_used (TMR_INDEX2 (t), data);
*walk_subtrees = 0;
return NULL;
  }
--- 370,378 
   fields do not contain vars.  */
if (TREE_CODE (t) == TARGET_MEM_REF)
  {
!   mark_all_vars_used (TMR_BASE (t));
!   mark_all_vars_used (TMR_INDEX (t));
!   mark_all_vars_used (TMR_INDEX2 (t));
*walk_subtrees = 0;
return NULL;
  }
*** mark_all_vars_used_1 (tree *tp, int *wal
*** 381,396 
   eliminated as unused.  */
if (TREE_CODE (t) == VAR_DECL)
  {
!   /* Global vars do not have a var-annotation so their use is tracked
!  with the global_unused_vars bitmap.  Also walk their initializer
!when they are first recognized as used.  */
!   if (is_global_var (t))
!   {
! if (bitmap_clear_bit (global_unused_vars, DECL_UID (t)))
!   mark_all_vars_used (DECL_INITIAL (t), data);
!   }
!   else
!   set_is_used (t);
  }
/* remove_unused_scope_block_p requires information about labels
   which are not DECL_IGNORED_P to tell if they might be used in the IL.  */
--- 381,390 
   eliminated as unused.  */
if (TREE_CODE (t) == VAR_DECL)
  {
!   /* When a global var becomes used for the first time also walk its
!  initializer (non global ones don't have any).  */
!   if (set_is_used (t)  is_global_var (t))
!   mark_all_vars_used (DECL_INITIAL (t));
  }
/* remove_unused_scope_block_p requires information about labels
   which are not DECL_IGNORED_P to tell if they might be used in the IL.  */
*** mark_scope_block_unused (tree scope)
*** 435,441 
 done by the inliner.  */
  
  static bool
! remove_unused_scope_block_p (tree scope, bitmap global_unused_vars)
  {
tree *t, *next;
bool unused = !TREE_USED (scope);
--- 429,435 
 done by the inliner.  */
  
  static bool
! remove_unused_scope_block_p (tree scope)
  {
tree *t, *next;
bool unused = !TREE_USED (scope);
*** remove_unused_scope_block_p (tree scope,
*** 475,483 
 info about optimized-out variables in the scope blocks.
 Exception are 

Re: rfa: merge handling of locals and globals in remove_unused_locals

2012-08-01 Thread Richard Guenther
On Wed, Aug 1, 2012 at 5:28 PM, Michael Matz m...@suse.de wrote:
 Hi,

 On Wed, 1 Aug 2012, Richard Guenther wrote:

 Ok.  Would be nice to now unify global and local var handling with a
 single bitmap.

 Yeah, wanted to do that as follow-up.  Namely like so.  Regstrapping on
 x86_64-linux in progress on top of your remove-referenced-vars patches.
 Okay for trunk?

Ok.

Thanks,
Richard.


 Ciao,
 Michael.
 --
 * tree-ssa-live.c (set_is_used): Return a bool.
 (mark_all_vars_used): Don't take data argument.
 (mark_all_vars_used_1): Adjust calls to above, merge handling
 of local and global vars.
 (remove_unused_scope_block_p): Don't take global_unused_vars,
 merge handling of local and global vars.
 (remove_unused_locals): Don't allocate/fill/pass global_unused_vars,
 use is_used_p for local and global vars.

 Index: gcc/tree-ssa-live.c
 ===
 *** gcc.orig/tree-ssa-live.c2012-08-01 17:21:39.0 +0200
 --- gcc/tree-ssa-live.c 2012-08-01 17:22:01.0 +0200
 *** partition_view_bitmap (var_map map, bitm
 *** 331,342 

   static bitmap usedvars;

 ! /* Mark VAR as used, so that it'll be preserved during rtl expansion.  */

 ! static inline void
   set_is_used (tree var)
   {
 !   bitmap_set_bit (usedvars, DECL_UID (var));
   }

   /* Return true if VAR is marked as used.  */
 --- 331,343 

   static bitmap usedvars;

 ! /* Mark VAR as used, so that it'll be preserved during rtl expansion.
 !Returns true if VAR wasn't marked before.  */

 ! static inline bool
   set_is_used (tree var)
   {
 !   return bitmap_set_bit (usedvars, DECL_UID (var));
   }

   /* Return true if VAR is marked as used.  */
 *** is_used_p (tree var)
 *** 347,360 
 return bitmap_bit_p (usedvars, DECL_UID (var));
   }

 ! static inline void mark_all_vars_used (tree *, void *data);

   /* Helper function for mark_all_vars_used, called via walk_tree.  */

   static tree
 ! mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data)
   {
 -   bitmap global_unused_vars = (bitmap)data;
 tree t = *tp;
 enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
 tree b;
 --- 348,360 
 return bitmap_bit_p (usedvars, DECL_UID (var));
   }

 ! static inline void mark_all_vars_used (tree *);

   /* Helper function for mark_all_vars_used, called via walk_tree.  */

   static tree
 ! mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data 
 ATTRIBUTE_UNUSED)
   {
 tree t = *tp;
 enum tree_code_class c = TREE_CODE_CLASS (TREE_CODE (t));
 tree b;
 *** mark_all_vars_used_1 (tree *tp, int *wal
 *** 370,378 
fields do not contain vars.  */
 if (TREE_CODE (t) == TARGET_MEM_REF)
   {
 !   mark_all_vars_used (TMR_BASE (t), data);
 !   mark_all_vars_used (TMR_INDEX (t), data);
 !   mark_all_vars_used (TMR_INDEX2 (t), data);
 *walk_subtrees = 0;
 return NULL;
   }
 --- 370,378 
fields do not contain vars.  */
 if (TREE_CODE (t) == TARGET_MEM_REF)
   {
 !   mark_all_vars_used (TMR_BASE (t));
 !   mark_all_vars_used (TMR_INDEX (t));
 !   mark_all_vars_used (TMR_INDEX2 (t));
 *walk_subtrees = 0;
 return NULL;
   }
 *** mark_all_vars_used_1 (tree *tp, int *wal
 *** 381,396 
eliminated as unused.  */
 if (TREE_CODE (t) == VAR_DECL)
   {
 !   /* Global vars do not have a var-annotation so their use is tracked
 !  with the global_unused_vars bitmap.  Also walk their initializer
 !when they are first recognized as used.  */
 !   if (is_global_var (t))
 !   {
 ! if (bitmap_clear_bit (global_unused_vars, DECL_UID (t)))
 !   mark_all_vars_used (DECL_INITIAL (t), data);
 !   }
 !   else
 !   set_is_used (t);
   }
 /* remove_unused_scope_block_p requires information about labels
which are not DECL_IGNORED_P to tell if they might be used in the IL.  
 */
 --- 381,390 
eliminated as unused.  */
 if (TREE_CODE (t) == VAR_DECL)
   {
 !   /* When a global var becomes used for the first time also walk its
 !  initializer (non global ones don't have any).  */
 !   if (set_is_used (t)  is_global_var (t))
 !   mark_all_vars_used (DECL_INITIAL (t));
   }
 /* remove_unused_scope_block_p requires information about labels
which are not DECL_IGNORED_P to tell if they might be used in the IL.  
 */
 *** mark_scope_block_unused (tree scope)
 *** 435,441 
  done by the inliner.  */

   static bool
 ! remove_unused_scope_block_p (tree scope, bitmap global_unused_vars)
   {
 tree *t, *next;
 bool unused = !TREE_USED (scope);
 --- 429,435 
  done by the inliner.  */

   static bool
 ! remove_unused_scope_block_p (tree scope)
   {
 tree *t, *next;
 bool unused 

[Patch, Fortran, F03] PR 54147: Interface checks for PPCs deferred TBPs

2012-08-01 Thread Janus Weil
Hi all,

here is a follow-up patch to my recent fix for PR 42418. Shortly after
committing it, I realized that the same checks should be done not only
for plain PROCEDURE declarations, but also for procedure-pointer
components and (deferred) type-bound procedures. So, what the attached
patch does, is to separate the checks out of their original place, put
them into a stand-alone routine and call this from different places in
order to apply the checks to the three cases mentioned above.

The new test cases are completely analogous to the one for 42418, but
tailored to PPCs  TBPs.

Patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2012-08-01  Janus Weil  ja...@gcc.gnu.org

PR fortran/54147
* resolve.c (check_proc_interface): New routine for PROCEDURE interface
checks.
(resolve_procedure_interface,resolve_typebound_procedure,
resolve_fl_derived0): Call it.

2012-08-01  Janus Weil  ja...@gcc.gnu.org

PR fortran/54147
* gfortran.dg/abstract_type_6.f03: Modified.
* gfortran.dg/proc_ptr_comp_3.f90: Modified.
* gfortran.dg/proc_ptr_comp_35.f90: New.
* gfortran.dg/typebound_proc_9.f03: Modified.
* gfortran.dg/typebound_proc_26.f90: New.


pr54147.diff
Description: Binary data


proc_ptr_comp_35.f90
Description: Binary data


typebound_proc_26.f90
Description: Binary data


Re: [RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Paolo Carlini

Hi,

On 08/01/2012 04:32 PM, Jason Merrill wrote:

I think the problem is that we're deferring access control due to
tentative parsing on line 11, and not on line 13.  I guess we need a

push_deferring_access_checks (dk_no_deferred);
pop_deferring_access_checks ();

around the substitution of default template args in
type_unification_real.
Great, thanks. Thus, I have been testing the attached and it definitely 
works for the testcases I discussed so far. Testsuite seems also Ok 
(lightly tested so far).


However, something weird is going on for this variant, using decltype 
(wanted to consistently extend sfinae37.C):


class C {
   typedef int type;
};

templateclass T
auto g(int) - decltype(typename T::type(), char());

templateclass
auto g(...) - char ()[2];

static_assert(sizeof(gC(0)) == 2, Ouch);  // line 11

typedef int testg[sizeof(gC(0)) == 2 ? 1 : -1];  // line 13

what happens is that line 13 is mishandled:

sfinae37_red.C:13:48: error: size of array ‘testg’ is negative

However, *if I comment out line 11*, things work for line 13! If I swap 
line 11 and line 13 then the declaration of testg is accepted and the 
static_assert triggers. In any case, only the first evaluation of the 
sizeof is correct, the next are incorrect. The issue seems so weird that 
it should be easy to fix... ;)


Final important observation: in fact, this variant with decltype is 
handled in the same way with or without the push_deferring_access_checks 
/ pop_deferring_access_checks calls.


Paolo.



Index: pt.c
===
--- pt.c(revision 190031)
+++ pt.c(working copy)
@@ -15122,9 +15122,11 @@ type_unification_real (tree tparms,
  location_t save_loc = input_location;
  if (DECL_P (parm))
input_location = DECL_SOURCE_LOCATION (parm);
+ push_deferring_access_checks (dk_no_deferred);
  arg = tsubst_template_arg (arg, targs, complain, NULL_TREE);
  arg = convert_template_argument (parm, arg, targs, complain,
   i, NULL_TREE);
+ pop_deferring_access_checks ();
  input_location = save_loc;
  if (arg == error_mark_node)
return 1;



Re: [PATCH 0/2] Convert s390 to atomic optabs, v2

2012-08-01 Thread Richard Henderson
On 08/01/2012 01:40 AM, Richard Guenther wrote:
 I see.  So your issue is that you don't get the knowledge
 that the address is even more aligned than required by the
 builtin.

Yes.  Very helpful for quite a few targets that only have word-sized atomic 
operations, and we emulate char/short via bit-fiddling.  That's where MEM_ALIGN 
as an align+ofs pair would come in doubly helpful...

 So we only use type information when seeing an actual memory
 reference where we make sure to keep alignment info correct
 (which we don't bother to do for addresses).

How hard would it be to include (some) builtins in actual memory reference?  
Since it seems likely at this point that gimple_atomic will make it in for 4.8?


r~


Re: [PATCH] Intrinsics for ADCX

2012-08-01 Thread Kirill Yukhin
Hi Richard,

 Frankly I don't understand the point of these instructions
 being added to the ISA at all.  I would have understood an
 add-with-carry that did *not* modify the flags at all, but
 two separate ones that modify C and O separately is just
 downright strange.
If there is only one carry in flight, they all are equivalent although
ADOX is a little less useful in loops.
If there are two carries in flight, that’s where the new instructions
show their benefit, since they allow accumulation without destroying
each other (see next comment).
For any number of carries beyond two, you have to start saving
restoring carry bits and it degenerates to the first case for some of
them.

 But to the point: I don't understand the point of having
 this as a builtin.  Is the code generated by this builtin
 any better than plain C?
I think this is just like a practice to introduce new intrinsics for new insns.
I doubt, that we may generate such things automatically:
c1 = 0;
c2 = 0;
c1 = _adcx64(  res[i], src[i], src2[i], c1);
c1 = _adcx64(  res[i+1], src[i+1], src2[i+1], c1);
c2 = _adcx64(  res[i], src[i], src2[i], c2);
c2 = _adcx64(  res[i+1], src[i+1], src2[i+1], c2);

 And if you're going to have the builtin, why is this restricted
 to adx anyway?  You obviously can produce the same results with
 the good old fashioned adc instruction as well.
We have one intrinsic for both ADCX/ADOX. So, we just picked up first
one to use when exanding the built-in

 Which begs the question of why you've got a separate pattern
 for the adx anyway.  If the insn is so much better, it ought to
 be used in the same pattern we use for adc now.
I believe, we may introduce global variant of ADCX, which may be
expanded into either of ADC/ADCX/ADOX on x86 and into analogs
on the other ports.

K


Re: [PATCH 0/2] Convert s390 to atomic optabs, v2

2012-08-01 Thread Richard Guenther
On Wed, 1 Aug 2012, Richard Henderson wrote:

 On 08/01/2012 01:40 AM, Richard Guenther wrote:
  I see.  So your issue is that you don't get the knowledge
  that the address is even more aligned than required by the
  builtin.
 
 Yes.  Very helpful for quite a few targets that only have word-sized atomic 
 operations, and we emulate char/short via bit-fiddling.  That's where 
 MEM_ALIGN as an align+ofs pair would come in doubly helpful...
 
  So we only use type information when seeing an actual memory
  reference where we make sure to keep alignment info correct
  (which we don't bother to do for addresses).
 
 How hard would it be to include (some) builtins in actual memory reference? 
  Since it seems likely at this point that gimple_atomic will make it in for 
 4.8?

Actually it would not help you at all.  As far as I understand
the testcase is equivalent from an alignment perspective to

 struct S { int x; unsigned short y; } g_s;
 void bad (S *p_s)
 {
   short *p = (short *)p_s-y;
   *(short *)p = 0;
 }

so the builtin is a memory access to a short.  We cannot derive
any alignment for p_s from this alone unless we change the way
the middle-end constrains pointer type usage (which in turn
means that pointer conversions cannot be dropped on the floor
like we do now).

If you said

  p_s-y = 0;

then we can exploit the fact that you dereference p_s and derive
bigger alignment.  But I don't see how we can massage the
builtin to preserve such form.  Well, put in a memory reference
in the argument, __builtin_compare_exchange (p_s-y, ...), but
that fails foul of GIMPLE requirements to use a temporary for
register type function arguments, which we may be able to
overcome with some special flags.

Richard.


Re: [PATCH][1/2] Remove referenced vars

2012-08-01 Thread Richard Guenther
On Wed, 1 Aug 2012, Richard Guenther wrote:

 
 This series aims at removing referenced vars.  It builds on the into-SSA
 TLC series and the still to be posted removal of var-anns.
 
 This first patch removes SRAs use of referenced vars.  Instead of
 turning it upside-down the following simply adds a pass-local
 referenced vars reverse lookup capability uid - decl.
 
 This was the last user of referenced_var ().

The following is what I ended up applying after re-testing on
x86_64-unknown-linux-gnu.

Richard.

2012-08-01  Richard Guenther  rguent...@suse.de

* tree-flow-inline.h (referenced_var): Remove.
* tree-ssa-coalesce.c (create_outofssa_var_map): Remove duplicate
checking code.
* tree-sra.c (candidates): New global hashtable.
(candidate): New function.
(sra_initialize): Initialize candidates.
(sra_deinitialize): Free candidates.
(disqualify_candidate): Remove candidate from candidates.
(maybe_add_sra_candidate): New function.
(find_var_candidates): Walk over all local decls and parameters,
add candidates to candidates hashtable.
(find_param_candidates): Add candidates to candidates hashtable.
(analyze_all_variable_accesses): Use candidate instead of
referenced_var.

Index: gcc/tree-flow-inline.h
===
*** gcc/tree-flow-inline.h.orig 2012-08-01 17:04:18.0 +0200
--- gcc/tree-flow-inline.h  2012-08-01 17:14:40.874388765 +0200
*** next_htab_element (htab_iterator *hti)
*** 98,113 
return NULL;
  }
  
- /* Get the variable with uid UID from the list of referenced vars.  */
- 
- static inline tree
- referenced_var (unsigned int uid)
- {
-   tree var = referenced_var_lookup (cfun, uid);
-   gcc_assert (var || uid == 0);
-   return var;
- }
- 
  /* Initialize ITER to point to the first referenced variable in the
 referenced_vars hashtable, and return that variable.  */
  
--- 98,103 
Index: gcc/tree-ssa-coalesce.c
===
*** gcc/tree-ssa-coalesce.c.orig2012-08-01 16:42:49.0 +0200
--- gcc/tree-ssa-coalesce.c 2012-08-01 17:14:40.874388765 +0200
*** create_outofssa_var_map (coalesce_list_p
*** 983,996 
int v1, v2, cost;
unsigned i;
  
- #ifdef ENABLE_CHECKING
-   bitmap used_in_real_ops;
-   bitmap used_in_virtual_ops;
- 
-   used_in_real_ops = BITMAP_ALLOC (NULL);
-   used_in_virtual_ops = BITMAP_ALLOC (NULL);
- #endif
- 
map = init_var_map (num_ssa_names);
  
FOR_EACH_BB (bb)
--- 983,988 
*** create_outofssa_var_map (coalesce_list_p
*** 1126,1142 
default:
  break;
}
- 
- #ifdef ENABLE_CHECKING
- /* Mark real uses and defs.  */
- FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE))
-   bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (var)));
- 
- /* Validate that virtual ops don't get used in funny ways.  */
- if (gimple_vuse (stmt))
-   bitmap_set_bit (used_in_virtual_ops,
-   DECL_UID (SSA_NAME_VAR (gimple_vuse (stmt;
- #endif /* ENABLE_CHECKING */
}
  }
  
--- 1118,1123 
*** create_outofssa_var_map (coalesce_list_p
*** 1173,1199 
}
  }
  
- #if defined ENABLE_CHECKING
-   {
- unsigned i;
- bitmap both = BITMAP_ALLOC (NULL);
- bitmap_and (both, used_in_real_ops, used_in_virtual_ops);
- if (!bitmap_empty_p (both))
-   {
-   bitmap_iterator bi;
- 
-   EXECUTE_IF_SET_IN_BITMAP (both, 0, i, bi)
- fprintf (stderr, Variable %s used in real and virtual operands\n,
-  get_name (referenced_var (i)));
-   internal_error (SSA corruption);
-   }
- 
- BITMAP_FREE (used_in_real_ops);
- BITMAP_FREE (used_in_virtual_ops);
- BITMAP_FREE (both);
-   }
- #endif
- 
return map;
  }
  
--- 1154,1159 
Index: gcc/tree-sra.c
===
*** gcc/tree-sra.c.orig 2012-08-01 16:42:49.0 +0200
--- gcc/tree-sra.c  2012-08-01 17:18:02.220381820 +0200
*** struct access
*** 224,232 
   BIT_FIELD_REF?  */
unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  We do
!  the decision and creation at different places because create_tmp_var
!  cannot be called from within FOR_EACH_REFERENCED_VAR. */
unsigned grp_to_be_replaced : 1;
  
/* Should TREE_NO_WARNING of a replacement be set?  */
--- 224,230 
   BIT_FIELD_REF?  */
unsigned grp_partial_lhs : 1;
  
!   /* Set when a scalar replacement should be created for this variable.  */
unsigned grp_to_be_replaced : 1;
  
/* Should TREE_NO_WARNING of a replacement be set?  */
*** static alloc_pool link_pool;
*** 

Re: [PATCH, MIPS] Add 34Kn cpu

2012-08-01 Thread Richard Sandiford
Sandra Loosemore san...@codesourcery.com writes:
 This patch makes GCC know about -march=34kn.  MIPS asked us to add 
 support for this processor to our local source base a couple of years 
 ago; it's basically a 34Kc without the DSP ASE.  OK for mainline?

 I have posted the corresponding assembler patch here:
 http://sourceware.org/ml/binutils/2012-08/msg8.html

 -Sandra


 2012-08-01  Catherine Moore  c...@codesourcery.com
   Sandra Loosemore  san...@codesourcery.com

   gcc/
   * config/mips/mips-cpus.def (34kn): New.
   * config/mips/mips.h (MIPS_ARCH_FLOAT_SPEC): Add 34kn.
   (BASE_DRIVER_SELF_SPECS): Do not imply -mdsp for the 34kn.

Needs adding to invoke.texi too.  OK with that change, thanks.

Richard


Re: [RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Jason Merrill

On 08/01/2012 11:49 AM, Paolo Carlini wrote:

static_assert(sizeof(gC(0)) == 2, Ouch);  // line 11

typedef int testg[sizeof(gC(0)) == 2 ? 1 : -1];  // line 13

what happens is that line 13 is mishandled:

sfinae37_red.C:13:48: error: size of array ‘testg’ is negative

However, *if I comment out line 11*, things work for line 13! If I swap
line 11 and line 13 then the declaration of testg is accepted and the
static_assert triggers.


Curious.  I guess that the second time we see the call the compiler 
thinks it already has the candidate it needs, but I don't know why that 
would be.  Are we not getting to type_unification_real from 
add_template_candidate the second time?


Jason



Re: [RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Paolo Carlini

On 08/01/2012 07:35 PM, Jason Merrill wrote:

On 08/01/2012 11:49 AM, Paolo Carlini wrote:

static_assert(sizeof(gC(0)) == 2, Ouch);  // line 11

typedef int testg[sizeof(gC(0)) == 2 ? 1 : -1];  // line 13

what happens is that line 13 is mishandled:

sfinae37_red.C:13:48: error: size of array ‘testg’ is negative

However, *if I comment out line 11*, things work for line 13! If I swap
line 11 and line 13 then the declaration of testg is accepted and the
static_assert triggers.


Curious.  I guess that the second time we see the call the compiler 
thinks it already has the candidate it needs, but I don't know why 
that would be.  Are we not getting to type_unification_real from 
add_template_candidate the second time?
So, I'm in the middle of this (got distracted earlier today). I can tell 
you what I have.


For the second evaluation, the second time we call 
instantiate_template_1, thus for the interesting g(int) overload, here:


  spec = retrieve_specialization (gen_tmpl, targ_ptr, 0);

  gcc_assert (tmpl == gen_tmpl
  || ((fndecl = retrieve_specialization (tmpl, orig_args, 0))
  == spec)
  || fndecl == NULL_TREE);

  if (spec != NULL_TREE)
{
  if (FNDECL_RECHECK_ACCESS_P (spec)  (complain  tf_error))
recheck_decl_substitution (spec, gen_tmpl, targ_ptr);
  return spec;
}

things are completely different, because spec != NULL_TREE and, more 
importantly, complain is tf_none, thus recheck_decl_substitution is not 
called, we just return immediately.


Compare to the first evaluation: in that case we call enforce_access 
*way* below, with the perform_deferred_access_checks call near the end 
of instantiate_template_1.


Thus, looks like the recheck_decl_substitution mechanism is not working 
by design because of complain == tf_none?!?


Note that while I'm debugging this, I see instantiate_template_1 always 
getting complain == tf_none, something seems weird about the  
(complain  tf_error) above...


Paolo.



PATCH: PR rtl-optimization/54157: [x32] -maddress-mode=long failures

2012-08-01 Thread H.J. Lu
Hi,

We have

(gdb) r -fpreprocessed x.i -quiet -dumpbase x.i -mx32
-maddress-mode=long -mtune=generic -march=x86-64 -auxbase x -O2 -version
-ftree-vectorize -o x.s
Starting program: /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/cc1
-fpreprocessed x.i -quiet -dumpbase x.i -mx32 -maddress-mode=long
-mtune=generic -march=x86-64 -auxbase x -O2 -version -ftree-vectorize -o
x.s
GNU C (GCC) version 4.8.0 20120801 (experimental)
(x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.1 20120629 (Red Hat 4.7.1-1), GMP
version 5.0.2, MPFR version 3.1.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.8.0 20120801 (experimental)
(x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.1 20120629 (Red Hat 4.7.1-1), GMP
version 5.0.2, MPFR version 3.1.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 07a4e516c4e8fe4abfdafa83737d8f4a

Breakpoint 1, fancy_abort (
file=0x130fe68 /export/gnu/import/git/gcc/gcc/explow.c, line=88, 
function=0x131032e __FUNCTION__.39220 plus_constant)
at /export/gnu/import/git/gcc/gcc/diagnostic.c:1011
1011  internal_error (in %s, at %s:%d, function, trim_filename
(file), line);
(gdb) f 1
#1  0x00743e07 in plus_constant (mode=DImode, x=0x7106a7e0, 
c=99452) at /export/gnu/import/git/gcc/gcc/explow.c:88
88gcc_assert (GET_MODE (x) == VOIDmode || GET_MODE (x) == mode);
(gdb) f 2
#2  0x00adc4b1 in simplify_binary_operation_1 (code=PLUS,
mode=DImode, 
op0=0x7106a7e0, op1=0x71010e80, trueop0=0x7106a7e0, 
trueop1=0x71010e80)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1956
1956return plus_constant (mode, op0, INTVAL (op1));
(gdb) call debug_rtx (op0)
(symbol_ref:SI (tmp2) var_decl 0x70f06140 tmp2)
(gdb) call debug_rtx (op1)
(const_int 99452 [0x1847c])
(gdb) bt
#0  fancy_abort (file=0x130fe68
/export/gnu/import/git/gcc/gcc/explow.c, 
line=88, function=0x131032e __FUNCTION__.39220 plus_constant)
at /export/gnu/import/git/gcc/gcc/diagnostic.c:1011
#1  0x00743e07 in plus_constant (mode=DImode, x=0x7106a7e0, 
c=99452) at /export/gnu/import/git/gcc/gcc/explow.c:88
#2  0x00adc4b1 in simplify_binary_operation_1 (code=PLUS,
mode=DImode, 
op0=0x7106a7e0, op1=0x71010e80, trueop0=0x7106a7e0, 
trueop1=0x71010e80)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1956
#3  0x00adc221 in simplify_binary_operation (code=PLUS,
mode=DImode, 
op0=0x7106a7e0, op1=0x71010e80)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1904
#4  0x00ae4beb in simplify_plus_minus (code=PLUS, mode=DImode, 
op0=0x71071d80, op1=0x71072440)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:4083
#5  0x00adcd81 in simplify_binary_operation_1 (code=PLUS,
mode=DImode, 
op0=0x71071d80, op1=0x71072440, trueop0=0x71071d80, 
trueop1=0x71072440)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:2079
#6  0x00adc221 in simplify_binary_operation (code=PLUS,
mode=DImode, 
op0=0x71071d80, op1=0x71072440)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1904
#7  0x00ad6f55 in simplify_gen_binary (code=PLUS, mode=DImode, 
---Type return to continue, or q return to quit---
op0=0x71071d80, op1=0x71072440)
at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:173
#8  0x0111b868 in force_to_mode (x=0x71071cd8, mode=DImode, 
mask=15, just_select=0) at
/export/gnu/import/git/gcc/gcc/combine.c:8392
#9  0x01118ed6 in make_extraction (mode=SImode,
inner=0x71071cd8, 
pos=2, pos_rtx=0x0, len=2, unsignedp=1, in_dest=0, in_compare=0)
at /export/gnu/import/git/gcc/gcc/combine.c:7474
#10 0x01119981 in make_compound_operation (x=0x71071d68, 
in_code=SET) at /export/gnu/import/git/gcc/gcc/combine.c:7721
#11 0x01116cc5 in simplify_set (x=0x71066c78)
at /export/gnu/import/git/gcc/gcc/combine.c:6539
#12 0x01114e91 in combine_simplify_rtx (x=0x71066c78, 
op0_mode=VOIDmode, in_dest=0, in_cond=0)
at /export/gnu/import/git/gcc/gcc/combine.c:5971
#13 0x01113250 in subst (x=0x71066c78, from=0x7106a860, 
to=0x71071cd8, in_dest=0, in_cond=0, unique_copy=0)
at /export/gnu/import/git/gcc/gcc/combine.c:5301
#14 0x01112d30 in subst (x=0x71059870, from=0x7106a860, 
to=0x71071cd8, in_dest=0, in_cond=0, unique_copy=0)
at /export/gnu/import/git/gcc/gcc/combine.c:5164
#15 0x0110d1e3 in try_combine (i3=0x7106c5a0,
i2=0x7106c558, 
i1=0x7106c510, i0=0x0, new_direct_jump_p=0x7fffd974, 
last_combined_insn=0x7106c5a0)
---Type return to continue, or q return to quit---
at /export/gnu/import/git/gcc/gcc/combine.c:3259
#16 0x011083ad in combine_instructions (f=0x7102ba40,
nregs

Re: [RFC / RFH] Re-opened C++/51213 (access control under SFINAE)

2012-08-01 Thread Paolo Carlini

Hi again,

On 08/01/2012 08:40 PM, Paolo Carlini wrote:
For the second evaluation, the second time we call 
instantiate_template_1, thus for the interesting g(int) overload, here:


  spec = retrieve_specialization (gen_tmpl, targ_ptr, 0);

  gcc_assert (tmpl == gen_tmpl
  || ((fndecl = retrieve_specialization (tmpl, orig_args, 0))
  == spec)
  || fndecl == NULL_TREE);

  if (spec != NULL_TREE)
{
  if (FNDECL_RECHECK_ACCESS_P (spec)  (complain  tf_error))
recheck_decl_substitution (spec, gen_tmpl, targ_ptr);
  return spec;
}

things are completely different, because spec != NULL_TREE and, more 
importantly, complain is tf_none, thus recheck_decl_substitution is 
not called, we just return immediately.
So, it is possible that when spec != NULL_TREE and we are once more in a 
SFINAE context, we have to actually call perform_deferred_access_checks 
(complain) and either return error_mark_node or the spec depending on 
the return value?


Paolo.


Re: PATCH: PR rtl-optimization/54157: [x32] -maddress-mode=long failures

2012-08-01 Thread Richard Sandiford
H.J. Lu hongjiu...@intel.com writes:
 We have

 (gdb) r -fpreprocessed x.i -quiet -dumpbase x.i -mx32
 -maddress-mode=long -mtune=generic -march=x86-64 -auxbase x -O2 -version
 -ftree-vectorize -o x.s
 Starting program: /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/cc1
 -fpreprocessed x.i -quiet -dumpbase x.i -mx32 -maddress-mode=long
 -mtune=generic -march=x86-64 -auxbase x -O2 -version -ftree-vectorize -o
 x.s
 GNU C (GCC) version 4.8.0 20120801 (experimental)
 (x86_64-unknown-linux-gnu)
   compiled by GNU C version 4.7.1 20120629 (Red Hat 4.7.1-1), GMP
 version 5.0.2, MPFR version 3.1.0, MPC version 0.9
 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 GNU C (GCC) version 4.8.0 20120801 (experimental)
 (x86_64-unknown-linux-gnu)
   compiled by GNU C version 4.7.1 20120629 (Red Hat 4.7.1-1), GMP
 version 5.0.2, MPFR version 3.1.0, MPC version 0.9
 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 Compiler executable checksum: 07a4e516c4e8fe4abfdafa83737d8f4a

 Breakpoint 1, fancy_abort (
 file=0x130fe68 /export/gnu/import/git/gcc/gcc/explow.c, line=88, 
 function=0x131032e __FUNCTION__.39220 plus_constant)
 at /export/gnu/import/git/gcc/gcc/diagnostic.c:1011
 1011internal_error (in %s, at %s:%d, function, trim_filename
 (file), line);
 (gdb) f 1
 #1  0x00743e07 in plus_constant (mode=DImode, x=0x7106a7e0, 
 c=99452) at /export/gnu/import/git/gcc/gcc/explow.c:88
 88  gcc_assert (GET_MODE (x) == VOIDmode || GET_MODE (x) == mode);
 (gdb) f 2
 #2  0x00adc4b1 in simplify_binary_operation_1 (code=PLUS,
 mode=DImode, 
 op0=0x7106a7e0, op1=0x71010e80, trueop0=0x7106a7e0, 
 trueop1=0x71010e80)
 at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1956
 1956  return plus_constant (mode, op0, INTVAL (op1));
 (gdb) call debug_rtx (op0)
 (symbol_ref:SI (tmp2) var_decl 0x70f06140 tmp2)
 (gdb) call debug_rtx (op1)
 (const_int 99452 [0x1847c])
 (gdb) bt
 #0  fancy_abort (file=0x130fe68
 /export/gnu/import/git/gcc/gcc/explow.c, 
 line=88, function=0x131032e __FUNCTION__.39220 plus_constant)
 at /export/gnu/import/git/gcc/gcc/diagnostic.c:1011
 #1  0x00743e07 in plus_constant (mode=DImode, x=0x7106a7e0, 
 c=99452) at /export/gnu/import/git/gcc/gcc/explow.c:88
 #2  0x00adc4b1 in simplify_binary_operation_1 (code=PLUS,
 mode=DImode, 
 op0=0x7106a7e0, op1=0x71010e80, trueop0=0x7106a7e0, 
 trueop1=0x71010e80)
 at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1956
 #3  0x00adc221 in simplify_binary_operation (code=PLUS,
 mode=DImode, 
 op0=0x7106a7e0, op1=0x71010e80)
 at /export/gnu/import/git/gcc/gcc/simplify-rtx.c:1904

Things have already gone wrong by this frame: we have a DImode
addition of an SImode value, which isn't allowed.  Where does
that mismatch get introduced?

Richard


Re: ORDERED_EXPR in invert_tree_comparison

2012-08-01 Thread Marc Glisse

Hello,

an opinion on this?

(I just noticed: I'll update the list in the comment visible at the top of 
the patch if this gets in).


On Thu, 19 Jul 2012, Marc Glisse wrote:


Hello,

the simple patch below passes the testsuite after a c,c++ bootstrap without 
new regressions. Note however that


#include math.h
int f(double a, double b){
 return (!isunordered(a,b))(ab);
}

is then optimized by ifcombine to return (ab);, which seems wrong in the 
absence of -fno-trapping-math. I don't know if there are ways to trigger this 
latent bug without the patch.




2012-06-15  Marc Glisse  marc.gli...@inria.fr

   PR tree-optimization/53805
   * fold-const.c (invert_tree_comparison): Do invert ORDERED_EXPR and
   UNORDERED_EXPR for floating point.

--- fold-const.c(revision 189622)
+++ fold-const.c(working copy)
@@ -2096,13 +2096,14 @@ pedantic_non_lvalue_loc (location_t loc,
   It is generally not safe to do this for floating-point comparisons, except
   for EQ_EXPR and NE_EXPR, so we return ERROR_MARK in this case.  */

enum tree_code
invert_tree_comparison (enum tree_code code, bool honor_nans)
{
-  if (honor_nans  flag_trapping_math  code != EQ_EXPR  code != NE_EXPR)
+  if (honor_nans  flag_trapping_math  code != EQ_EXPR  code != NE_EXPR
+   code != ORDERED_EXPR  code != UNORDERED_EXPR)
return ERROR_MARK;

  switch (code)
{
case EQ_EXPR:
  return NE_EXPR;


--
Marc Glisse


Remove redundant comparison in debug mode

2012-08-01 Thread François Dumont
Verifying number of comparisons invoked in different algos and different 
modes I remarked this small performance issue.


2012-08-01  François Dumont  fdum...@gcc.gnu.org

* include/debug/functions.h (__check_partition_lower_aux): Remove
redundant comparison with pivot value.
(__check_partition_upper_aux): Likewise.

Tested under Linux x86_64 debug mode.

Ok for trunk ?

François
Index: include/debug/functions.h
===
--- include/debug/functions.h	(revision 189985)
+++ include/debug/functions.h	(working copy)
@@ -354,8 +354,12 @@
 {
   while (__first != __last  *__first  __value)
 	++__first;
-  while (__first != __last  !(*__first  __value))
-	++__first;
+  if (__first != __last)
+	{
+	  ++__first;
+	  while (__first != __last  !(*__first  __value))
+	++__first;
+	}
   return __first == __last;
 }
 
@@ -368,8 +372,10 @@
 			const _Safe_iterator_Iterator, _Sequence __last,
 			const _Tp __value,
 			std::random_access_iterator_tag __tag)
-{ return __check_partitioned_lower_aux(__first.base(), __last.base(),
-	   __value, __tag); }
+{
+  return __check_partitioned_lower_aux(__first.base(), __last.base(),
+	   __value, __tag);
+}
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 270. Binary search requirements overly strict
@@ -378,8 +384,10 @@
 inline bool
 __check_partitioned_lower(_ForwardIterator __first,
 			  _ForwardIterator __last, const _Tp __value)
-{ return __check_partitioned_lower_aux(__first, __last, __value,
-	   std::__iterator_category(__first)); }
+{
+  return __check_partitioned_lower_aux(__first, __last, __value,
+	   std::__iterator_category(__first));
+}
 
   templatetypename _ForwardIterator, typename _Tp
 inline bool
@@ -389,8 +397,12 @@
 {
   while (__first != __last  !(__value  *__first))
 	++__first;
-  while (__first != __last  __value  *__first)
-	++__first;
+  if (__first != __last)
+	{
+	  ++__first;
+	  while (__first != __last  __value  *__first)
+	++__first;
+	}
   return __first == __last;
 }
 
@@ -403,15 +415,19 @@
 			const _Safe_iterator_Iterator, _Sequence __last,
 			const _Tp __value,
 			std::random_access_iterator_tag __tag)
-{ return __check_partitioned_upper_aux(__first.base(), __last.base(),
-	   __value, __tag); }
+{
+  return __check_partitioned_upper_aux(__first.base(), __last.base(),
+	   __value, __tag);
+}
 
   templatetypename _ForwardIterator, typename _Tp
 inline bool
 __check_partitioned_upper(_ForwardIterator __first,
 			  _ForwardIterator __last, const _Tp __value)
-{ return __check_partitioned_upper_aux(__first, __last, __value,
-	   std::__iterator_category(__first)); }
+{
+  return __check_partitioned_upper_aux(__first, __last, __value,
+	   std::__iterator_category(__first));
+}
 
   templatetypename _ForwardIterator, typename _Tp, typename _Pred
 inline bool
@@ -422,8 +438,12 @@
 {
   while (__first != __last  bool(__pred(*__first, __value)))
 	++__first;
-  while (__first != __last  !bool(__pred(*__first, __value)))
-	++__first;
+  if (__first != __last)
+	{
+	  ++__first;
+	  while (__first != __last  !bool(__pred(*__first, __value)))
+	++__first;
+	}
   return __first == __last;
 }
 
@@ -437,8 +457,10 @@
 			const _Safe_iterator_Iterator, _Sequence __last,
 			const _Tp __value, _Pred __pred,
 			std::random_access_iterator_tag __tag)
-{ return __check_partitioned_lower_aux(__first.base(), __last.base(),
-	   __value, __pred, __tag); }
+{
+  return __check_partitioned_lower_aux(__first.base(), __last.base(),
+	   __value, __pred, __tag);
+}
 
   // Determine if a sequence is partitioned w.r.t. this element.
   templatetypename _ForwardIterator, typename _Tp, typename _Pred
@@ -446,8 +468,10 @@
 __check_partitioned_lower(_ForwardIterator __first,
 			  _ForwardIterator __last, const _Tp __value,
 			  _Pred __pred)
-{ return __check_partitioned_lower_aux(__first, __last, __value, __pred,
-	   std::__iterator_category(__first)); }
+{
+  return __check_partitioned_lower_aux(__first, __last, __value, __pred,
+	   std::__iterator_category(__first));
+}
 
   templatetypename _ForwardIterator, typename _Tp, typename _Pred
 inline bool
@@ -458,8 +482,12 @@
 {
   while (__first != __last  !bool(__pred(__value, *__first)))
 	++__first;
-  while (__first != __last  bool(__pred(__value, *__first)))
-	++__first;
+  if (__first != __last)
+	{
+	  ++__first;
+	  while (__first != __last  bool(__pred(__value, *__first)))
+	++__first;
+	}
   return __first == __last;
 }
 
@@ -473,16 +501,20 @@
 			const _Safe_iterator_Iterator, _Sequence __last,
 			const _Tp __value, _Pred __pred,
 			std::random_access_iterator_tag __tag)
-{ return __check_partitioned_upper_aux(__first.base(), 

[PATCH 1/2] m32c: Don't use set_optab_handler

2012-08-01 Thread Richard Henderson
Committed after a build completed.


r~


* config/m32c/m32c.c (TARGET_INIT_LIBFUNCS): Remove.
(m32c_init_libfuncs): Remove.
* config/m32c/cond.md (cstoreQHPSI4_16): Rename from cstoreQHPSI4.
(cstoreQHPSI4): New expander.
 
diff --git a/gcc/config/m32c/cond.md b/gcc/config/m32c/cond.md
index c751070..5886a7d 100644
--- a/gcc/config/m32c/cond.md
+++ b/gcc/config/m32c/cond.md
@@ -152,14 +152,31 @@
 
 ;; These are the pre-split patterns for the conditional sets.
 
-(define_insn_and_split cstoremode4
+(define_expand cstoremode4
+  [(set (match_operand:QI 0 register_operand)
+   (match_operator:QI 1 ordered_comparison_operator
+[(match_operand:QHPSI 2 mra_operand)
+ (match_operand:QHPSI 3 mrai_operand)]))]
+  
+{
+  if (TARGET_A24)
+{
+  rtx o = gen_reg_rtx (HImode);
+  emit_insn (gen_cstoremode4_24 (o, operands[1],
+  operands[2], operands[3]));
+  emit_move_insn (operands[0], gen_lowpart (QImode, o));
+  DONE;
+}
+})
+
+(define_insn_and_split *cstoremode4_16
   [(set (match_operand:QI 0 register_operand =Rqi)
(match_operator:QI 1 ordered_comparison_operator
 [(match_operand:QHPSI 2 mra_operand RraSd)
  (match_operand:QHPSI 3 mrai_operand RraSdi)]))]
   TARGET_A16
   #
-  reload_completed
+   reload_completed
   [(set (reg:CC FLG_REGNO)
(compare (match_dup 2)
 (match_dup 3)))
@@ -176,7 +193,7 @@
  (match_operand:QHPSI 3 mrai_operand RraSdi)]))]
   TARGET_A24
   #
-  reload_completed
+   reload_completed
   [(set (reg:CC FLG_REGNO)
(compare (match_dup 2)
 (match_dup 3)))
diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c
index 79b03fa..878be09 100644
--- a/gcc/config/m32c/m32c.c
+++ b/gcc/config/m32c/m32c.c
@@ -1857,25 +1857,6 @@ m32c_trampoline_init (rtx m_tramp, tree fndecl, rtx 
chainval)
 #undef A0
 }
 
-/* Implicit Calls to Library Routines */
-
-#undef TARGET_INIT_LIBFUNCS
-#define TARGET_INIT_LIBFUNCS m32c_init_libfuncs
-static void
-m32c_init_libfuncs (void)
-{
-  /* We do this because the M32C has an HImode operand, but the
- M16C has an 8-bit operand.  Since gcc looks at the match data
- and not the expanded rtl, we have to reset the optab so that
- the right modes are found. */
-  if (TARGET_A24)
-{
-  set_optab_handler (cstore_optab, QImode, CODE_FOR_cstoreqi4_24);
-  set_optab_handler (cstore_optab, HImode, CODE_FOR_cstorehi4_24);
-  set_optab_handler (cstore_optab, PSImode, CODE_FOR_cstorepsi4_24);
-}
-}
-
 /* Addressing Modes */
 
 /* The r8c/m32c family supports a wide range of non-orthogonal
-- 
1.7.7.6



[PATCH 2/2] Allow MODE_PARTIAL_INT in expmed costs

2012-08-01 Thread Richard Henderson
Testing on m32c reveals that we've been asking for cost of
conversion from MODE_PARTIAL_INT.  We hadn't actually been
initializing those costs, mind.

I'm not only allowing the query, but initializing them too.

Committed after testing on x86_64 and m32c.


r~


* expmed.h (NUM_MODE_PARTIAL_INT): New.
(NUM_MODE_VECTOR_INT, NUM_MODE_IP_INT, NUM_MODE_IPV_INT): New.
(struct expmed_op_cheap): Size one array on NUM_MODE_IPV_INT.
(struct expmed_op_costs): Likewise.
(struct target_expmed): Size x_convert_cost on NUM_MODE_IP_INT.
(expmed_mode_index): New.
(expmed_op_cheap_ptr, expmed_op_cost_ptr): Use expmed_mode_index.
(convert_cost_ptr): Likewise.
* expmed.c (struct init_expmed_rtl): Rename convert to trunc.
(init_expmed_one_conv): Split out from ...
(init_expmed_one_mode): ... here.  Iterate conversions over
partial integer modes too.
(init_expmed): Iterate over partial integer modes too.

diff --git a/gcc/expmed.c b/gcc/expmed.c
index 1fe0034..d91d8f1 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -101,7 +101,6 @@ struct init_expmed_rtl
   struct rtx_def mult; rtunion mult_fld1;
   struct rtx_def sdiv; rtunion sdiv_fld1;
   struct rtx_def udiv; rtunion udiv_fld1;
-  struct rtx_def zext;
   struct rtx_def sdiv_32;  rtunion sdiv_32_fld1;
   struct rtx_def smod_32;  rtunion smod_32_fld1;
   struct rtx_def wide_mult;rtunion wide_mult_fld1;
@@ -112,13 +111,36 @@ struct init_expmed_rtl
   struct rtx_def shift_add;rtunion shift_add_fld1;
   struct rtx_def shift_sub0;   rtunion shift_sub0_fld1;
   struct rtx_def shift_sub1;   rtunion shift_sub1_fld1;
-  struct rtx_def convert;
+  struct rtx_def zext;
+  struct rtx_def trunc;
 
   rtx pow2[MAX_BITS_PER_WORD];
   rtx cint[MAX_BITS_PER_WORD];
 };
 
 static void
+init_expmed_one_conv (struct init_expmed_rtl *all, enum machine_mode to_mode,
+ enum machine_mode from_mode, bool speed)
+{
+  int to_size, from_size;
+  rtx which;
+
+  /* We're given no information about the true size of a partial integer,
+ only the size of the full integer it requires for storage.  For
+ comparison purposes here, reduce the bit size by one in that case.  */
+  to_size = (GET_MODE_BITSIZE (to_mode)
+- (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT));
+  from_size = (GET_MODE_BITSIZE (from_mode)
+  - (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT));
+  
+  /* Assume cost of zero-extend and sign-extend is the same.  */
+  which = (to_size  from_size ? all-trunc : all-zext);
+
+  PUT_MODE (all-reg, from_mode);
+  set_convert_cost (to_mode, from_mode, speed, set_src_cost (which, speed));
+}
+
+static void
 init_expmed_one_mode (struct init_expmed_rtl *all,
  enum machine_mode mode, int speed)
 {
@@ -141,7 +163,8 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
   PUT_MODE (all-shift_add, mode);
   PUT_MODE (all-shift_sub0, mode);
   PUT_MODE (all-shift_sub1, mode);
-  PUT_MODE (all-convert, mode);
+  PUT_MODE (all-zext, mode);
+  PUT_MODE (all-trunc, mode);
 
   set_add_cost (speed, mode, set_src_cost (all-plus, speed));
   set_neg_cost (speed, mode, set_src_cost (all-neg, speed));
@@ -176,8 +199,13 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
 
   if (SCALAR_INT_MODE_P (mode))
 {
-  enum machine_mode wider_mode = GET_MODE_WIDER_MODE (mode);
-
+  for (mode_from = MIN_MODE_INT; mode_from = MAX_MODE_INT;
+  mode_from = (enum machine_mode)(mode_from + 1))
+   init_expmed_one_conv (all, mode, mode_from, speed);
+}
+  if (GET_MODE_CLASS (mode) == MODE_INT)
+{
+  enum machine_mode  wider_mode = GET_MODE_WIDER_MODE (mode);
   if (wider_mode != VOIDmode)
{
  PUT_MODE (all-zext, wider_mode);
@@ -185,33 +213,11 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
  PUT_MODE (all-wide_lshr, wider_mode);
  XEXP (all-wide_lshr, 1) = GEN_INT (mode_bitsize);
 
- set_mul_widen_cost (speed, wider_mode, set_src_cost (all-wide_mult, 
speed));
- set_mul_highpart_cost (speed, mode, set_src_cost (all-wide_trunc, 
speed));
+ set_mul_widen_cost (speed, wider_mode,
+ set_src_cost (all-wide_mult, speed));
+ set_mul_highpart_cost (speed, mode,
+set_src_cost (all-wide_trunc, speed));
}
-
-  for (mode_from = GET_CLASS_NARROWEST_MODE (MODE_INT);
-  mode_from != VOIDmode;
-  mode_from = GET_MODE_WIDER_MODE (mode_from))
-   if (mode != mode_from)
- {
-   unsigned short size_to = GET_MODE_SIZE (mode);
-   unsigned short size_from = GET_MODE_SIZE (mode_from);
-   if (size_to  size_from)
- {
-   PUT_CODE (all-convert, TRUNCATE);
-   PUT_MODE (all-reg, mode_from);
-   set_convert_cost (mode, mode_from, speed,
- set_src_cost 

[PATCH] Fix ARM constant-pool layout calculations under -falign-labels

2012-08-01 Thread Roland McGrath
Using e.g. -falign-labels=16 on ARM can confuse the constant-pool layout
code such that it places pool entries too far away from their referring
instructions.  This change seems to fix it.

I don't have a small test case, only a large one, which I haven't actually
tried to get to reproduce on any vanilla ARM target.  But the logic of the
change seems straightforward and sound.


Thanks,
Roland


2012-08-01  Roland McGrath  mcgra...@google.com

* config/arm/arm.c (get_label_padding): Use align_labels as minimum.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 701ab4c..9bdb52c 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -12384,6 +12384,7 @@ get_label_padding (rtx label)
   HOST_WIDE_INT align, min_insn_size;

   align = 1  label_to_alignment (label);
+  align = MAX (align, align_labels);
   min_insn_size = TARGET_THUMB ? 2 : 4;
   return align  min_insn_size ? align - min_insn_size : 0;
 }


Re: [PATCH 2/2] Allow MODE_PARTIAL_INT in expmed costs

2012-08-01 Thread DJ Delorie

 Testing on m32c reveals that we've been asking for cost of
 conversion from MODE_PARTIAL_INT.  We hadn't actually been
 initializing those costs, mind.

Ah, ignore my previous email in the m32c thread then ;-)


[PATCH, MIPS] 74k madd scheduler tweaks

2012-08-01 Thread Sandra Loosemore
The existing scheduler bypass information for madd on the 74k uses some 
bits copied from the 24k, and is not quite correct.  This patch is based 
on one originally sent to us by MIPS and has been present in our local 
source base for years.  I've confirmed that we are legally allowed to 
contribute this to the FSF; ok for mainline?


-Sandra

2012-08-01  Sandra Loosemore  san...@codesourcery.com
Maxim Kuvyrkov  ma...@codesourcery.com
Julian Brown  jul...@codesourcery.com
MIPS Technologies, Inc.

* config/mips/74k.md (r74k_int_mult, r74k_int_madd): Don't use
mips_linked_madd_p for bypasses.
(r74k_int_mul3): Use mips_mult_madd_chain_bypass_p for bypass.
* config/mips/mips.c (mips_mult_madd_chain_bypass_p): New.
* config/mips/mips-protos.h (mips_mult_madd_chain_bypass_p): Add
prototype.


Index: gcc/config/mips/74k.md
===
--- gcc/config/mips/74k.md	(revision 189988)
+++ gcc/config/mips/74k.md	(working copy)
@@ -168,10 +168,11 @@
 ;; mult/madd/msub-int_mfhilo  : 4 cycles (default)
 ;; mult-madd/msub : 1 cycles
 ;; madd/msub-madd/msub: 1 cycles
-(define_bypass 1 r74k_int_mult,r74k_int_mul3 r74k_int_madd
-  mips_linked_madd_p)
-(define_bypass 1 r74k_int_madd r74k_int_madd
-  mips_linked_madd_p)
+(define_bypass 1 r74k_int_mult r74k_int_madd)
+(define_bypass 1 r74k_int_madd r74k_int_madd)
+
+(define_bypass 1 r74k_int_mul3 r74k_int_madd
+  mips_mult_madd_chain_bypass_p)
 
 ;; --
 ;; Floating Point Instructions
Index: gcc/config/mips/mips-protos.h
===
--- gcc/config/mips/mips-protos.h	(revision 189988)
+++ gcc/config/mips/mips-protos.h	(working copy)
@@ -296,6 +296,7 @@ extern unsigned int mips_sync_loop_insns
 extern const char *mips_output_division (const char *, rtx *);
 extern unsigned int mips_hard_regno_nregs (int, enum machine_mode);
 extern bool mips_linked_madd_p (rtx, rtx);
+extern bool mips_mult_madd_chain_bypass_p (rtx, rtx);
 extern bool mips_store_data_bypass_p (rtx, rtx);
 extern rtx mips_prefetch_cookie (rtx, rtx);
 
Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c	(revision 189988)
+++ gcc/config/mips/mips.c	(working copy)
@@ -12392,6 +12392,18 @@ mips_linked_madd_p (rtx out_insn, rtx in
   return false;
 }
 
+/* Helper function for 74k; returns true to enable the chained mult/madd
+   bypass.  */
+bool
+mips_mult_madd_chain_bypass_p (rtx out_insn ATTRIBUTE_UNUSED,
+			   rtx in_insn ATTRIBUTE_UNUSED)
+{
+  if (reload_completed)
+return false;
+  else
+return true;
+}
+
 /* True if the dependency between OUT_INSN and IN_INSN is on the store
data rather than the address.  We need this because the cprestore
pattern is type store, but is defined using an UNSPEC_VOLATILE,


Re: [PATCH 1/2] m32c: Don't use set_optab_handler

2012-08-01 Thread DJ Delorie

I tried to test this, but newlib won't build (looks unrelated).  The
failure is this assert in expmed.h:


  gcc_assert (to_mode = MIN_MODE_INT
   to_mode = MAX_MODE_INT
   from_mode = MIN_MODE_INT
   from_mode = MAX_MODE_INT);

which can't possibly work on any platform with partial int modes
(PSImode) because the P*modes are enumerated *after* the regular
integer modes, so PSImode's enum value is higher than TImode
(MAX_MODE_INT for m32c).  Should there be a range check for
MIN,MAX_MODE_PARTIAL_INT as well?

enum machine_mode
{
  VOIDmode,/* machmode.def:173 */
  BLKmode, /* machmode.def:177 */
  CCmode,  /* machmode.def:205 */
  BImode,  /* machmode.def:180 */
  QImode,  /* machmode.def:185 */
  HImode,  /* machmode.def:186 */
  SImode,  /* machmode.def:187 */
  DImode,  /* machmode.def:188 */
  TImode,  /* machmode.def:189 */
  PSImode, /* config/m32c/m32c-modes.def:26 */


m32c-elf-gcc -B/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/newlib/ -isystem 
/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/newlib/targ-include -isystem 
/greed/dj/m32c/newlib/src/newlib/libc/include 
-B/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/libgloss/m32c 
-L/greed/dj/m32c/newlib/m32c-elf/m32c-elf/m32cm/libgloss/libnosys 
-L/greed/dj/m32c/newlib/src/libgloss/m32c  -mcpu=m32cm 
-DPACKAGE_NAME=\newlib\ -DPACKAGE_TARNAME=\newlib\ 
-DPACKAGE_VERSION=\1.20.0\ -DPACKAGE_STRING=\newlib\ 1.20.0\ 
-DPACKAGE_BUGREPORT=\\ -DPACKAGE_URL=\\ -I. 
-I../../../../../../src/newlib/libc/stdio -O1 -DPREFER_SIZE_OVER_SPEED 
-DSMALL_MEMORY -DMISSING_SYSCALL_NAMES -DABORT_PROVIDED -fno-builtin  -g 
-O2 -fshort-enums -DSTRING_ONLY -c 
../../../../../../src/newlib/libc/stdio/vfprintf.c -o lib_a-svfprintf.o
In file included from ../../../../../../src/newlib/libc/stdio/vfprintf.c:151:0:
../../../../../../src/newlib/libc/stdio/vfprintf.c: In function '_svfprintf_r':
../../../../../../src/newlib/libc/stdio/vfprintf.c:137:24: internal compiler 
error: in convert_cost_ptr, at expmed.h:639
 #   define _VFPRINTF_R _svfprintf_r
^
../../../../../../src/newlib/libc/stdio/vfprintf.c:541:8: note: in expansion of 
macro '_VFPRINTF_R'
 _DEFUN(_VFPRINTF_R, (data, fp, fmt0, ap),
^
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html for instructions.
make: *** [lib_a-svfprintf.o] Error 1


dj@greed pts/3 ~/m32c/gcc/m32c-elf/gcc
$ gdb cc1
GNU gdb (GDB) Red Hat Enterprise Linux (7.1-29.el6_0.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as x86_64-redhat-linux-gnu.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /greed/dj/m32c/gcc/m32c-elf/gcc/cc1...done.
Breakpoint 1 at 0xb25eb0: file ../../gcc/gcc/diagnostic.c, line 1010.
Breakpoint 2 at 0xb25de0: file ../../gcc/gcc/diagnostic.c, line 951.
Breakpoint 3 at 0x45f728
Breakpoint 4 at 0x45f5e8

[ gdb ] r -fpreprocessed vfprintf.i -quiet -dumpbase vfprintf.c -mcpu=m32cm 
-auxbase-strip lib_a-svfprintf.o -g -O1 -O2 -version -fno-builtin -fshort-enums 
-o vfprintf.s
GNU C (GCC) version 4.8.0 20120731 (experimental) [trunk revision 190021] 
(m32c-elf)
compiled by GNU C version 4.4.6 20110731 (Red Hat 4.4.6-3), GMP version 
4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.8.0 20120731 (experimental) [trunk revision 190021] 
(m32c-elf)
compiled by GNU C version 4.4.6 20110731 (Red Hat 4.4.6-3), GMP version 
4.3.1, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 827bbd6609eec0d0ea9ef658ea29c21b

Breakpoint 1, fancy_abort (file=0xc3f911 ../../gcc/gcc/expmed.h, line=639, 
function=0xc40340 convert_cost_ptr)
at ../../gcc/gcc/diagnostic.c:1010
1010{
Missing separate debuginfos, use: debuginfo-install 
glibc-2.12-1.47.el6_2.5.x86_64

[ gdb ] up
#1  0x00aa9ffd in convert_cost_ptr (to_mode=SImode, from_mode=PSImode, 
speed=1 '\001')
at ../../gcc/gcc/expmed.h:636
636   gcc_assert (to_mode = MIN_MODE_INT

[ gdb ] where
#0  fancy_abort (file=0xc3f911 ../../gcc/gcc/expmed.h, line=639, 
function=0xc40340 convert_cost_ptr)
at ../../gcc/gcc/diagnostic.c:1010
#1  0x00aa9ffd in convert_cost_ptr (to_mode=SImode, from_mode=PSImode, 
speed=1 '\001')
at ../../gcc/gcc/expmed.h:636
#2  0x00aaa08a in convert_cost (to_mode=SImode, from_mode=PSImode, 
speed=1 '\001')
at ../../gcc/gcc/expmed.h:663

Re: [PATCH][7/n] into-SSA TLC

2012-08-01 Thread Tom de Vries
On 01/08/12 10:47, Richard Guenther wrote:
   * tree-ssa-tail-merge.c (release_last_vdef): Remove.
   (replace_block_by): Adjust.
   (tail_merge_optimize): Use mark_virtual_operands_for_renaming.

Richard,

this caused PR50672 to trigger again.

Thanks,
- Tom


Re: [PATCH 0/2] Convert s390 to atomic optabs, v2

2012-08-01 Thread Richard Henderson
Please try this as a followup to the previous two patches.
That should clean up the mistake with the insv change.


r~
commit 6b07a31943bcbca2a4f6fae707cf3d7ae283d4dc
Author: Richard Henderson r...@redhat.com
Date:   Wed Aug 1 16:10:37 2012 -0700

fixup insv

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 8259e2b..35c7fb5 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -4551,7 +4551,8 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
   int bitsize = INTVAL (op1);
   int bitpos = INTVAL (op2);
   enum machine_mode mode = GET_MODE (dest);
-  enum machine_mode smode = smallest_mode_for_size (bitsize, MODE_INT);
+  enum machine_mode smode;
+  int smode_bsize, mode_bsize;
   rtx op, clobber;
 
   /* Generate INSERT IMMEDIATE (IILL et al).  */
@@ -4587,6 +4588,10 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
   return true;
 }
 
+  smode = smallest_mode_for_size (bitsize, MODE_INT);
+  smode_bsize = GET_MODE_BITSIZE (smode);
+  mode_bsize = GET_MODE_BITSIZE (mode);
+
   /* Generate STORE CHARACTERS UNDER MASK (STCM et al).  */
   if (bitpos == 0
(bitsize % BITS_PER_UNIT) == 0
@@ -4595,7 +4600,7 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
  || const_int_operand (src, VOIDmode)))
 {
   /* Emit standard pattern if possible.  */
-  if (GET_MODE_BITSIZE (smode) == bitsize)
+  if (smode_bsize == bitsize)
{
  emit_move_insn (adjust_address (dest, smode, 0),
  gen_lowpart (smode, src));
@@ -4608,7 +4613,7 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
  int size = bitsize / BITS_PER_UNIT;
  rtx src_mem = adjust_address (force_const_mem (word_mode, src),
BLKmode,
-   GET_MODE_SIZE (word_mode) - size);
+   UNITS_PER_WORD - size);
 
  dest = adjust_address (dest, BLKmode, 0);
  set_mem_size (dest, size);
@@ -4619,22 +4624,22 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
   /* (set (ze (mem)) (reg)).  */
   else if (register_operand (src, word_mode))
{
- if (bitsize = GET_MODE_BITSIZE (SImode))
+ if (bitsize = 32)
emit_move_insn (gen_rtx_ZERO_EXTRACT (word_mode, dest, op1,
  const0_rtx), src);
  else
{
  /* Emit st,stcmh sequence.  */
- int stcmh_width = bitsize - GET_MODE_BITSIZE (SImode);
+ int stcmh_width = bitsize - 32;
  int size = stcmh_width / BITS_PER_UNIT;
 
  emit_move_insn (adjust_address (dest, SImode, size),
  gen_lowpart (SImode, src));
  set_mem_size (dest, size);
- emit_move_insn (gen_rtx_ZERO_EXTRACT (word_mode, dest, GEN_INT
-   (stcmh_width), const0_rtx),
- gen_rtx_LSHIFTRT (word_mode, src, GEN_INT
-   (GET_MODE_BITSIZE (SImode;
+ emit_move_insn (gen_rtx_ZERO_EXTRACT (word_mode, dest,
+   GEN_INT (stcmh_width),
+   const0_rtx),
+ gen_rtx_LSHIFTRT (word_mode, src, GEN_INT (32)));
}
  return true;
}
@@ -4649,7 +4654,7 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src)
register_operand (dest, mode))
 {
   /* Emit a strict_low_part pattern if possible.  */
-  if (bitpos == 0  GET_MODE_BITSIZE (smode) == bitsize)
+  if (smode_bsize == bitsize  bitpos == mode_bsize - smode_bsize)
{
  op = gen_rtx_STRICT_LOW_PART (VOIDmode, gen_lowpart (smode, dest));
  op = gen_rtx_SET (VOIDmode, op, gen_lowpart (smode, src));
@@ -4728,7 +4733,12 @@ init_alignment_context (struct alignment_context *ac, 
rtx mem,
   ac-aligned = (MEM_ALIGN (mem) = GET_MODE_BITSIZE (SImode));
 
   if (ac-aligned)
-ac-memsi = adjust_address (mem, SImode, 0); /* Memory is aligned.  */
+{
+  ac-memsi = adjust_address (mem, SImode, 0); /* Memory is aligned.  */
+  ac-shift = const0_rtx;
+  ac-modemask = GEN_INT (GET_MODE_MASK (mode));
+  ac-modemaski = GEN_INT (~GET_MODE_MASK (mode));
+}
   else
 {
   /* Alignment is unknown.  */
@@ -4755,15 +4765,17 @@ init_alignment_context (struct alignment_context *ac, 
rtx mem,
   ac-shift = expand_simple_binop (SImode, MINUS, ac-shift, byteoffset,
  NULL_RTX, 1, OPTAB_DIRECT);
 
+  /* Shift is the byte count, but we need the bitcount.  */
+  ac-shift = expand_simple_binop (SImode, ASHIFT, ac-shift, GEN_INT (3),
+  NULL_RTX, 1, OPTAB_DIRECT);
+
+  /* Calculate masks.  */
+  ac-modemask = expand_simple_binop 

Re: PING [PATCH] Fix PR libstdc++/54036, problem negating DFP NaNs

2012-08-01 Thread Peter Bergner
On Wed, 1 Aug 2012 08:24:48 -0700 Janis Johnson wrote:
 On 08/01/2012 07:29 AM, Paolo Carlini wrote:
  On 08/01/2012 12:46 AM, Peter Bergner wrote:
  I'd like to ping the following libstdc++ DFP patch that fixes PR54036:
 
 http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00959.html
  I think the patch is essentially Ok, but I would recommend giving Janis 
  a chance to comment (say 24/48 h).
 
 It looks fine to me.
 
  Note that the patch only touches libstdc++-v3 code, thus the testcases 
  should be added to libstdc++-v3/testsuite/decimal and the patch itself 
  was missing a CC to libstdc++@.
 
 I agree.

So just to be sure, like the patch below?

Also, is this ok for the 4.6 and 4.7 release branches?


Peter


libstdc++-v3/
PR libstdc++/54036
* include/decimal/decimal.h (_DEFINE_DECIMAL_UNARY_OP): Use _Op as
a unary operator.

libstdc++-v3/testsuite/
PR libstdc++/54036
* decimal/pr54036-1.cc: New test.
* decimal/pr54036-2.cc: Likewise.
* decimal/pr54036-3.cc: Likewise.

Index: libstdc++-v3/include/decimal/decimal.h
===
--- libstdc++-v3/include/decimal/decimal.h  (revision 189599)
+++ libstdc++-v3/include/decimal/decimal.h  (working copy)
@@ -288,7 +288,7 @@
   inline _Tp operator _Op(_Tp __rhs)   \
   {\
 _Tp __tmp; \
-__tmp.__setval(0 _Op __rhs.__getval());\
+__tmp.__setval(_Op __rhs.__getval());  \
 return __tmp;  \
   }
 
Index: libstdc++-v3/testsuite/decimal/pr54036-1.cc
===
--- libstdc++-v3/testsuite/decimal/pr54036-1.cc (revision 0)
+++ libstdc++-v3/testsuite/decimal/pr54036-1.cc (revision 0)
@@ -0,0 +1,56 @@
+#include decimal/decimal
+using namespace std;
+
+decimal::decimal32
+__attribute__ ((noinline))
+my_nan32 (void)
+{
+  decimal::decimal32 z = 0;
+  decimal::decimal32 v = z/z;
+  return v;
+}
+
+decimal::decimal32
+__attribute__ ((noinline))
+my_inf32 (void)
+{
+  decimal::decimal32 o = 1;
+  decimal::decimal32 z = 0;
+  decimal::decimal32 v = o/z;
+  return v;
+}
+
+int
+main (void)
+{
+  decimal::decimal32 v;
+
+  v = my_nan32 ();
+  if (!__builtin_isnand32 (v.__getval ()))
+__builtin_abort ();
+  if (__builtin_signbitd32 (v.__getval ()))
+__builtin_abort ();
+
+  v = -v;
+
+  if (!__builtin_isnand32 (v.__getval ()))
+__builtin_abort ();
+  if (!__builtin_signbitd32 (v.__getval ()))
+__builtin_abort ();
+
+  v = my_inf32 ();
+  if (!__builtin_isinfd32 (v.__getval ()))
+__builtin_abort ();
+  if (__builtin_signbitd32 (v.__getval ()))
+__builtin_abort ();
+
+  v = -v;
+
+  if (!__builtin_isinfd32 (v.__getval ()))
+__builtin_abort ();
+  if (!__builtin_signbitd32 (v.__getval ()))
+__builtin_abort ();
+
+  return 0;
+}
+
Index: libstdc++-v3/testsuite/decimal/pr54036-2.cc
===
--- libstdc++-v3/testsuite/decimal/pr54036-2.cc (revision 0)
+++ libstdc++-v3/testsuite/decimal/pr54036-2.cc (revision 0)
@@ -0,0 +1,56 @@
+#include decimal/decimal
+using namespace std;
+
+decimal::decimal64
+__attribute__ ((noinline))
+my_nan64 (void)
+{
+  decimal::decimal64 z = 0;
+  decimal::decimal64 v = z/z;
+  return v;
+}
+
+decimal::decimal64
+__attribute__ ((noinline))
+my_inf64 (void)
+{
+  decimal::decimal64 o = 1;
+  decimal::decimal64 z = 0;
+  decimal::decimal64 v = o/z;
+  return v;
+}
+
+int
+main (void)
+{
+  decimal::decimal64 v;
+
+  v = my_nan64 ();
+  if (!__builtin_isnand64 (v.__getval ()))
+__builtin_abort ();
+  if (__builtin_signbitd64 (v.__getval ()))
+__builtin_abort ();
+
+  v = -v;
+
+  if (!__builtin_isnand64 (v.__getval ()))
+__builtin_abort ();
+  if (!__builtin_signbitd64 (v.__getval ()))
+__builtin_abort ();
+
+  v = my_inf64 ();
+  if (!__builtin_isinfd64 (v.__getval ()))
+__builtin_abort ();
+  if (__builtin_signbitd64 (v.__getval ()))
+__builtin_abort ();
+
+  v = -v;
+
+  if (!__builtin_isinfd64 (v.__getval ()))
+__builtin_abort ();
+  if (!__builtin_signbitd64 (v.__getval ()))
+__builtin_abort ();
+
+  return 0;
+}
+
Index: libstdc++-v3/testsuite/decimal/pr54036-3.cc
===
--- libstdc++-v3/testsuite/decimal/pr54036-3.cc (revision 0)
+++ libstdc++-v3/testsuite/decimal/pr54036-3.cc (revision 0)
@@ -0,0 +1,56 @@
+#include decimal/decimal
+using namespace std;
+
+decimal::decimal128
+__attribute__ ((noinline))
+my_nan128 (void)
+{
+  decimal::decimal128 z = 0;
+  decimal::decimal128 v = z/z;
+  return v;
+}
+
+decimal::decimal128
+__attribute__ ((noinline))
+my_inf128 (void)
+{
+  decimal::decimal128 o = 1;
+  decimal::decimal128 z = 0;
+  decimal::decimal128 v = o/z;
+  return v;
+}
+
+int
+main (void)
+{
+  decimal::decimal128 v;
+
+  v = my_nan128 ();
+  if 

Re: [PR52983] eliminate autoinc from debug_insn locs

2012-08-01 Thread Alexandre Oliva
On Jul 24, 2012, Alexandre Oliva aol...@redhat.com wrote:

 Thanks.  I'm about to go on a trip for the rest of the week and I won't
 be online much, so I won't check them in now.  I will when I get back
 home, so that I'll have a better chance of dealing with any fallout.

I've just installed the 3 patches.  The first one needed updating 
to retain changes I made myself to functions moved to the new file, so
here's the updated patch.

for  gcc/ChangeLog
from  Alexandre Oliva  aol...@redhat.com

	PR debug/52983
	* valtrack.h, valtrack.c: New.
	* Makefile.in (VALTRACK_H): New.
	(OBJS): Add valtrack.o.
	(valtrack.o): New.
	(cselib.o, dce.o, df-problems.o, combine.o): Add VALTRACK_H.
	* combine.c: Include valtrack.h.
	(make_compound_operation): Publish.
	(cleanup_auto_inc_dec): Move to valtrack.c.
	(struct rtx_subst_pair, propagate_for_debug_subst): Likewise.
	(propagate_for_debug): Likewise.  Add this_basic_block parameter.
	Adjust all callers.
	* cselib.c: Include valtrack.h.
	* dce.c: Likewise.
	* df-problems.c: Likewise.
	(dead_debug_init, dead_debug_reset_uses): Move to valtrack.c.
	(dead_debug_finish, dead_debug_add): Likewise.
	(dead_debug_insert_temp): Likewise.
	* df.h (struct dead_debug_use): Move to valtrack.h.
	(struct dead_debug, enum debug_temp_where): Likewise.
	(dead_debug_init, dead_debug_reset_uses): Move to valtrack.h.
	(dead_debug_finish, dead_debug_add): Likewise.
	(dead_debug_insert_temp): Likewise.
	* rtl.h (make_compound_operation): Declare.

Index: gcc/Makefile.in
===
--- gcc/Makefile.in.orig	2012-08-01 01:29:21.523642980 -0300
+++ gcc/Makefile.in	2012-08-01 14:39:46.0 -0300
@@ -904,6 +904,7 @@ CGRAPH_H = cgraph.h $(VEC_H) $(TREE_H) $
 	cif-code.def ipa-ref.h ipa-ref-inline.h $(LINKER_PLUGIN_API_H)
 DF_H = df.h $(BITMAP_H) $(REGSET_H) sbitmap.h $(BASIC_BLOCK_H) \
 	alloc-pool.h $(TIMEVAR_H)
+VALTRACK_H = valtrack.h $(BITMAP_H) $(DF_H) $(RTL_H) $(BASIC_BLOCK_H)
 RESOURCE_H = resource.h hard-reg-set.h $(DF_H)
 DDG_H = ddg.h sbitmap.h $(DF_H)
 GCC_H = gcc.h version.h $(DIAGNOSTIC_CORE_H)
@@ -1447,6 +1448,7 @@ OBJS = \
 	tree-vectorizer.o \
 	tree-vrp.o \
 	tree.o \
+	valtrack.o \
 	value-prof.o \
 	var-tracking.o \
 	varasm.o \
@@ -2947,7 +2949,7 @@ cse.o : cse.c $(CONFIG_H) $(SYSTEM_H) co
$(DF_H) $(DBGCNT_H)
 dce.o : dce.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) $(EXCEPT_H) $(DF_H) cselib.h \
-   $(DBGCNT_H) dce.h $(TREE_PASS_H) $(DBGCNT_H) $(TM_P_H) \
+   $(DBGCNT_H) dce.h $(VALTRACK_H) $(TREE_PASS_H) $(DBGCNT_H) $(TM_P_H) \
$(EMIT_RTL_H)
 dse.o : dse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) $(TM_P_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) insn-config.h \
@@ -3039,7 +3041,7 @@ df-core.o : df-core.c $(CONFIG_H) $(SYST
 df-problems.o : df-problems.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) \
$(RTL_H) insn-config.h $(RECOG_H) $(FUNCTION_H) $(REGS_H) alloc-pool.h \
hard-reg-set.h $(BASIC_BLOCK_H) $(DF_H) $(BITMAP_H) sbitmap.h $(TIMEVAR_H) \
-   $(TM_P_H) $(TARGET_H) $(FLAGS_H) $(EXCEPT_H) dce.h vecprim.h
+   $(TM_P_H) $(TARGET_H) $(FLAGS_H) $(EXCEPT_H) dce.h vecprim.h $(VALTRACK_H)
 df-scan.o : df-scan.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) $(RTL_H) \
insn-config.h $(RECOG_H) $(FUNCTION_H) $(REGS_H) alloc-pool.h \
hard-reg-set.h $(BASIC_BLOCK_H) $(DF_H) $(BITMAP_H) sbitmap.h \
@@ -3048,6 +3050,8 @@ df-scan.o : df-scan.c $(CONFIG_H) $(SYST
 regstat.o : regstat.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TM_P_H) $(FLAGS_H) $(REGS_H) $(EXCEPT_H) hard-reg-set.h \
$(BASIC_BLOCK_H) $(TIMEVAR_H) $(DF_H)
+valtrack.o : valtrack.c $(VALTRACK_H) $(CONFIG_H) $(SYSTEM_H) \
+   coretypes.h $(TM_H) $(FUNCTION_H) $(REGS_H) $(EMIT_RTL_H)
 var-tracking.o : var-tracking.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(TREE_H) hard-reg-set.h insn-config.h reload.h $(FLAGS_H) \
$(BASIC_BLOCK_H) bitmap.h alloc-pool.h $(FIBHEAP_H) $(HASHTAB_H) \
@@ -3144,9 +3148,10 @@ et-forest.o : et-forest.c $(CONFIG_H) $(
 combine.o : combine.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(FLAGS_H) $(FUNCTION_H) insn-config.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \
rtlhooks-def.h $(BASIC_BLOCK_H) $(RECOG_H) hard-reg-set.h \
-   $(DIAGNOSTIC_CORE_H) $(TM_P_H) $(TREE_H) $(TARGET_H) $(PARAMS_H) $(OPTABS_H) \
-   insn-codes.h $(TREE_PASS_H) $(DF_H) vecprim.h $(CGRAPH_H) \
-   $(OBSTACK_H)
+   $(DIAGNOSTIC_CORE_H) $(TM_P_H) $(TREE_H) $(TARGET_H) \
+   output.h $(PARAMS_H) $(OPTABS_H) \
+   insn-codes.h $(TREE_PASS_H) $(DF_H) $(VALTRACK_H) \
+   vecprim.h $(CGRAPH_H) $(OBSTACK_H)
 reginfo.o : reginfo.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
hard-reg-set.h $(FLAGS_H) $(BASIC_BLOCK_H) addresses.h $(REGS_H) \
insn-config.h $(RECOG_H) reload.h $(DIAGNOSTIC_CORE_H) \
Index: gcc/combine.c