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

2012-08-05 Thread Richard Sandiford
For the record, I can't approve this, but...

"H.J. Lu"  writes:
> i386,md has
>
> (define_expand "extzv"
>   [(set (match_operand:SI 0 "register_operand")
> (zero_extract:SI (match_operand 1 "ext_register_operand")
>  (match_operand:SI 2 "const8_operand")
>  (match_operand:SI 3 "const8_operand")))]
>   ""
>
> and mode_for_extraction picks word_mode for operand 1 since
> its mode is VOIDmode.  This patch changes mode_for_extraction
> to return the mode of operand 1 if the pattern accepts any mode.
> I added *jcc_btsi_mask_2 since combine now tries a different
> pattern, which leads to test failures on gcc.target/i386/bt-mask-1.c
> and  gcc.target/i386/bt-mask-2.  I didn't update *jcc_btsi_mask_1
> instead since I am not sure if it is used elsewhere.  Tested on
> Linux/x86-64 and Linux/x32.  OK for trunk?

the mode of the extraction operand is defined to be word_mode
for registers (see md.texi), so that at least would need to
be updated.  But I'm not convinced that the wanted_inner_mode here:

   if (! in_dest && unsignedp
-  && mode_for_extraction (EP_extzv, -1) != MAX_MACHINE_MODE)
+  && mode_for_extraction (EP_extzv, -1, VOIDmode) != MAX_MACHINE_MODE)
 {
-  wanted_inner_reg_mode = mode_for_extraction (EP_extzv, 1);
-  pos_mode = mode_for_extraction (EP_extzv, 3);
-  extraction_mode = mode_for_extraction (EP_extzv, 0);
+  wanted_inner_reg_mode = mode_for_extraction (EP_extzv, 1,
+  inner_mode);
+  pos_mode = mode_for_extraction (EP_extzv, 3, VOIDmode);
+  extraction_mode = mode_for_extraction (EP_extzv, 0, VOIDmode);
 }

is right.  inner_mode is the mode of the thing we're extracting,
which doesn't ncessarily have anything to do with what the ext*
patterns support.

FWIW, in reply to your force_to_mode message, gen_lowpart_for_combine
looks a bit odd:

  if (omode == imode)
return x;

  /* Return identity if this is a CONST or symbolic reference.  */
  if (omode == Pmode
  && (GET_CODE (x) == CONST
  || GET_CODE (x) == SYMBOL_REF
  || GET_CODE (x) == LABEL_REF))
return x;

So if we know the modes are different, we nevertheless return the
original mode for CONST, SYMBOL_REF or LABEL_REF.  Surely the caller
isn't going to be expecting that?  If we're not prepared to change
the mode to the one that the caller asked for then I think we should
goto fail instead.

I don't know if you're hitting that or not.

Richard


RE: [PATCH, gcc/doc]: Document AMD btver2 enablement

2012-08-05 Thread Kumar, Venkataramanan
Hi Gerald,

Thank you. I committed changes as per your review comments.


Ref: http://gcc.gnu.org/viewcvs?view=revision&revision=190151

Regards,
Venkat.


> -Original Message-
> From: Gerald Pfeifer [mailto:ger...@pfeifer.com]
> Sent: Sunday, August 05, 2012 12:24 AM
> To: Kumar, Venkataramanan
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH, gcc/doc]: Document AMD btver2 enablement
> 
> On Sat, 4 Aug 2012, venkataramanan.ku...@amd.com wrote:
> > Index: gcc/doc/extend.texi
> > ===
> > +@item btver1
> > +AMD family 14h cpu.
> 
> CPU...
> 
> >  @item amdfam15h
> >  AMD family 15h CPU.
> 
> ...like you already had here. :-)
> 
> > +@item btver2
> > +AMD family 16h cpu.
> 
> CPU.
> 
> > +@item btver2
> > +CPUs based on AMD Family 16h cores with x86-64 instruction set support.
> (This
> > +supersets MOVBE, F16C, BMI, AVX, PCL_MUL, AES, SSE4.2, SSE4.1, CX16, ABM,
> > +SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.)
> 
> I could not find "supsersets" as a verb in my dictionary: how
> about "includes"?
> 
> And I'd omit the parentheses around the second sentence, but this is
> just a preference on my side; feel free to keep them if you prefer.
> 
> Okay with these changes.
> 
> Thanks,
> Gerald




Re: [libiberty] add obstack macros (was Re: PR #53525 - track-macro-expansion performance regression)

2012-08-05 Thread Dimitrios Apostolou

On Sat, 4 Aug 2012, Ian Lance Taylor wrote:


On Fri, 3 Aug 2012, Ian Lance Taylor wrote:


I'm not sure where you are looking.  I only see one call to
_obstack_begin in the gcc directory, and it could easily be replaced
with a call to obstack_specify_allocation instead.


In libcpp/ mostly, but only 4 cases so that's not too many, I can change 
those with obstack_init/begin.



+#define XOBFINISH(O, PT)   ((PT) obstack_finish ((O)))



For XOBNEW, etc., we use (T *) rather than (PT).  Using (PT) seems
error-probe--it's the only use of the obstack with a different type
parameter.  Why not use T rather than PT here, and return (T *)?



I'd have to change many (about 60) occurences of XOBFINISH if I change that.
I'd go for it if I was sure it's what we want, it can be a separate patch
later on.


I'm sorry to ask you to change a lot of code, but it simply doesn't
make sense to me to have all but one macro take the type as an
argument, and have one macro take a pointer to the type.  They really
have to be consistent.


No problem, if anyone else doesn't object I'll change those (in a second 
patch, right?).



Thanks,
Dimitris



[Patch, Fortran] PR 35831: checking for dummy procedures

2012-08-05 Thread Janus Weil
Hi all,

here is a patch for a rather old PR, which deals with correctness
checking for several cases, such as:
1) dummy procedures
2) proc-ptr assignments
3) type-bound procedure overloading

The patch adds a new function 'check_result_characteristics' to do
various checks on function results. This is largely analogous to
'check_dummy_characteristics'. In both of them, there are still a few
attributes left to check, which I may add in a follow-up patch. Also I
had to disable the warning for cases where we can not finally
determine whether the string length or shape expressions are equal.
The treatment for those cases should be improved at some point, or one
should think about re-enabling the warnings.

Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus



2012-08-05  Janus Weil  

PR fortran/35831
* interface.c (check_result_characteristics): New function, which checks
the characteristics of function results.
(gfc_compare_interfaces,gfc_check_typebound_override): Call it.

2012-08-05  Janus Weil  

PR fortran/35831
* gfortran.dg/dummy_procedure_5.f90: Modified.
* gfortran.dg/dummy_procedure_8.f90: New.
* gfortran.dg/interface_26.f90: Modified.
* gfortran.dg/proc_ptr_11.f90: Modified.
* gfortran.dg/proc_ptr_15.f90: Modified.
* gfortran.dg/proc_ptr_result_5.f90: Modified.
* gfortran.dg/typebound_override_1.f90: Modified.
* gfortran.dg/typebound_proc_6.f03: Modified.


pr35831.diff
Description: Binary data


dummy_procedure_8.f90
Description: Binary data


Re: [C++ Patch] PR 54165

2012-08-05 Thread Jason Merrill

OK.

Jason


Re: [C++ Patch] PR 54161

2012-08-05 Thread Jason Merrill
On reflection, I think I prefer the status quo.  As long as the pedwarn 
is on by default, I don't mind letting people disable it with 
-Wno-pointer-arith.


Jason


[PATCH] Remove introduction of undefined overflow in emit_case_bit_test.

2012-08-05 Thread Tom de Vries
Richard,

the code in emit_case_bit_tests currently introduces a MINUS_EXPR in signed type
(without checking if signed types wrap or not), which could mean introduction of
undefined overflow.

This patch fixes this problem by performing the MINUS_EXPR in an unsigned type.

Doing so also enables the vrp optimization for the test-case.

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

OK for trunk?

Thanks,
- Tom


2012-08-06  Tom de Vries  

* tree-switch-conversion.c (emit_case_bit_tests): Generate MINUS_EXPR in
unsigned type.

* gcc.dg/tree-ssa/vrp78.c: New test.
Index: gcc/tree-switch-conversion.c
===
--- gcc/tree-switch-conversion.c (revision 190139)
+++ gcc/tree-switch-conversion.c (working copy)
@@ -384,10 +384,10 @@ emit_case_bit_tests (gimple swtch, tree
 
   gsi = gsi_last_bb (switch_bb);
 
-  /* idx = (unsigned) (x - minval) */
-  idx = fold_build2 (MINUS_EXPR, index_type, index_expr,
-		 fold_convert (index_type, minval));
-  idx = fold_convert (unsigned_index_type, idx);
+  /* idx = (unsigned)x - minval */
+  idx = fold_convert (unsigned_index_type, index_expr);
+  idx = fold_build2 (MINUS_EXPR, unsigned_index_type, idx,
+		 fold_convert (unsigned_index_type, minval));
   idx = force_gimple_operand_gsi (&gsi, idx,
   /*simple=*/true, NULL_TREE,
   /*before=*/true, GSI_SAME_STMT);
Index: gcc/testsuite/gcc.dg/tree-ssa/vrp78.c
===
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp78.c (revision 0)
@@ -0,0 +1,34 @@
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+
+/* Based on f3 from vrp63.c, but with switch instead of if-chain.  */
+
+extern void link_error (void);
+
+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;
+	}
+}
+}
+
+int
+main ()
+{
+  return 0;
+}


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

2012-08-05 Thread H.J. Lu
On Thu, Aug 2, 2012 at 1:12 AM, Richard Guenther  wrote:
> On Wed, 1 Aug 2012, Richard Guenther wrote:
>
>>
>> This is the combined patch, ontop of 2a and 2b this removes all
>> gimple_referenced_vars and add_referenced_vars calls.
>>
>> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>>
>> GCC is a better place w/o referenced vars ;)
>
> Re-bootstrapped and tested on x86_64-unknown-linux-gnu ontop of
> what has been actually committed.  Adjusted a few dump-scans in
> points-to analysis.  This will also result in
>
> FAIL: gcc.dg/pr52558-1.c scan-tree-dump-times lim1 "MEM count_lsm..
> count_lsm_fl
> ag" 1
> FAIL: gcc.dg/pr52558-2.c scan-tree-dump-times lim1 "MEM.*g_2_lsm_flag" 1
> FAIL: gcc.dg/tm/reg-promotion.c scan-tree-dump-times lim1 "MEM count_lsm..
> count
> _lsm_flag" 1
>
> as I could not figure out what to replace the previously senseless
> dump scanning with.  There are no changelog entries for the addition
> of these testcases, so I'm not sure whom to nag.  gcc.dg/pr52558-1.c
> was committed by Aldyh at least.  Aldyh - these tests scan for random
> strings and in no way guarantee that the store remains to be executed
> conditional only.  Maybe you should amend the lim dump in case you
> want to only ensure that the lim transform uses conditional replacement?
>
> Committed to trunk.
>
> Richard.
>
> 2012-08-02  Richard Guenther  
>
> * tree-dfa.c (referenced_var_lookup): Remove.
> (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.h (referenced_var_lookup): Likewise.
> (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-flow-inline.h (gimple_referenced_vars): Remove.
> (first_referenced_var): Likewise.
> (end_referenced_vars_p): Likewise.
> (next_referenced_var): 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.
> (pass_build_ssa): Do not require PROP_referenced_vars.
> * tree-ssa.c (target_for_debug_bind): Virtual operands are
> not suitable, but all register type vars are.
> (init_tree_ssa): Do not allocate referenced vars.
> (delete_tree_ssa): Do not free referenced vars.
> * cgraphunit.c (init_lowered_empty_function): Do not set
> PROP_referenced_vars.
> (assemble_thunk): Do not add referenced vars.
> * gimple-fold.c (canonicalize_constructor_val): Likewise.
> (gimplify_and_update_call_from_tree): Likewise.
> * gimple-streamer-in.c (input_bb): Likewise.
> * passes.c (init_optimization_passes): Do not run
> pass_referenced_vars.
> (dump_properties): Do not dump PROP_referenced_vars.
> * tree-inline.c (remap_decl): Do not add referenced vars.
> (remap_gimple_op_r): Likewise.
> (copy_tree_body_r): Likewise.
> (copy_bb): Likewise.
> (setup_one_parameter): Likewise.
> (declare_return_variable): Likewise.
> (copy_decl_for_dup_finish): Likewise.
> (copy_arguments_for_versioning): Likewise.
> (tree_function_versioning): Likewise.
> * 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-cfg.c (replace_ssa_name): Do not add referenced vars.
> (move_stmt_op): Likewise.
> * tree-ssa-operands.c (create_vop_var): Likewise.
> * gimple-low.c (record_vars_into): Likewise.
> * gimplify.c (gimple_regimplify_operands): Likewise.
> (force_gimple_operand_1): Likewise.
> * omp-low.

Re: [C++ Patch] PR 54161

2012-08-05 Thread Paolo Carlini

On 08/06/2012 01:29 AM, Jason Merrill wrote:
On reflection, I think I prefer the status quo.  As long as the 
pedwarn is on by default, I don't mind letting people disable it with 
-Wno-pointer-arith.

I hear you. Then, let's just close the PR.

Thanks!
Paolo.


Re: [libiberty] add obstack macros (was Re: PR #53525 - track-macro-expansion performance regression)

2012-08-05 Thread Ian Lance Taylor
On Sun, Aug 5, 2012 at 11:44 AM, Dimitrios Apostolou  wrote:
>
> No problem, if anyone else doesn't object I'll change those (in a second
> patch, right?).

Can you please resend the patch you propose to check into mainline?  Thanks.

Ian


[PATCH] put exception tables for comdat functions in comdat, too

2012-08-05 Thread Sandra Loosemore
For C++ functions that are emitted to a comdat section (template 
instantiations and the like), the corresponding exception handling 
information is presently being emitted to the non-comdat 
.gcc_except_table section.  This means that you can end up with multiple 
copies of the exception tables in the executable from different objects, 
even though the linker can remove all but one copy of the function it 
goes with.


We do have a test case for this, but I don't know how to mash it into 
the Dejagnu framework.  My hand-testing involved comparing the 
before/after output of readelf to see the new exception table sections 
in the group, and verifying that the size of the executable is smaller 
with the patch than without it.


Otherwise, I bootstrapped and regression tested on x86_64, and also 
tested on mipsisa32r2-sde-elf since I had an existing build tree for 
that set up.  This patch has also been present in our local source base 
for a while so it's been well-tested in that context.  OK for mainline?


-Sandra


2012-08-04  Paul Brook  
Sandra Loosemore  

gcc/
* except.c (switch_to_exception_section): Place tables for
DECL_ONE_ONLY functions in comdat groups.

Index: gcc/except.c
===
--- gcc/except.c	(revision 190149)
+++ gcc/except.c	(working copy)
@@ -2777,11 +2777,16 @@ switch_to_exception_section (const char 
 	flags = SECTION_WRITE;
 
 #ifdef HAVE_LD_EH_GC_SECTIONS
-	  if (flag_function_sections)
+	  if (flag_function_sections
+	  || (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP))
 	{
 	  char *section_name = XNEWVEC (char, strlen (fnname) + 32);
+	  /* The EH table must match the code section, so only mark
+		 it linkonce if we have COMDAT groups to tie them together.  */
+	  if (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP)
+		flags |= SECTION_LINKONCE;
 	  sprintf (section_name, ".gcc_except_table.%s", fnname);
-	  s = get_section (section_name, flags, NULL);
+	  s = get_section (section_name, flags, current_function_decl);
 	  free (section_name);
 	}
 	  else


Re: [PATCH] Improve ifcombine (PR 52005)

2012-08-05 Thread Marc Glisse


Hello,

do you have an opinion on this patch (available here:
http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01352.html
) ?

Or should we go back to my old patch, or Andrew's patch?

On Thu, 26 Jul 2012, Marc Glisse wrote:


Hello,

here is a new version of the ifcombine patch, which handles Andrew's examples 
(though only with -O2 for one of them, same_phi_args_p returns false 
otherwise).


Note that the new patch never calls maybe_fold_or_comparisons, only 
maybe_fold_and_comparisons. It would be possible to call 
maybe_fold_or_comparisons, when maybe_fold_and_comparisons fails, but I don't 
know if there are optimizations that one does and not the other, except for 
the odd trapping-math case.


Bootstrap and testsuite are fine.

2012-07-26 Marc Glisse 

gcc/
PR tree-optimization/51938
PR tree-optimization/52005
* tree-ssa-ifcombine.c (ifcombine_ifandif): New parameters for
inverted conditions.
(ifcombine_iforif): Remove, merge code into ifcombine_ifandif.
(tree_ssa_ifcombine_bb): Update calls to the above. Detect !a&&b
and !a||b patterns.


gcc/testsuite/
PR tree-optimization/51938
PR tree-optimization/52005
* gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase.
* gcc.dg/tree-ssa/ssa-ifcombine-9.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-10.c: Likewise.
* gcc.dg/tree-ssa/ssa-ifcombine-11.c: Likewise.


--
Marc Glisse


[patch] speed up ifcvt:cond_move_convert_if_block

2012-08-05 Thread Steven Bosscher
Hello,

In PR54146, ifcvt spends a lot of time just clearing memory. This
patch changes the value maps to pointer-maps to fix this issue.

Bootstrapped&tested on x86_64-unknown-linux-gnu. OK?

Ciao!
Steven


PR54146_ifcvt.diff
Description: Binary data