[PATCH] Fix and be more forgiving in the alias oracle

2011-03-03 Thread Richard Guenther

As PR47283 shows we still have issues with debug insns and the alias
oracle.  This patch makes us give conservative answers for
refs_may_alias_p_1 like we do in the other oracle entires (where
I noticed a bug, fixed with this patch).  I'll keep the assert
for checking-enabled builds as we probably want to fix the issues
nevertheless.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-03-03  Richard Guenther  

PR middle-end/47283
* tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Make code
match comment.
(refs_may_alias_p_1): For release branches return true if
we are confused by our input.

Index: gcc/tree-ssa-alias.c
===
*** gcc/tree-ssa-alias.c(revision 170594)
--- gcc/tree-ssa-alias.c(working copy)
*** ptr_deref_may_alias_decl_p (tree ptr, tr
*** 178,184 
|| (TREE_CODE (decl) != VAR_DECL
  && TREE_CODE (decl) != PARM_DECL
  && TREE_CODE (decl) != RESULT_DECL))
! return false;
  
/* Disregard pointer offsetting.  */
if (TREE_CODE (ptr) == POINTER_PLUS_EXPR)
--- 178,184 
|| (TREE_CODE (decl) != VAR_DECL
  && TREE_CODE (decl) != PARM_DECL
  && TREE_CODE (decl) != RESULT_DECL))
! return true;
  
/* Disregard pointer offsetting.  */
if (TREE_CODE (ptr) == POINTER_PLUS_EXPR)
*** refs_may_alias_p_1 (ao_ref *ref1, ao_ref
*** 1080,1086 
--- 1080,1091 
  ao_ref_alias_set (ref2), -1,
  tbaa_p);
  
+   /* We really do not want to end up here, but returning true is safe.  */
+ #ifdef ENABLE_CHECKING
gcc_unreachable ();
+ #else
+   return true;
+ #endif
  }
  
  bool


[PATCH, C++ testsuite] Fix g++.dg/abi/arm_cxa_vec1.C

2011-03-03 Thread Yufeng Zhang
Hi,

Here is a patch that fixes a problem in one g++ test case. A typo (of
using the macro ___ARM_EABI__ rather than __ARM_EABI__) has made the
original test case almost a NOP.

Also with a few other changes that make the test work properly.

I have already tested the updated test case that it still passes with
arm-eabi as an expected pass and passes with x86 as an unsupported test.

OK for the trunk?

Thanks,
Yufeng


2011-03-03  Yufeng Zhang  

* g++.dg/abi/arm_cxa_vec1.C: Correct the typos/errors in the
test case.

Index: gcc/testsuite/g++.dg/abi/arm_cxa_vec1.C
===
--- gcc/testsuite/g++.dg/abi/arm_cxa_vec1.C (revision 170373)
+++ gcc/testsuite/g++.dg/abi/arm_cxa_vec1.C (working copy)
@@ -3,10 +3,12 @@
 
 #include 
 
-#ifdef ___ARM_EABI__
-static void cctor (void * a, void * b)
+#ifdef __ARM_EABI__
+using namespace __cxxabiv1;
+static __cxa_cdtor_return_type cctor (void * a, void * b)
 {
-  *(char *) a = *(char *) b
+  *(char *) a = *(char *) b;
+  return a;
 }
 
 int main()
@@ -15,10 +17,10 @@
   char data2;
   char *p;
 
-  p = __cxa_vec_ctor (&data, 1, 1, NULL, NULL);
+  p = (char *) __cxa_vec_ctor (&data, 1, 1, NULL, NULL);
   if (p != &data)
 return 1;
-  p = __cxa_vec_cctor (&data2, &data, 1, 1, cctor, NULL);
+  p = (char *) __cxa_vec_cctor (&data2, &data, 1, 1, cctor, NULL);
   if (p != &data2)
 return 1;






[Committed] S/390: Remove deprecated target macro FUNCTION_VALUE

2011-03-03 Thread Andreas Krebbel
Hi,

this patch removes the use of the deprecated FUNCTION_VALUE macro in
the S/390 back end.

Bootstrapped on s390 and s390x. No regression.

Committed to mainline.

Bye,

-Andreas-


2011-03-03  Andreas Krebbel  

* config/s390/s390.c (s390_function_value): Rename to ...
(s390_function_and_libcall_value): ... this.
(s390_function_value): New function.
(s390_libcall_value): New function.
(TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE): Define target
hooks.
* config/s390/s390.h (FUNCTION_VALUE, LIBCALL_VALUE): Remove
target macro definitions.
* config/s390/s390-protos.h (s390_function_value): Remove prototype.


Index: gcc/config/s390/s390.c
===
--- gcc/config/s390/s390.c.orig
+++ gcc/config/s390/s390.c
@@ -8687,17 +8687,23 @@ s390_promote_function_mode (const_tree t
   return mode;
 }
 
-/* Define where to return a (scalar) value of type TYPE.
-   If TYPE is null, define where to return a (scalar)
+/* Define where to return a (scalar) value of type RET_TYPE.
+   If RET_TYPE is null, define where to return a (scalar)
value of mode MODE from a libcall.  */
 
-rtx
-s390_function_value (const_tree type, const_tree fn, enum machine_mode mode)
-{
-  if (type)
-{
-  int unsignedp = TYPE_UNSIGNED (type);
-  mode = promote_function_mode (type, TYPE_MODE (type), &unsignedp, fn, 1);
+static rtx
+s390_function_and_libcall_value (enum machine_mode mode,
+const_tree ret_type,
+const_tree fntype_or_decl,
+bool outgoing ATTRIBUTE_UNUSED)
+{
+  /* For normal functions perform the promotion as
+ promote_function_mode would do.  */
+  if (ret_type)
+{
+  int unsignedp = TYPE_UNSIGNED (ret_type);
+  mode = promote_function_mode (ret_type, mode, &unsignedp,
+   fntype_or_decl, 1);
 }
 
   gcc_assert (GET_MODE_CLASS (mode) == MODE_INT || SCALAR_FLOAT_MODE_P (mode));
@@ -8710,6 +8716,10 @@ s390_function_value (const_tree type, co
 return gen_rtx_REG (mode, 2);
   else if (GET_MODE_SIZE (mode) == 2 * UNITS_PER_LONG)
 {
+  /* This case is triggered when returning a 64 bit value with
+-m31 -mzarch.  Although the value would fit into a single
+register it has to be forced into a 32 bit register pair in
+order to match the ABI.  */
   rtvec p = rtvec_alloc (2);
 
   RTVEC_ELT (p, 0)
@@ -8723,6 +8733,26 @@ s390_function_value (const_tree type, co
   gcc_unreachable ();
 }
 
+/* Define where to return a scalar return value of type RET_TYPE.  */
+
+static rtx
+s390_function_value (const_tree ret_type, const_tree fn_decl_or_type,
+bool outgoing)
+{
+  return s390_function_and_libcall_value (TYPE_MODE (ret_type), ret_type,
+ fn_decl_or_type, outgoing);
+}
+
+/* Define where to return a scalar libcall return value of mode
+   MODE.  */
+
+static rtx
+s390_libcall_value (enum machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
+{
+  return s390_function_and_libcall_value (mode, NULL_TREE,
+ NULL_TREE, true);
+}
+
 
 /* Create and return the va_list datatype.
 
@@ -10694,6 +10724,10 @@ s390_loop_unroll_adjust (unsigned nunrol
 #define TARGET_FUNCTION_ARG s390_function_arg
 #undef TARGET_FUNCTION_ARG_ADVANCE
 #define TARGET_FUNCTION_ARG_ADVANCE s390_function_arg_advance
+#undef TARGET_FUNCTION_VALUE
+#define TARGET_FUNCTION_VALUE s390_function_value
+#undef TARGET_LIBCALL_VALUE
+#define TARGET_LIBCALL_VALUE s390_libcall_value
 
 #undef TARGET_FIXED_CONDITION_CODE_REGS
 #define TARGET_FIXED_CONDITION_CODE_REGS s390_fixed_condition_code_regs
Index: gcc/config/s390/s390.h
===
--- gcc/config/s390/s390.h.orig
+++ gcc/config/s390/s390.h
@@ -688,14 +688,6 @@ CUMULATIVE_ARGS;
   (N) == 16 || (N) == 17 || (TARGET_64BIT && ((N) == 18 || (N) == 19)))
 
 
-/* Scalar return values.  */
-
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
-  s390_function_value ((VALTYPE), (FUNC), VOIDmode)
-
-#define LIBCALL_VALUE(MODE) \
-  s390_function_value (NULL, NULL, (MODE))
-
 /* Only gpr 2 and fpr 0 are ever used as return registers.  */
 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16)
 
Index: gcc/config/s390/s390-protos.h
===
--- gcc/config/s390/s390-protos.h.orig
+++ gcc/config/s390/s390-protos.h
@@ -111,9 +111,3 @@ extern int s390_branch_condition_mask (r
 extern int s390_compare_and_branch_condition_mask (rtx);
 
 #endif /* RTX_CODE */
-
-#ifdef TREE_CODE
-#ifdef RTX_CODE
-extern rtx s390_function_value (const_tree, const_tree, enum machine_mode);
-#endif /* RTX_CODE */
-#endif /* TREE_CODE */


[PATCH][4.5] Fix -Werror bootstrap

2011-03-03 Thread Richard Guenther

Bootstrapped on x86_64-unknown-linux-gnu, applied.

Richard.

2011-03-03  Richard Guenther  

* tree-vect-stmt.c (vectorizable_operation): Remove unused vars.

Index: gcc/tree-vect-stmts.c
===
*** gcc/tree-vect-stmts.c   (revision 170648)
--- gcc/tree-vect-stmts.c   (working copy)
*** vectorizable_operation (gimple stmt, gim
*** 2238,2244 
int op_type;
optab optab;
int icode;
-   enum machine_mode optab_op2_mode;
tree def;
gimple def_stmt;
enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type};
--- 2238,2243 
*** vectorizable_operation (gimple stmt, gim
*** 2251,2258 
int j, i;
VEC(tree,heap) *vec_oprnds0 = NULL, *vec_oprnds1 = NULL;
tree vop0, vop1;
-   unsigned int k;
-   bool scalar_shift_arg = false;
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
int vf;
  
--- 2250,2255 


Re: [Patch, AVR]: PR42240 - Fix epilogue of naked functions

2011-03-03 Thread Georg-Johann Lay
Denis Chertykov schrieb:
> 2011/2/26 Georg-Johann Lay :
>> Georg-Johann Lay schrieb:
>>
>> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01441.html
>>
>>> The patch implements target hook TARGET_CANNOT_MODIFY_JUMPS_P in order
>>> to inhibit post-reload bb reorder for naked functions.
>>>
>>> It's basically the same patch as proposed in bug data base and works
>>> for the test case attached there.
>>>
>>> The patch works just as well for gcc-4.5.2. Should I provide a
>>> seperate patch against 4.5.2 (tags/gcc_4_5_2_release) or is this patch
>>> (against trunk) sufficient?
>>>
>>> Johann
>>>
>>> --
>>>
>>> 2011-02-11  Georg-Johann Lay  
>>>
>>>PR target/42240
>>>* config/avr/avr.c (avr_cannot_modify_jumps_p): New function.
>>>(TARGET_CANNOT_MODIFY_JUMPS_P): Define.
>>>
> 
> Applied.
> 
> Denis.

This are backports to 4.3, 4.4, 4.5 branch, respectively
(branches/gcc-4_*-branch/)

I think PR42240 can be closed now

Johann


Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 170651)
+++ config/avr/avr.c	(working copy)
@@ -69,6 +69,7 @@ static void avr_file_start (void);
 static void avr_file_end (void);
 static void avr_asm_function_end_prologue (FILE *);
 static void avr_asm_function_begin_epilogue (FILE *);
+static bool avr_cannot_modify_jumps_p (void);
 static void avr_insert_attributes (tree, tree *);
 static void avr_asm_init_sections (void);
 static unsigned int avr_section_type_flags (tree, const char *, int);
@@ -328,6 +329,9 @@ int avr_case_values_threshold = 3;
 #undef TARGET_STRICT_ARGUMENT_NAMING
 #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
 
+#undef TARGET_CANNOT_MODIFY_JUMPS_P
+#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 void
@@ -951,6 +955,27 @@ avr_asm_function_begin_epilogue (FILE *f
   fprintf (file, "/* epilogue start */\n");
 }
 
+
+/* Implement TARGET_CANNOT_MODITY_JUMPS_P */
+
+static bool
+avr_cannot_modify_jumps_p (void)
+{
+
+  /* Naked Functions must not have any instructions after
+ their epilogue, see PR42240 */
+ 
+  if (reload_completed
+  && cfun->machine
+  && cfun->machine->is_naked)
+{
+  return true;
+}
+
+  return false;
+}
+
+
 /* Return nonzero if X (an RTX) is a legitimate memory address on the target
machine for a memory operand of mode MODE.  */
 
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 170651)
+++ config/avr/avr.c	(working copy)
@@ -72,6 +72,7 @@ static void avr_file_start (void);
 static void avr_file_end (void);
 static void avr_asm_function_end_prologue (FILE *);
 static void avr_asm_function_begin_epilogue (FILE *);
+static bool avr_cannot_modify_jumps_p (void);
 static rtx avr_function_value (const_tree, const_tree, bool);
 static void avr_insert_attributes (tree, tree *);
 static void avr_asm_init_sections (void);
@@ -361,6 +362,9 @@ int avr_case_values_threshold = 3;
 #undef TARGET_HARD_REGNO_SCRATCH_OK
 #define TARGET_HARD_REGNO_SCRATCH_OK avr_hard_regno_scratch_ok
 
+#undef TARGET_CANNOT_MODIFY_JUMPS_P
+#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 void
@@ -1093,6 +1097,27 @@ avr_asm_function_begin_epilogue (FILE *f
   fprintf (file, "/* epilogue start */\n");
 }
 
+
+/* Implement TARGET_CANNOT_MODITY_JUMPS_P */
+
+static bool
+avr_cannot_modify_jumps_p (void)
+{
+
+  /* Naked Functions must not have any instructions after
+ their epilogue, see PR42240 */
+ 
+  if (reload_completed
+  && cfun->machine
+  && cfun->machine->is_naked)
+{
+  return true;
+}
+
+  return false;
+}
+
+
 /* Return nonzero if X (an RTX) is a legitimate memory address on the target
machine for a memory operand of mode MODE.  */
 
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 170651)
+++ config/avr/avr.c	(working copy)
@@ -73,6 +73,7 @@ static void avr_file_end (void);
 static bool avr_legitimate_address_p (enum machine_mode, rtx, bool);
 static void avr_asm_function_end_prologue (FILE *);
 static void avr_asm_function_begin_epilogue (FILE *);
+static bool avr_cannot_modify_jumps_p (void);
 static rtx avr_function_value (const_tree, const_tree, bool);
 static void avr_insert_attributes (tree, tree *);
 static void avr_asm_init_sections (void);
@@ -196,6 +197,9 @@ static const struct attribute_spec avr_a
 #undef TARGET_HELP
 #define TARGET_HELP avr_help
 
+#undef TARGET_CANNOT_MODIFY_JUMPS_P
+#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 void
@@ -991,6 +995,27 @@ avr_asm_function_begin_epilogue (FILE *f
   fprintf (file, "/* epilogue start */\n");
 }
 
+
+/* Implement TARGET_CANNOT_MODITY_JUMPS_P */
+
+static bool
+avr_cannot_modi

Re: ivopts improvement

2011-03-03 Thread Tom de Vries
Hi Paolo,

On 03/03/2011 09:44 AM, Paolo Bonzini wrote:
> On 03/02/2011 11:01 PM, Tom de Vries wrote:
>> +  if (TREE_CODE (nit) == COND_EXPR)
>> +{
>> +  if (!loop_only_exit_p (loop, exit))
>> +return false;
>> +
>> +  return iv_elimination_compare_lt (use, cand, bound, nit, comp);
>> +}
>> +
> 
> You probably need a comment on top of iv_elimination_compare_lt, 
> otherwise I'm left wondering why this isn't
> 
>if (TREE_CODE (nit) == COND_EXPR
>&& loop_only_exit_p (loop, exit)
>&& iv_elimination_compare_lt (use, cand, bound, nit, comp))
>  return true;
> 

You're right, there's a comment missing. I added it now.

> Also, the check on nit is an optimization.  

It's not, hopefully now explained by the comment.

> Perhaps you should add a 
> gcc_checking_assert to i_elimination_compare_lt and/or remove this from 
> get_lt_bound:
> 
>> +  if (TREE_CODE (nit) != COND_EXPR)
>> +return NULL_TREE;
>> +

It's duplicate test, so I turned it into a gcc_checking_assert.

> Or perhaps loop_only_exit_p could be optimized by computing it ahead of 
> time, possibly at the same time as loop_body_includes_call.  This way it 
> becomes very cheap and the code above can just call 
> iv_elimination_compare_lt without any pre-screening.

Gave it a try in a new patch.

reg-tested on x86_64. Better?

Thanks,
- Tom
diff -u gcc/tree-ssa-loop-ivopts.c gcc/tree-ssa-loop-ivopts.c
--- gcc/tree-ssa-loop-ivopts.c	(working copy)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -292,6 +292,10 @@
 
   /* Whether the loop body includes any function calls.  */
   bool body_includes_call;
+
+  /* Whether the loop body includes any function calls that possibly have side
+ effects.  */
+  bool body_includes_side_effect_call;
 };
 
 /* An assignment of iv candidates to uses.  */
@@ -456,6 +460,20 @@
   return exit;
 }
 
+/* Returns true if single_exit (DATA->current_loop) is the only possible exit.
+   Uses the same logic as loop_only_exit_p.  */
+
+static bool
+loop_single_exit_p (struct ivopts_data *data)
+{
+  edge exit = single_exit (data->current_loop);
+
+  if (!exit)
+return false;
+
+  return !data->body_includes_side_effect_call;
+}
+
 /* Dumps information about the induction variable IV to FILE.  */
 
 extern void dump_iv (FILE *, struct iv *);
@@ -4403,7 +4421,7 @@
   if (double_int_ucmp (max_niter, period_value) > 0)
 {
   /* See if we can take advantage of infered loop bound information.  */
-  if (loop_only_exit_p (loop, exit))
+  if (loop_single_exit_p (data))
 {
   if (!estimated_loop_iterations (loop, true, &max_niter))
 return false;
@@ -6343,23 +6361,34 @@
   htab_delete (data->inv_expr_tab);
 }
 
-/* Returns true if the loop body BODY includes any function calls.  */
+/* Find any functions calls in loop body BODY and stores a classification of
+   those in calls in DATA.  */
 
-static bool
-loop_body_includes_call (basic_block *body, unsigned num_nodes)
+static void
+find_calls_in_loop_body (struct ivopts_data *data, basic_block *body,
+ unsigned num_nodes)
 {
   gimple_stmt_iterator gsi;
   unsigned i;
+  bool call = false;
+  bool se_call = false;
+  bool done = false;
 
-  for (i = 0; i < num_nodes; i++)
-for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
+  for (i = 0; i < num_nodes && !done; i++)
+for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi) && !done;
+ gsi_next (&gsi))
   {
-	gimple stmt = gsi_stmt (gsi);
-	if (is_gimple_call (stmt)
-	&& !is_inexpensive_builtin (gimple_call_fndecl (stmt)))
-	  return true;
+gimple stmt = gsi_stmt (gsi);
+if (!is_gimple_call (stmt))
+  continue;
+
+call = call || is_inexpensive_builtin (gimple_call_fndecl (stmt));
+se_call = se_call || gimple_has_side_effects (stmt);
+done = call && se_call;
   }
-  return false;
+
+  data->body_includes_call = call;
+  data->body_includes_side_effect_call = se_call;
 }
 
 /* Optimizes the LOOP.  Returns true if anything changed.  */
@@ -6393,7 +6422,7 @@
 }
 
   body = get_loop_body (loop);
-  data->body_includes_call = loop_body_includes_call (body, loop->num_nodes);
+  find_calls_in_loop_body (data, body, loop->num_nodes);
   renumber_gimple_stmt_uids_in_blocks (body, loop->num_nodes);
   free (body);
 
diff -u gcc/tree-ssa-loop-ivopts.c gcc/tree-ssa-loop-ivopts.c
--- gcc/tree-ssa-loop-ivopts.c	(working copy)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -832,17 +832,25 @@
 
   if (!slot)
 {
-  /* Try to determine number of iterations.  We must know it
-	 unconditionally (i.e., without possibility of # of iterations
-	 being zero).  Also, we cannot safely work with ssa names that
-	 appear in phi nodes on abnormal edges, so that we do not create
-	 overlapping life ranges for them (PR 27283).  */
+  /* Try to determine number of iterations.  We cannot safely work with ssa
+  

Re: [PATCH, i386 AVX] Type error in vpmaddubsw instruction pattern

2011-03-03 Thread Uros Bizjak
On Thu, Mar 3, 2011 at 12:11 PM, Liu  wrote:

> When I read sse.md, I find there is a type error in vpmaddubsw
> define_insn pattern.
> Attached is the patch that fix the type error.
> Is it OK to commit to 4.6 trunk?

The same problem is with ssse3_pmadddubsw128 pattern.  Can you also
provide the ChangeLog for the patch and how you test the change?

Thanks,
Uros.


build_function_call and TREE_ADDRESSABLE

2011-03-03 Thread Alan Modra
TREE_ADDRESSABLE comment says "In a FUNCTION_DECL, nonzero means its
address is needed".  However, as I point out in
http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html, this flag
gets set when making normal calls.  It wasn't always like this.
gcc-4.0 was careful to not set TREE_ADDRESSABLE on FUNCTION_DECLs in
build_function_call, a feature lost in revision 100984.  I'd like to
have that feature back for the above patch.  Bootstrapped and
regression tested powerpc-linux.  OK for 4.6?

* c-typeck.c (build_function_call_vec): Avoid setting TREE_ADDRESSABLE
on normal function calls.

Index: gcc/c-typeck.c
===
--- gcc/c-typeck.c  (revision 170607)
+++ gcc/c-typeck.c  (working copy)
@@ -2715,7 +2715,20 @@ build_function_call_vec (location_t loc,
   fundecl = function;
 }
   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
-function = function_to_pointer_conversion (loc, function);
+{
+  if (fundecl)
+   {
+ /* Don't set TREE_ADDRESSABLE for the implicit function
+pointer conversion in a function call.  This allows
+TREE_ADDRESSABLE to be used to detect explicit function
+address operations.  */
+ bool addressable = TREE_ADDRESSABLE (fundecl);
+ function = function_to_pointer_conversion (loc, function);
+ TREE_ADDRESSABLE (fundecl) = addressable;
+   }
+  else
+   function = function_to_pointer_conversion (loc, function);
+}
 
   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
  expressions, like those used for ObjC messenger dispatches.  */

-- 
Alan Modra
Australia Development Lab, IBM


[PATCH] Try to canonicalize MEM_REFs that are put into MEM_EXPRs for DEBUG_INSNs (PR debug/47283, take 2)

2011-03-03 Thread Jakub Jelinek
On Thu, Mar 03, 2011 at 03:31:55PM +1000, Richard Henderson wrote:
> Do you really want to fallthru with newexp here?
> In theory it could have folded to anything.  My guess is that
> you want to restart instead...

Here is an updated patch that does that, and also as requested by
Richard Guenther instead of calling set_mem_expr with a type
just clears MEM_EXPR if it isn't suitable for alias oracle.

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

2011-03-03  Jakub Jelinek  

PR debug/47283
* cfgexpand.c (expand_debug_expr) : If MEM_REF
first operand is not is_gimple_mem_ref_addr, try to fold it.
If the operand still isn't is_gimple_mem_ref_addr, clear
MEM_EXPR on op0.

--- gcc/cfgexpand.c.jj  2011-02-21 15:37:42.0 +0100
+++ gcc/cfgexpand.c 2011-03-02 11:05:32.0 +0100
@@ -2578,6 +2578,15 @@ expand_debug_expr (tree exp)
   }
 
 case MEM_REF:
+  if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
+   {
+ tree newexp = fold_binary (MEM_REF, TREE_TYPE (exp),
+TREE_OPERAND (exp, 0),
+TREE_OPERAND (exp, 1));
+ if (newexp)
+   return expand_debug_expr (newexp);
+   }
+  /* FALLTHROUGH */
 case INDIRECT_REF:
   op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
   if (!op0)
@@ -2611,6 +2620,9 @@ expand_debug_expr (tree exp)
 
   op0 = gen_rtx_MEM (mode, op0);
   set_mem_attributes (op0, exp, 0);
+  if (TREE_CODE (exp) == MEM_REF
+ && !is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
+   set_mem_expr (op0, NULL_TREE);
   set_mem_addr_space (op0, as);
 
   return op0;


Jakub


Re: build_function_call and TREE_ADDRESSABLE

2011-03-03 Thread Richard Guenther
On Thu, Mar 3, 2011 at 3:33 PM, Alan Modra  wrote:
> TREE_ADDRESSABLE comment says "In a FUNCTION_DECL, nonzero means its
> address is needed".  However, as I point out in
> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html, this flag
> gets set when making normal calls.  It wasn't always like this.
> gcc-4.0 was careful to not set TREE_ADDRESSABLE on FUNCTION_DECLs in
> build_function_call, a feature lost in revision 100984.  I'd like to
> have that feature back for the above patch.  Bootstrapped and
> regression tested powerpc-linux.  OK for 4.6?

You'll get the addressable flag re-applied by the operand scanner.

Richard.

>        * c-typeck.c (build_function_call_vec): Avoid setting TREE_ADDRESSABLE
>        on normal function calls.
>
> Index: gcc/c-typeck.c
> ===
> --- gcc/c-typeck.c      (revision 170607)
> +++ gcc/c-typeck.c      (working copy)
> @@ -2715,7 +2715,20 @@ build_function_call_vec (location_t loc,
>       fundecl = function;
>     }
>   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
> -    function = function_to_pointer_conversion (loc, function);
> +    {
> +      if (fundecl)
> +       {
> +         /* Don't set TREE_ADDRESSABLE for the implicit function
> +            pointer conversion in a function call.  This allows
> +            TREE_ADDRESSABLE to be used to detect explicit function
> +            address operations.  */
> +         bool addressable = TREE_ADDRESSABLE (fundecl);
> +         function = function_to_pointer_conversion (loc, function);
> +         TREE_ADDRESSABLE (fundecl) = addressable;
> +       }
> +      else
> +       function = function_to_pointer_conversion (loc, function);
> +    }
>
>   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
>      expressions, like those used for ObjC messenger dispatches.  */
>
> --
> Alan Modra
> Australia Development Lab, IBM
>


Re: build_function_call and TREE_ADDRESSABLE

2011-03-03 Thread Richard Guenther
On Thu, Mar 3, 2011 at 4:42 PM, Richard Guenther
 wrote:
> On Thu, Mar 3, 2011 at 3:33 PM, Alan Modra  wrote:
>> TREE_ADDRESSABLE comment says "In a FUNCTION_DECL, nonzero means its
>> address is needed".  However, as I point out in
>> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html, this flag
>> gets set when making normal calls.  It wasn't always like this.
>> gcc-4.0 was careful to not set TREE_ADDRESSABLE on FUNCTION_DECLs in
>> build_function_call, a feature lost in revision 100984.  I'd like to
>> have that feature back for the above patch.  Bootstrapped and
>> regression tested powerpc-linux.  OK for 4.6?
>
> You'll get the addressable flag re-applied by the operand scanner.

The proper way to check "if its address is needed" is via cgraph
predicates.

Richard.


Re: [PATCH] Try to canonicalize MEM_REFs that are put into MEM_EXPRs for DEBUG_INSNs (PR debug/47283, take 2)

2011-03-03 Thread Richard Guenther
On Thu, Mar 3, 2011 at 4:11 PM, Jakub Jelinek  wrote:
> On Thu, Mar 03, 2011 at 03:31:55PM +1000, Richard Henderson wrote:
>> Do you really want to fallthru with newexp here?
>> In theory it could have folded to anything.  My guess is that
>> you want to restart instead...
>
> Here is an updated patch that does that, and also as requested by
> Richard Guenther instead of calling set_mem_expr with a type
> just clears MEM_EXPR if it isn't suitable for alias oracle.
>
> Bootstrapped/regtested again on x86_64-linux and i686-linux, ok?

Ok.

Thanks,
Richard.

> 2011-03-03  Jakub Jelinek  
>
>        PR debug/47283
>        * cfgexpand.c (expand_debug_expr) : If MEM_REF
>        first operand is not is_gimple_mem_ref_addr, try to fold it.
>        If the operand still isn't is_gimple_mem_ref_addr, clear
>        MEM_EXPR on op0.
>
> --- gcc/cfgexpand.c.jj  2011-02-21 15:37:42.0 +0100
> +++ gcc/cfgexpand.c     2011-03-02 11:05:32.0 +0100
> @@ -2578,6 +2578,15 @@ expand_debug_expr (tree exp)
>       }
>
>     case MEM_REF:
> +      if (!is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
> +       {
> +         tree newexp = fold_binary (MEM_REF, TREE_TYPE (exp),
> +                                    TREE_OPERAND (exp, 0),
> +                                    TREE_OPERAND (exp, 1));
> +         if (newexp)
> +           return expand_debug_expr (newexp);
> +       }
> +      /* FALLTHROUGH */
>     case INDIRECT_REF:
>       op0 = expand_debug_expr (TREE_OPERAND (exp, 0));
>       if (!op0)
> @@ -2611,6 +2620,9 @@ expand_debug_expr (tree exp)
>
>       op0 = gen_rtx_MEM (mode, op0);
>       set_mem_attributes (op0, exp, 0);
> +      if (TREE_CODE (exp) == MEM_REF
> +         && !is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
> +       set_mem_expr (op0, NULL_TREE);
>       set_mem_addr_space (op0, as);
>
>       return op0;
>
>
>        Jakub
>


[PATCH] Fix PR47968, extract_bit_field_1 oddness

2011-03-03 Thread Richard Guenther

This fixes PR47968, we are trying to expand a bitfield extraction
through vec_extract but strip subregs making the inputs invalid.
We try to compensate for this searching for a more proper vector mode
but then we have a strange requirement that NUNITS should stay the
same when the most important thing is to have matching element mode.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2011-03-03  Richard Guenther  

PR middle-end/47968
* expmed.c (extract_bit_field_1): Prefer vector modes that
vec_extract patterns can handle.

* gcc.dg/torture/pr47968.c: New testcase.

Index: gcc/expmed.c
===
*** gcc/expmed.c(revision 170649)
--- gcc/expmed.c(working copy)
*** extract_bit_field_1 (rtx str_rtx, unsign
*** 1205,1211 
&& GET_MODE_INNER (GET_MODE (op0)) != tmode)
  {
enum machine_mode new_mode;
-   int nunits = GET_MODE_NUNITS (GET_MODE (op0));
  
if (GET_MODE_CLASS (tmode) == MODE_FLOAT)
new_mode = MIN_MODE_VECTOR_FLOAT;
--- 1205,1210 
*** extract_bit_field_1 (rtx str_rtx, unsign
*** 1221,1228 
new_mode = MIN_MODE_VECTOR_INT;
  
for (; new_mode != VOIDmode ; new_mode = GET_MODE_WIDER_MODE (new_mode))
!   if (GET_MODE_NUNITS (new_mode) == nunits
!   && GET_MODE_SIZE (new_mode) == GET_MODE_SIZE (GET_MODE (op0))
&& targetm.vector_mode_supported_p (new_mode))
  break;
if (new_mode != VOIDmode)
--- 1220,1226 
new_mode = MIN_MODE_VECTOR_INT;
  
for (; new_mode != VOIDmode ; new_mode = GET_MODE_WIDER_MODE (new_mode))
!   if (GET_MODE_SIZE (new_mode) == GET_MODE_SIZE (GET_MODE (op0))
&& targetm.vector_mode_supported_p (new_mode))
  break;
if (new_mode != VOIDmode)
Index: gcc/testsuite/gcc.dg/torture/pr47968.c
===
*** gcc/testsuite/gcc.dg/torture/pr47968.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr47968.c  (revision 0)
***
*** 0 
--- 1,11 
+ /* { dg-do compile } */
+ 
+ typedef __attribute__ ((vector_size (16))) float float4;
+ typedef __attribute__ ((vector_size (16))) double double2;
+ 
+ float foo (double2 d2)
+ {
+   float4 f4 = (float4) d2;
+   return *(float *) &f4;
+ }
+ 


[C++ Patch] PR 47974

2011-03-03 Thread Paolo Carlini
Hi,

another ICE on invalid, 4.6 regression, a simple patch for it attached.
Tested x86_64-linux.

Ok?

Thanks,
Paolo.
/cp
2011-03-03  Paolo Carlini  

PR c++/47974
* pt.c (tsubst_template_args): Check argument t for error_mark_node.

/testsuite
2011-03-03  Paolo Carlini  

PR c++/47974
* g++.dg/template/crash106.C: New.
Index: testsuite/g++.dg/template/crash106.C
===
--- testsuite/g++.dg/template/crash106.C(revision 0)
+++ testsuite/g++.dg/template/crash106.C(revision 0)
@@ -0,0 +1,12 @@
+// PR c++/47974
+
+typedef double T;
+
+struct A
+{
+  template void foo(); // { dg-error "type" }
+};
+
+template > struct B {}; // { dg-error 
"type|declared" }
+
+B<> b; // { dg-error "type|declaration" }
Index: cp/pt.c
===
--- cp/pt.c (revision 170651)
+++ cp/pt.c (working copy)
@@ -8966,10 +8966,15 @@ static tree
 tsubst_template_args (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 {
   tree orig_t = t;
-  int len = TREE_VEC_LENGTH (t);
-  int need_new = 0, i, expanded_len_adjust = 0, out;
-  tree *elts = XALLOCAVEC (tree, len);
+  int len, need_new = 0, i, expanded_len_adjust = 0, out;
+  tree *elts;
 
+  if (t == error_mark_node)
+return error_mark_node;
+
+  len = TREE_VEC_LENGTH (t);
+  elts = XALLOCAVEC (tree, len);
+
   for (i = 0; i < len; i++)
 {
   tree orig_arg = TREE_VEC_ELT (t, i);


[committed] Fix OpenMP ICE on invalid during gimplification (PR c/47963)

2011-03-03 Thread Jakub Jelinek
Hi!

omp_notice_variable isn't prepared to see INTEGER_CST (which wouldn't be
there on valid code where DECL_SIZE is a DECL).
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk.

2011-03-03  Jakub Jelinek  

PR c/47963
* gimplify.c (omp_add_variable): Only call omp_notice_variable
on TYPE_SIZE_UNIT if it is a DECL.

* gcc.dg/gomp/pr47963.c: New test.
* g++.dg/gomp/pr47963.C: New test.

--- gcc/gimplify.c.jj   2010-12-09 11:12:48.0 +0100
+++ gcc/gimplify.c  2011-03-03 09:18:01.0 +0100
@@ -5511,7 +5511,8 @@ omp_add_variable (struct gimplify_omp_ct
 For local variables TYPE_SIZE_UNIT might not be gimplified yet,
 in this case omp_notice_variable will be called later
 on when it is gimplified.  */
-  else if (! (flags & GOVD_LOCAL))
+  else if (! (flags & GOVD_LOCAL)
+  && DECL_P (TYPE_SIZE_UNIT (TREE_TYPE (decl
omp_notice_variable (ctx, TYPE_SIZE_UNIT (TREE_TYPE (decl)), true);
 }
   else if (lang_hooks.decls.omp_privatize_by_reference (decl))
--- gcc/testsuite/gcc.dg/gomp/pr47963.c.jj  2011-03-03 10:13:56.0 
+0100
+++ gcc/testsuite/gcc.dg/gomp/pr47963.c 2011-03-03 09:22:41.0 +0100
@@ -0,0 +1,11 @@
+/* PR c/47963 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (float n)
+{
+  int A[n][n]; /* { dg-error "has non-integer type" } */
+#pragma omp parallel private(A)
+  ;
+}
--- gcc/testsuite/g++.dg/gomp/pr47963.C.jj  2011-03-03 10:13:22.0 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr47963.C 2011-03-03 10:13:39.0 +0100
@@ -0,0 +1,11 @@
+// PR c/47963
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+void
+foo (float n)
+{
+  int A[n][n]; // { dg-error "has non-integral type" }
+#pragma omp parallel private(A)
+  ;
+}

Jakub


[PATCH] Fix PR47975

2011-03-03 Thread Richard Guenther

Bah, whoever invented

#define TYPE_MODE(NODE) \
  (TREE_CODE (TYPE_CHECK (NODE)) == VECTOR_TYPE \
   ? vector_type_mode (NODE) : (NODE)->type.mode)

needs to be clue-batted (yes, I know your name!!! ;))

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

Richard.

2011-03-03  Richard Guenther  

PR middle-end/47975
* optabs.c (optab_for_tree_code): Do not use VECTOR_MODE_P.

* gcc.dg/torture/pr47975.c: New testcase.

Index: gcc/optabs.c
===
*** gcc/optabs.c(revision 170649)
--- gcc/optabs.c(working copy)
*** optab_for_tree_code (enum tree_code code
*** 303,309 
return TYPE_UNSIGNED (type) ? udiv_optab : sdiv_optab;
  
  case LSHIFT_EXPR:
!   if (VECTOR_MODE_P (TYPE_MODE (type)))
{
  if (subtype == optab_vector)
return TYPE_SATURATING (type) ? NULL : vashl_optab;
--- 303,309 
return TYPE_UNSIGNED (type) ? udiv_optab : sdiv_optab;
  
  case LSHIFT_EXPR:
!   if (TREE_CODE (type) == VECTOR_TYPE)
{
  if (subtype == optab_vector)
return TYPE_SATURATING (type) ? NULL : vashl_optab;
*** optab_for_tree_code (enum tree_code code
*** 315,321 
return ashl_optab;
  
  case RSHIFT_EXPR:
!   if (VECTOR_MODE_P (TYPE_MODE (type)))
{
  if (subtype == optab_vector)
return TYPE_UNSIGNED (type) ? vlshr_optab : vashr_optab;
--- 315,321 
return ashl_optab;
  
  case RSHIFT_EXPR:
!   if (TREE_CODE (type) == VECTOR_TYPE)
{
  if (subtype == optab_vector)
return TYPE_UNSIGNED (type) ? vlshr_optab : vashr_optab;
*** optab_for_tree_code (enum tree_code code
*** 325,331 
return TYPE_UNSIGNED (type) ? lshr_optab : ashr_optab;
  
  case LROTATE_EXPR:
!   if (VECTOR_MODE_P (TYPE_MODE (type)))
{
  if (subtype == optab_vector)
return vrotl_optab;
--- 325,331 
return TYPE_UNSIGNED (type) ? lshr_optab : ashr_optab;
  
  case LROTATE_EXPR:
!   if (TREE_CODE (type) == VECTOR_TYPE)
{
  if (subtype == optab_vector)
return vrotl_optab;
*** optab_for_tree_code (enum tree_code code
*** 335,341 
return rotl_optab;
  
  case RROTATE_EXPR:
!   if (VECTOR_MODE_P (TYPE_MODE (type)))
{
  if (subtype == optab_vector)
return vrotr_optab;
--- 335,341 
return rotl_optab;
  
  case RROTATE_EXPR:
!   if (TREE_CODE (type) == VECTOR_TYPE)
{
  if (subtype == optab_vector)
return vrotr_optab;
Index: gcc/testsuite/gcc.dg/torture/pr47975.c
===
*** gcc/testsuite/gcc.dg/torture/pr47975.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr47975.c  (revision 0)
***
*** 0 
--- 1,9 
+ /* { dg-do compile } */
+ 
+ int __attribute__ ((vector_size (32))) x;
+ 
+ void
+ foo (void)
+ {
+   x <<= x;
+ }


[PATCH] Fix PR46399 - missing mode promotion for libcall args - updated

2011-03-03 Thread Andreas Krebbel
Hi,

I've refreshed the patch:

[PATCH] Fix PR46399 - missing mode promotion for libcall args
http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01595.html

after removing the FUNCTION_VALUE target macro with:

[Committed] S/390: Remove deprecated target macro FUNCTION_VALUE
http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00127.html

And I've moved the documentation of the new target hook to target.def
as requested by Nathan.

Bootstrapped on x86_64, s390 and s390x. No regressions.

Two testcases fixed on s390x:

< FAIL: gcc.dg/dfp/pr41049.c execution test
< FAIL: decimal/comparison.cc execution test

Ok for mainline?

Bye,

-Andreas-


2011-03-04  Andreas Krebbel  

PR middle-end/46399
* calls.c (emit_library_call_value_1): Promote libcall arguments
using promote_libcall_mode.
* explow.c (promote_libcall_mode): New function.
* expr.h (promote_libcall_mode): New prototype.
* target.def (promote_libcall_mode): New target hook.
* targhooks.c (default_promote_libcall_mode): New function.
* targhooks.h (default_promote_libcall_mode): New prototype.
* config/s390/s390.c (s390_promote_libcall_mode): New function.

* doc/tm.texi: Regenerate.


Index: gcc/calls.c
===
*** gcc/calls.c.orig
--- gcc/calls.c
*** emit_library_call_value_1 (int retval, r
*** 3481,3486 
--- 3481,3487 
  {
rtx val = va_arg (p, rtx);
enum machine_mode mode = (enum machine_mode) va_arg (p, int);
+   int unsigned_p = 0;
  
/* We cannot convert the arg value to the mode the library wants here;
 must do it earlier where we know the signedness of the arg.  */
*** emit_library_call_value_1 (int retval, r
*** 3528,3536 
  val = force_operand (XEXP (slot, 0), NULL_RTX);
}
  
!   argvec[count].value = val;
argvec[count].mode = mode;
! 
argvec[count].reg = targetm.calls.function_arg (&args_so_far, mode,
  NULL_TREE, true);
  
--- 3529,3537 
  val = force_operand (XEXP (slot, 0), NULL_RTX);
}
  
!   mode = promote_libcall_mode (mode, &unsigned_p, fntype, 1);
argvec[count].mode = mode;
!   argvec[count].value = convert_modes (mode, GET_MODE (val), val, 
unsigned_p);
argvec[count].reg = targetm.calls.function_arg (&args_so_far, mode,
  NULL_TREE, true);
  
Index: gcc/explow.c
===
*** gcc/explow.c.orig
--- gcc/explow.c
*** promote_function_mode (const_tree type, 
*** 783,788 
--- 783,807 
return mode;
  }
  }
+ 
+ /* Return the mode to use to pass or return a scalar of MODE for a libcall.
+PUNSIGNEDP points to the signedness of the type and may be adjusted
+to show what signedness to use on extension operations.
+ 
+FOR_RETURN is nonzero if the caller is promoting the return value
+of FNDECL, else it is for promoting args.  */
+ 
+ enum machine_mode
+ promote_libcall_mode (enum machine_mode mode, int *punsignedp,
+ const_tree funtype, int for_return)
+ {
+   if (INTEGRAL_MODE_P (mode))
+   return targetm.calls.promote_libcall_mode (mode, punsignedp, funtype,
+for_return);
+   else
+ return mode;
+ }
+ 
  /* Return the mode to use to store a scalar of TYPE and MODE.
 PUNSIGNEDP points to the signedness of the type and may be adjusted
 to show what signedness to use on extension operations.  */
Index: gcc/expr.h
===
*** gcc/expr.h.orig
--- gcc/expr.h
*** extern rtx force_not_mem (rtx);
*** 613,618 
--- 613,623 
  extern enum machine_mode promote_function_mode (const_tree, enum 
machine_mode, int *,
const_tree, int);
  
+ /* Return mode and signedness to use when an libcall argument or
+result in the given mode is promoted.  */
+ extern enum machine_mode promote_libcall_mode (enum machine_mode, int *,
+  const_tree, int);
+ 
  /* Return mode and signedness to use when an object in the given mode
 is promoted.  */
  extern enum machine_mode promote_mode (const_tree, enum machine_mode, int *);
Index: gcc/target.def
===
*** gcc/target.def.orig
--- gcc/target.def
*** DEFHOOK
*** 1918,1923 
--- 1918,1935 
   default_promote_function_mode)
  
  DEFHOOK
+ (promote_libcall_mode,
+  "Like @code{TARGET_PROMOTE_FUNCTION_MODE}, but it is applied to libcall\
+  arguments only.  Define this if your target requires function\
+  arguments to be promoted to a larger mode and uses C compiled libcall\
+  routines (e.g. libdecnumber).

Re: C++ PATCH for c++/47950 (ICE with condition in template)

2011-03-03 Thread Jason Merrill

On 03/03/2011 12:08 AM, Jason Merrill wrote:

The problem here was that we were folding the initializer too many
times, so we lost the TREE_CONSTANT on the TARGET_EXPR. Since we already
fold in cp_parser_initializer_clause, it's redundant to do so in
cp_parser_condition as well.


It occurred to me that a more robust fix would be to make it so 
redundant folding doesn't cause an ICE here.


Tested x86_64-pc-linux-gnu, applied to trunk.
commit a0390d566c766d20b49735be27913666a1e7ffad
Author: Jason Merrill 
Date:   Thu Mar 3 00:08:21 2011 -0500

PR c++/47950
* pt.c (tsubst_copy_and_build) [TARGET_EXPR]: Retain TREE_CONSTANT.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4b262d0..60b2699 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13368,7 +13368,11 @@ tsubst_copy_and_build (tree t,
   /* We can get here for a constant initializer of non-dependent type.
  FIXME stop folding in cp_parser_initializer_clause.  */
   gcc_assert (TREE_CONSTANT (t));
-  return get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
+  {
+   tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
+   TREE_CONSTANT (r) = true;
+   return r;
+  }
 
 default:
   /* Handle Objective-C++ constructs, if appropriate.  */


Re: [C++ Patch] PR 47974

2011-03-03 Thread Jason Merrill

OK.

Jason


[RFC] OpenMP 3.1 atomics

2011-03-03 Thread Jakub Jelinek
Hi!

This patch is a WIP patch for OpenMP 3.1 atomics, so far for C FE only.
It handles parsing (I created 3 new tree codes for atomic read,
atomic capture of the old and of the new value), gimplification and
omp expansion thereof, but currently both atomic read and atomic write
are implemented always pretty expensively using __sync_val_compare_and_swap.

I think we probably want to implement them as volatile read or write
(or perhaps just non-volatile read with some barriers around?), but probably
need some target hook to tell us what loads/stores aren't actually atomic
(say on old alpha char/short/int loads and stores aren't atomic).

Any comments?

--- gcc/c-parser.c.jj   2011-02-24 14:20:36.0 +0100
+++ gcc/c-parser.c  2011-03-03 16:57:07.0 +0100
@@ -9006,20 +9006,114 @@ c_parser_omp_structured_block (c_parser 
 
   where x is an lvalue expression with scalar type.
 
+   OpenMP 3.1:
+   # pragma omp atomic read new-line
+ read-stmt
+
+   # pragma omp atomic write new-line
+ write-stmt
+
+   # pragma omp atomic update new-line
+ expression-stmt
+
+   # pragma omp atomic capture new-line
+ capture-stmt
+
+   # pragma omp atomic capture new-line
+ capture-block
+
+   read-stmt:
+ v = x
+   write-stmt:
+ x = expr
+   capture-stmt:
+ v = x binop= expr | v = x++ | v = ++x | v = x-- | v = --x
+   capture-block:
+ { v = x; x binop= expr; } | { x binop= expr; v = x; }
+
+  where x and v are lvalue expressions with scalar type.
+
   LOC is the location of the #pragma token.  */
 
 static void
 c_parser_omp_atomic (location_t loc, c_parser *parser)
 {
-  tree lhs, rhs;
-  tree stmt;
-  enum tree_code code;
+  tree lhs = NULL_TREE, rhs = NULL_TREE, v = NULL_TREE, lhs1 = NULL_TREE;
+  tree stmt, orig_lhs;
+  enum tree_code code = OMP_ATOMIC, opcode = NOP_EXPR;
   struct c_expr rhs_expr;
+  bool structured_block = false;
+
+  if (c_parser_next_token_is (parser, CPP_NAME))
+{
+  const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
 
+  if (!strcmp (p, "read"))
+   code = OMP_ATOMIC_READ;
+  else if (!strcmp (p, "write"))
+   code = NOP_EXPR;
+  else if (!strcmp (p, "update"))
+   code = OMP_ATOMIC;
+  else if (!strcmp (p, "capture"))
+   code = OMP_ATOMIC_CAPTURE_NEW;
+  else
+   p = NULL;
+  if (p)
+   c_parser_consume_token (parser);
+}
   c_parser_skip_to_pragma_eol (parser);
 
+  switch (code)
+{
+case OMP_ATOMIC_READ:
+case NOP_EXPR: /* atomic write */
+  v = c_parser_unary_expression (parser).value;
+  v = c_fully_fold (v, false, NULL);
+  if (v == error_mark_node)
+   goto saw_error;
+  loc = c_parser_peek_token (parser)->location;
+  if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
+   goto saw_error;
+  lhs = c_parser_unary_expression (parser).value;
+  lhs = c_fully_fold (lhs, false, NULL);
+  if (lhs == error_mark_node)
+   goto saw_error;
+  if (code == NOP_EXPR)
+   {
+ /* atomic write is represented by OMP_ATOMIC with NOP_EXPR
+opcode.  */
+ code = OMP_ATOMIC;
+ rhs = lhs;
+ lhs = v;
+ v = NULL_TREE;
+   }
+  goto done;
+case OMP_ATOMIC_CAPTURE_NEW:
+  if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
+   {
+ c_parser_consume_token (parser);
+ structured_block = true;
+   }
+  else
+   {
+ v = c_parser_unary_expression (parser).value;
+ v = c_fully_fold (v, false, NULL);
+ if (v == error_mark_node)
+   goto saw_error;
+ if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
+   goto saw_error;
+   }
+  break;
+default:
+  break;
+}
+
+  /* For structured_block case we don't know yet whether
+ old or new x should be captured.  */
+restart:
   lhs = c_parser_unary_expression (parser).value;
   lhs = c_fully_fold (lhs, false, NULL);
+  orig_lhs = lhs;
   switch (TREE_CODE (lhs))
 {
 case ERROR_MARK:
@@ -9027,17 +9121,23 @@ c_parser_omp_atomic (location_t loc, c_p
   c_parser_skip_to_end_of_block_or_statement (parser);
   return;
 
-case PREINCREMENT_EXPR:
 case POSTINCREMENT_EXPR:
+  if (code == OMP_ATOMIC_CAPTURE_NEW)
+   code = OMP_ATOMIC_CAPTURE_OLD;
+  /* FALLTHROUGH */
+case PREINCREMENT_EXPR:
   lhs = TREE_OPERAND (lhs, 0);
-  code = PLUS_EXPR;
+  opcode = PLUS_EXPR;
   rhs = integer_one_node;
   break;
 
-case PREDECREMENT_EXPR:
 case POSTDECREMENT_EXPR:
+  if (code == OMP_ATOMIC_CAPTURE_NEW)
+   code = OMP_ATOMIC_CAPTURE_OLD;
+  /* FALLTHROUGH */
+case PREDECREMENT_EXPR:
   lhs = TREE_OPERAND (lhs, 0);
-  code = MINUS_EXPR;
+  opcode = MINUS_EXPR;
   rhs = integer_one_node;
   break;
 
@@ -9062,7 +9162,10 @@ c_parser_omp_atomic (location_t loc, c_p
  /* This is pre or post increment.  */
  rhs

Re: [Patch, AVR]: PR42240 - Fix epilogue of naked functions

2011-03-03 Thread Denis Chertykov
>> Denis.
>
> This are backports to 4.3, 4.4, 4.5 branch, respectively
> (branches/gcc-4_*-branch/)

Why you want to backport so deep ?
IMHO trunk and 4.5 is enough.
Applied to 4.5

Denis.


RE: [PATCH, i386] Introduce a flag to generate only 128-bit avx instructions

2011-03-03 Thread Fang, Changpeng
Yes, you are right. I renamed the flag to -mprefers-avx128 and modified
the documentation.

Is this OK to commit to 4.6?

Thanks,

Changpeng




From: Richard Henderson [r...@redhat.com]
Sent: Wednesday, March 02, 2011 3:50 PM
To: Fang, Changpeng
Cc: Jakub Jelinek; H.J. Lu; Richard Guenther; gcc-patches@gcc.gnu.org; 
hubi...@ucw.cz
Subject: Re: [PATCH, i386] Introduce a flag to generate only 128-bit avx 
instructions

On 03/03/2011 03:39 AM, Fang, Changpeng wrote:
>  case SFmode:
> -  return TARGET_AVX ? V8SFmode : V4SFmode;
> +  return (TARGET_AVX && !flag_avx_m128_only) ? V8SFmode : V4SFmode;
>  case DFmode:
> -  return TARGET_AVX ? V4DFmode : V2DFmode;
> +  return (TARGET_AVX && !flag_avx_m128_only) ? V4DFmode : V2DFmode;
>  case DImode:
>return V2DImode;
>  case SImode:
> diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
> index 85362d7..8968b25 100644
> --- a/gcc/config/i386/i386.opt
> +++ b/gcc/config/i386/i386.opt
> @@ -266,6 +266,10 @@ Target RejectNegative Var(flag_dispatch_scheduler)
>  Do dispatch scheduling if processor is bdver1 and Haifa scheduling
>  is selected.
>
> +mavx-m128-only
> +Target Report Var(flag_avx_m128_only) Init(0)
> +Generate only 128-bit AVX instructions.

You've not actually disabled 256-bit avx insns.  The documentation for
that switch suggests that you should.  Perhaps you want to expand the
documentation to say use only 128-bit insns for auto-vectorization?


r~

From 8c3ddf13024d426954986befd742448fa3805788 Mon Sep 17 00:00:00 2001
From: Changpeng Fang 
Date: Tue, 1 Mar 2011 12:50:46 -0800
Subject: [PATCH] Introduce flag -mprefers-avx128 for the vectorizer to generate only 128-bit avx insns.

	* config/i386/i386.opt (mprefers-avx128): New flag.
	* config/i386/i386.c (ix86_preferred_simd_mode): Prefer 128-bit mode
	if the flag -mprefers-avx128 is turned on.
---
 gcc/config/i386/i386.c   |4 ++--
 gcc/config/i386/i386.opt |5 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index aa59ada..b92c10d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -34747,9 +34747,9 @@ ix86_preferred_simd_mode (enum machine_mode mode)
   switch (mode)
 {
 case SFmode:
-  return TARGET_AVX ? V8SFmode : V4SFmode;
+  return (TARGET_AVX && !flag_prefers_avx128) ? V8SFmode : V4SFmode;
 case DFmode:
-  return TARGET_AVX ? V4DFmode : V2DFmode;
+  return (TARGET_AVX && !flag_prefers_avx128) ? V4DFmode : V2DFmode;
 case DImode:
   return V2DImode;
 case SImode:
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 85362d7..b4979ee 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -266,6 +266,11 @@ Target RejectNegative Var(flag_dispatch_scheduler)
 Do dispatch scheduling if processor is bdver1 and Haifa scheduling
 is selected.
 
+mprefers-avx128
+Target Report Var(flag_prefers_avx128) Init(0)
+Auto-vectorizer prefers to generate 128-bit AVX instructions instead of 256-bit
+ones.
+
 ;; ISA support
 
 m32
-- 
1.6.3.3



Re: [Patch, AVR]: PR42240 - Fix epilogue of naked functions

2011-03-03 Thread Georg-Johann Lay

Denis Chertykov schrieb:

Denis.


This are backports to 4.3, 4.4, 4.5 branch, respectively
(branches/gcc-4_*-branch/)



Why you want to backport so deep ?
IMHO trunk and 4.5 is enough.
Applied to 4.5

Denis.


I don't know what the policy concerning the depth of backporting 
bugfixes actually is. At least the check-in rule is "documentation and 
bug fixes only" so I though (backport of) bugfix is all right.


My intention was to go deep enough to have PR42240 resolved/fixed, i.e.
in all versions that are still supported.

Or what backports must be done in order to have it resolved/fixed?

Johann





RE: [Patch, AVR]: PR42240 - Fix epilogue of naked functions

2011-03-03 Thread Weddington, Eric


> -Original Message-
> From: Georg-Johann Lay [mailto:a...@gjlay.de]
> Sent: Thursday, March 03, 2011 11:01 AM
> To: Denis Chertykov
> Cc: gcc-patches@gcc.gnu.org; Anatoly Sokolov; Weddington, Eric
> Subject: Re: [Patch, AVR]: PR42240 - Fix epilogue of naked functions
> 
> > Denis.
> 
> I don't know what the policy concerning the depth of backporting
> bugfixes actually is. At least the check-in rule is "documentation and
> bug fixes only" so I though (backport of) bugfix is all right.
> 
> My intention was to go deep enough to have PR42240 resolved/fixed, i.e.
> in all versions that are still supported.
> 
> Or what backports must be done in order to have it resolved/fixed?

Most public distributions of avr-gcc have the 4.4 series. I think fixing this 
to 4.5 should be fine.


[patch, committed, ia64-hp-hpux*] Fix -flto failures

2011-03-03 Thread Steve Ellcey
This patch fixes g++.dg/lto/20091022-2, g++.dg/torture/pr33572.C, and
g++.dg/torture/pr39417.C on IA64 HP-UX when compiled with -flto.

In this case the tests generate references to __gcc_personality_v0 which
is not defined in libgcc_s.so on HP-UX.  This patch fixes the problem by
including the __gcc_personality_v0 function in libgcc.

Tested on IA64 HP-UX and checked in.

FYI: I have done some more investigation into why the gcc.dg/cleanup-*
tests fail on ia64-hp-hpux* platforms when using the system unwind library
and the problem does not look like it is related to _UA_END_OF_STACK,
instead when we call _Unwind_ForcedUnwind it trys to get the personality
function and gets a NULL.  In HP-UX it tries to do a call without checking
for a NULL personality function and aborts.  In GCC Unwind, we check
for the personality function being null and only call it when it is
not null.  I am not sure why the personality routine is null, the
assembly code generated for cleanup-5.c on HP-UX contains:

.global __gcc_personality_v0#
.type   __gcc_personality_v0#, @function
.personality__gcc_personality_v0#


Steve Ellcey
s...@cup.hp.com



2011-03-03  Steve Ellcey  

* config/ia64/t-hpux: Add $(srcdir)/unwind-c.c to LIB2ADDEH


Index: config/ia64/t-hpux
===
--- config/ia64/t-hpux  (revision 170637)
+++ config/ia64/t-hpux  (working copy)
@@ -50,7 +50,7 @@
 
 T_CFLAGS += -DUSE_LIBUNWIND_EXCEPTIONS
 
-LIB2ADDEH =
+LIB2ADDEH = $(srcdir)/unwind-c.c
 
 SHLIB_EXT = .so
 # Must include -lunwind in the link, so that libgcc_s.so has the necessary


[gomp3.1] C/C++ min/max reductions

2011-03-03 Thread Jakub Jelinek
Hi!

This patch adds min/max reduction support for C/C++, which was quite easy
given that the middle-end already needs to support it for Fortran.

Tested on x86_64-linux, committed to gomp-3_1-branch.

2011-03-03  Jakub Jelinek  

* c-parser.c (c_parser_omp_clause_reduction): Handle min and max.
* c-typeck.c (c_finish_omp_clauses): Handle MIN_EXPR and MAX_EXPR.

* parser.c (cp_parser_omp_clause_reduction): Handle min and max.
* semantics.c (finish_omp_clauses): Handle MIN_EXPR and MAX_EXPR.

* testsuite/libgomp.c/reduction-6.c: New test.
* testsuite/libgomp.c++/reduction-4.C: New test.

--- gcc/c-parser.c.jj   2011-03-03 16:57:07.0 +0100
+++ gcc/c-parser.c  2011-03-03 19:49:05.0 +0100
@@ -8692,7 +8692,12 @@ c_parser_omp_clause_private (c_parser *p
reduction ( reduction-operator : variable-list )
 
reduction-operator:
- One of: + * - & ^ | && || */
+ One of: + * - & ^ | && ||
+ 
+   OpenMP 3.1:
+   
+   reduction-operator:
+ One of: + * - & ^ | && || max min  */
 
 static tree
 c_parser_omp_clause_reduction (c_parser *parser, tree list)
@@ -8728,10 +8733,26 @@ c_parser_omp_clause_reduction (c_parser 
case CPP_OR_OR:
  code = TRUTH_ORIF_EXPR;
  break;
+case CPP_NAME:
+ {
+   const char *p
+ = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+   if (strcmp (p, "min") == 0)
+ {
+   code = MIN_EXPR;
+   break;
+ }
+   if (strcmp (p, "max") == 0)
+ {
+   code = MAX_EXPR;
+   break;
+ }
+ }
+ /* FALLTHRU */
default:
  c_parser_error (parser,
  "expected %<+%>, %<*%>, %<-%>, %<&%>, "
- "%<^%>, %<|%>, %<&&%>, or %<||%>");
+ "%<^%>, %<|%>, %<&&%>, %<||%>, % or %");
  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0);
  return list;
}
--- gcc/c-typeck.c.jj   2011-02-24 14:20:36.0 +0100
+++ gcc/c-typeck.c  2011-03-03 19:27:19.0 +0100
@@ -10441,6 +10441,8 @@ c_finish_omp_clauses (tree clauses)
case PLUS_EXPR:
case MULT_EXPR:
case MINUS_EXPR:
+   case MIN_EXPR:
+   case MAX_EXPR:
  break;
case BIT_AND_EXPR:
  r_name = "&";
--- gcc/cp/parser.c.jj  2011-02-24 14:18:07.0 +0100
+++ gcc/cp/parser.c 2011-03-03 19:48:52.0 +0100
@@ -23683,7 +23683,12 @@ cp_parser_omp_clause_ordered (cp_parser 
reduction ( reduction-operator : variable-list )
 
reduction-operator:
- One of: + * - & ^ | && || */
+ One of: + * - & ^ | && ||
+
+   OpenMP 3.1:
+
+   reduction-operator:
+ One of: + * - & ^ | && || min max  */
 
 static tree
 cp_parser_omp_clause_reduction (cp_parser *parser, tree list)
@@ -23720,9 +23725,26 @@ cp_parser_omp_clause_reduction (cp_parse
 case CPP_OR_OR:
   code = TRUTH_ORIF_EXPR;
   break;
+case CPP_NAME:
+  {
+   tree id = cp_lexer_peek_token (parser->lexer)->u.value;
+   const char *p = IDENTIFIER_POINTER (id);
+
+   if (strcmp (p, "min") == 0)
+ {
+   code = MIN_EXPR;
+   break;
+ }
+   if (strcmp (p, "max") == 0)
+ {
+   code = MAX_EXPR;
+   break;
+ }
+  }
+  /* FALLTHROUGH */
 default:
   cp_parser_error (parser, "expected %<+%>, %<*%>, %<-%>, %<&%>, %<^%>, "
-  "%<|%>, %<&&%>, or %<||%>");
+  "%<|%>, %<&&%>, %<||%>, % or %");
 resync_fail:
   cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
 /*or_comma=*/false,
--- gcc/cp/semantics.c.jj   2011-02-28 19:27:17.0 +0100
+++ gcc/cp/semantics.c  2011-03-03 19:50:38.0 +0100
@@ -3893,6 +3893,8 @@ finish_omp_clauses (tree clauses)
case PLUS_EXPR:
case MULT_EXPR:
case MINUS_EXPR:
+   case MIN_EXPR:
+   case MAX_EXPR:
  break;
default:
  error ("%qE has invalid type for %",
--- libgomp/testsuite/libgomp.c/reduction-6.c.jj2011-03-03 
19:44:19.0 +0100
+++ libgomp/testsuite/libgomp.c/reduction-6.c   2011-03-03 19:43:38.0 
+0100
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+extern void abort (void);
+int j;
+float f;
+
+int
+main ()
+{
+  j = -1;
+  f = 1024.0;
+  int i;
+  #pragma omp parallel for reduction (min:f) reduction (max:j)
+for (i = 0; i < 4; i++)
+  switch (i)
+   {
+   case 0:
+ if (j < -16) j = -16; break;
+   case 1:
+ if (f > -2.0) f = -2.0; break;
+   case 2:
+ if (j < 8) j = 8; if (f > 9.0) f = 9.0; break;
+   case 3:
+ break;
+

[PATCH, i386] Fix wrong mode in pmaddubsw instruction pattern

2011-03-03 Thread Uros Bizjak
On Thu, Mar 3, 2011 at 3:29 PM, Uros Bizjak  wrote:

>> When I read sse.md, I find there is a type error in vpmaddubsw
>> define_insn pattern.
>> Attached is the patch that fix the type error.
>> Is it OK to commit to 4.6 trunk?
>
> The same problem is with ssse3_pmadddubsw128 pattern.  Can you also
> provide the ChangeLog for the patch and how you test the change?

Attached patch fixes all problems found with the mode of VEC_SELECT
RTXes in pmaddubsw patterns.

2011-03-03  Uros Bizjak  

* config/i386/sse.md (*avx_pmaddubsw128): Fix mode of VEC_SELECT RTX.
(ssse3_pmaddubsw128): Ditto.
(ssse3_pmaddubsw): Ditto.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
{,-m32} and will be committed to 4.6, 4.5 and 4.4 branches.

Thanks,
Uros.
Index: sse.md
===
--- sse.md  (revision 170658)
+++ sse.md  (working copy)
@@ -8885,7 +8885,7 @@
(ss_plus:V8HI
  (mult:V8HI
(zero_extend:V8HI
- (vec_select:V4QI
+ (vec_select:V8QI
(match_operand:V16QI 1 "register_operand" "x")
(parallel [(const_int 0)
   (const_int 2)
@@ -8908,7 +8908,7 @@
   (const_int 14)]
  (mult:V8HI
(zero_extend:V8HI
- (vec_select:V16QI (match_dup 1)
+ (vec_select:V8QI (match_dup 1)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)
@@ -8918,7 +8918,7 @@
   (const_int 13)
   (const_int 15)])))
(sign_extend:V8HI
- (vec_select:V16QI (match_dup 2)
+ (vec_select:V8QI (match_dup 2)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)
@@ -8939,7 +8939,7 @@
(ss_plus:V8HI
  (mult:V8HI
(zero_extend:V8HI
- (vec_select:V4QI
+ (vec_select:V8QI
(match_operand:V16QI 1 "register_operand" "0")
(parallel [(const_int 0)
   (const_int 2)
@@ -8962,7 +8962,7 @@
   (const_int 14)]
  (mult:V8HI
(zero_extend:V8HI
- (vec_select:V16QI (match_dup 1)
+ (vec_select:V8QI (match_dup 1)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)
@@ -8972,7 +8972,7 @@
   (const_int 13)
   (const_int 15)])))
(sign_extend:V8HI
- (vec_select:V16QI (match_dup 2)
+ (vec_select:V8QI (match_dup 2)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)
@@ -9009,13 +9009,13 @@
   (const_int 6)]
  (mult:V4HI
(zero_extend:V4HI
- (vec_select:V8QI (match_dup 1)
+ (vec_select:V4QI (match_dup 1)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)
   (const_int 7)])))
(sign_extend:V4HI
- (vec_select:V8QI (match_dup 2)
+ (vec_select:V4QI (match_dup 2)
(parallel [(const_int 1)
   (const_int 3)
   (const_int 5)


libiberty/cplus-dem.c, ada-demangle: plug memory leak.

2011-03-03 Thread Michael Snyder

We don't have a separate libiberty list, do we?

2011-03-03  Michael Snyder  

* libiberty/cplus-dem.c (ada_demangle): Stop memory leak.
Also fix a one line indent problem.

Index: cplus-dem.c
===
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 cplus-dem.c
--- cplus-dem.c 3 Jan 2011 21:05:58 -   1.52
+++ cplus-dem.c 3 Mar 2011 21:13:49 -
@@ -883,7 +883,7 @@ ada_demangle (const char *mangled, int o
   int len0;
   const char* p;
   char *d;
-  char *demangled;
+  char *demangled = NULL;
   
   /* Discard leading _ada_, which is used for library level subprograms.  */
   if (strncmp (mangled, "_ada_", 5) == 0)
@@ -1129,10 +1129,11 @@ ada_demangle (const char *mangled, int o
 
  unknown:
   len0 = strlen (mangled);
+  xfree (demangled);
   demangled = XNEWVEC (char, len0 + 3);
 
   if (mangled[0] == '<')
- strcpy (demangled, mangled);
+strcpy (demangled, mangled);
   else
 sprintf (demangled, "<%s>", mangled);
 


Re: libiberty/cplus-dem.c, ada-demangle: plug memory leak.

2011-03-03 Thread Jakub Jelinek
On Thu, Mar 03, 2011 at 01:20:28PM -0800, Michael Snyder wrote:
> 2011-03-03  Michael Snyder  
> 
>   * libiberty/cplus-dem.c (ada_demangle): Stop memory leak.
>   Also fix a one line indent problem.

No libiberty/ in libiberty/ChangeLog.

> @@ -1129,10 +1129,11 @@ ada_demangle (const char *mangled, int o
>  
>   unknown:
>len0 = strlen (mangled);
> +  xfree (demangled);
>demangled = XNEWVEC (char, len0 + 3);

xfree isn't ever used in libiberty/*, use either free, or
XDELETE/XDELETEVEC.  In fact, it seems to be defined only in gdb,
making cplus-dem.c dependent on gdb is obviously a wrong thing.

Jakub


Re: libiberty/cplus-dem.c, ada-demangle: plug memory leak.

2011-03-03 Thread Michael Snyder

Jakub Jelinek wrote:

On Thu, Mar 03, 2011 at 01:20:28PM -0800, Michael Snyder wrote:

2011-03-03  Michael Snyder  

* libiberty/cplus-dem.c (ada_demangle): Stop memory leak.
Also fix a one line indent problem.


No libiberty/ in libiberty/ChangeLog.


@@ -1129,10 +1129,11 @@ ada_demangle (const char *mangled, int o
 
  unknown:

   len0 = strlen (mangled);
+  xfree (demangled);
   demangled = XNEWVEC (char, len0 + 3);


xfree isn't ever used in libiberty/*, use either free, or
XDELETE/XDELETEVEC.  In fact, it seems to be defined only in gdb,
making cplus-dem.c dependent on gdb is obviously a wrong thing.


Thanks for the review.

How's this?

2011-03-03  Michael Snyder  

* cplus-dem.c (ada_demangle): Stop memory leak.
Also fix a one line indent problem.

Index: cplus-dem.c
===
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.52
diff -u -p -u -p -r1.52 cplus-dem.c
--- cplus-dem.c 3 Jan 2011 21:05:58 -   1.52
+++ cplus-dem.c 3 Mar 2011 21:59:08 -
@@ -883,7 +883,7 @@ ada_demangle (const char *mangled, int o
   int len0;
   const char* p;
   char *d;
-  char *demangled;
+  char *demangled = NULL;
   
   /* Discard leading _ada_, which is used for library level subprograms.  */
   if (strncmp (mangled, "_ada_", 5) == 0)
@@ -1129,10 +1129,12 @@ ada_demangle (const char *mangled, int o
 
  unknown:
   len0 = strlen (mangled);
+  if (demangled != NULL)
+free (demangled);
   demangled = XNEWVEC (char, len0 + 3);
 
   if (mangled[0] == '<')
- strcpy (demangled, mangled);
+strcpy (demangled, mangled);
   else
 sprintf (demangled, "<%s>", mangled);
 


[RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder

As written, the function will access element [30] of a 30-element array.

OK?

2011-03-03  Michael Snyder  

* hashtab.c (higher_prime_index): Prevent array overrun.

Index: hashtab.c
===
RCS file: /cvs/src/src/libiberty/hashtab.c,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 hashtab.c
--- hashtab.c   3 Feb 2011 07:23:59 -   1.38
+++ hashtab.c   3 Mar 2011 22:01:08 -
@@ -173,9 +173,9 @@ static unsigned int
 higher_prime_index (unsigned long n)
 {
   unsigned int low = 0;
-  unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]);
+  unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]) - 1;
 
-  while (low != high)
+  while (low < high)
 {
   unsigned int mid = low + (high - low) / 2;
   if (n > prime_tab[mid].prime)


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie

> As written, the function will access element [30] of a 30-element array.

Um, no?

  unsigned int mid = low + (high - low) / 2;

This can never give mid == high unless low == high, which won't happen
in that loop.

The math wants to search everything from (including) low to
(excluding) high.

(but I'm willing to be proven wrong...)


Fix !EXIT_IGNORE_STACK vs over-aligned variables

2011-03-03 Thread Richard Henderson
DJ reported this yesterday on m32c, but this would affect all such
targets: mcore, m32c, arc, h8300, m68hc11.

In my opinion, we ought to work with these targets to add the few
insns to their epilogue to handle alloca, rather than keep these
very infrequently used code paths.  Material for 4.7, for sure.

In the meantime, I need to get the emit_stack_save code emitted
at the right place at the start of the function.  The problem was
that cfgexpand.c was expecting to emit the sequence *before* the
mark, whereas function.c was actually emitting the sequence after
the mark.

I tried rearranging cfgexpand such that the mark was set so that
we could continue to insert afterward, but this resulted in an ICE
due to insertting the sequence outside any basic block.  In such
cases, we really don't have a viable location against which we 
can set the mark.

Then I changed things such that we insert before the mark.  This
worked.  If we're not doing over-alignement, this means that we
insert code before the FUNCTION_BEG note rather than after.  I 
think this is ok -- the save is logically part of the prologue.

At which point I needed to audit the other users of emit_stack_save
to figure out if the change to insert before is ok.  It turns out
that the one use in function.c is the only user that provided a 
non-null 'after' parameter.  Further, *no* user of emit_stack_restore
provided a non-null 'after' parameter.

So I've removed the after parameter from both emit_stack_save and
emit_stack_restore, adjusted all users, and changed the use in
function.c to do the sequence manipulation itself.

Tested on m32c-elf and x86_64-linux.  Committed.


r~
* explow.c (emit_stack_save): Remove 'after' parameter.
(emit_stack_restore): Likewise.
* expr.h: Update to match.
* builtins.c, calls.c, stmt.c: Likewise.
* config/alpha/alpha.md, config/avr/avr.md: Likewise.
* config/mips/mips.md, config/pa/pa.md, config/vax/vax.md: Likewise.
* function.c (expand_function_end): Insert the emit_stack_save
sequence before parm_birth_insn instead of after.


diff --git a/gcc/builtins.c b/gcc/builtins.c
index 106b2ca..3361264 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -784,7 +784,7 @@ expand_builtin_setjmp_setup (rtx buf_addr, rtx 
receiver_label)
plus_constant (buf_addr,
   2 * GET_MODE_SIZE (Pmode)));
   set_mem_alias_set (stack_save, setjmp_alias_set);
-  emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX);
+  emit_stack_save (SAVE_NONLOCAL, &stack_save);
 
   /* If there is further processing to do, do it.  */
 #ifdef HAVE_builtin_setjmp_setup
@@ -932,7 +932,7 @@ expand_builtin_longjmp (rtx buf_addr, rtx value)
  emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
 
  emit_move_insn (hard_frame_pointer_rtx, fp);
- emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
+ emit_stack_restore (SAVE_NONLOCAL, stack);
 
  emit_use (hard_frame_pointer_rtx);
  emit_use (stack_pointer_rtx);
@@ -1005,7 +1005,7 @@ expand_builtin_nonlocal_goto (tree exp)
 The non-local goto handler will then adjust it to contain the
 proper value and reload the argument pointer, if needed.  */
   emit_move_insn (hard_frame_pointer_rtx, r_fp);
-  emit_stack_restore (SAVE_NONLOCAL, r_sp, NULL_RTX);
+  emit_stack_restore (SAVE_NONLOCAL, r_sp);
 
   /* USE of hard_frame_pointer_rtx added for consistency;
 not clear if really needed.  */
@@ -1075,7 +1075,7 @@ expand_builtin_update_setjmp_buf (rtx buf_addr)
 emit_insn (gen_setjmp ());
 #endif
 
-  emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX);
+  emit_stack_save (SAVE_NONLOCAL, &stack_save);
 }
 
 /* Expand a call to __builtin_prefetch.  For a target that does not support
@@ -1558,10 +1558,10 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
   /* Save the stack with nonlocal if available.  */
 #ifdef HAVE_save_stack_nonlocal
   if (HAVE_save_stack_nonlocal)
-emit_stack_save (SAVE_NONLOCAL, &old_stack_level, NULL_RTX);
+emit_stack_save (SAVE_NONLOCAL, &old_stack_level);
   else
 #endif
-emit_stack_save (SAVE_BLOCK, &old_stack_level, NULL_RTX);
+emit_stack_save (SAVE_BLOCK, &old_stack_level);
 
   /* Allocate a block of memory onto the stack and copy the memory
  arguments to the outgoing arguments address.  We can pass TRUE
@@ -1677,10 +1677,10 @@ expand_builtin_apply (rtx function, rtx arguments, rtx 
argsize)
   /* Restore the stack.  */
 #ifdef HAVE_save_stack_nonlocal
   if (HAVE_save_stack_nonlocal)
-emit_stack_restore (SAVE_NONLOCAL, old_stack_level, NULL_RTX);
+emit_stack_restore (SAVE_NONLOCAL, old_stack_level);
   else
 #endif
-emit_stack_restore (SAVE_BLOCK, old_stack_level, NULL_RTX);
+emit_stack_restore (SAVE_BLOCK, old_stack_level);
 
   OK_DEFER_POP;
 
diff --git a/gcc/calls.c b/gcc/calls.c
index 5297763..f539f6

Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder

DJ Delorie wrote:

As written, the function will access element [30] of a 30-element array.


Um, no?


Y-uh-huh!


  unsigned int mid = low + (high - low) / 2;

This can never give mid == high unless low == high, which won't happen
in that loop.

The math wants to search everything from (including) low to
(excluding) high.

(but I'm willing to be proven wrong...)


I am willing to do that!   ;-)

Compile this program, run it under gdb with the input "0x", and 
step through the code.  You will see it assign the value "30" to "low" 
and use it to access the array.


I suppose you could do it directly just by loading gdb into gdb,
putting a breakpoint at the above function, and then calling it
from gdb with the input 0x.




#include 
#include 

typedef unsigned int hashval_t;

struct prime_ent
{
  hashval_t prime;
  hashval_t inv;
  hashval_t inv_m2; /* inverse of prime-2 */
  hashval_t shift;
};

static struct prime_ent const prime_tab[] = {
  {  7, 0x24924925, 0x999b, 2 },
  { 13, 0x3b13b13c, 0x745d1747, 3 },
  { 31, 0x08421085, 0x1a7b9612, 4 },
  { 61, 0x0c9714fc, 0x15b1e5f8, 5 },
  {127, 0x02040811, 0x0624dd30, 6 },
  {251, 0x05197f7e, 0x073260a5, 7 },
  {509, 0x01824366, 0x02864fc8, 8 },
  {   1021, 0x00c0906d, 0x014191f7, 9 },
  {   2039, 0x0121456f, 0x0161e69e, 10 },
  {   4093, 0x00300902, 0x00501908, 11 },
  {   8191, 0x00080041, 0x00180241, 12 },
  {  16381, 0x000c0091, 0x00140191, 13 },
  {  32749, 0x002605a5, 0x002a06e6, 14 },
  {  65521, 0x000f00e2, 0x00110122, 15 },
  { 131071, 0x8001, 0x00018003, 16 },
  { 262139, 0x00014002, 0x0001c004, 17 },
  { 524287, 0x2001, 0x6001, 18 },
  {1048573, 0x3001, 0x5001, 19 },
  {2097143, 0x4801, 0x5801, 20 },
  {4194301, 0x0c01, 0x1401, 21 },
  {8388593, 0x1e01, 0x2201, 22 },
  {   16777213, 0x0301, 0x0501, 23 },
  {   33554393, 0x1381, 0x1481, 24 },
  {   67108859, 0x0141, 0x01c1, 25 },
  {  134217689, 0x04e1, 0x0521, 26 },
  {  268435399, 0x0391, 0x03b1, 27 },
  {  536870909, 0x0019, 0x0029, 28 },
  { 1073741789, 0x008d, 0x0095, 29 },
  { 2147483647, 0x0003, 0x0007, 30 },
  /* Avoid "decimal constant so large it is unsigned" for 4294967291.  */
  { 0xfffb, 0x0006, 0x0008, 31 }
};

static unsigned int
higher_prime_index (unsigned long n)
{
  unsigned int low = 0;
  unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]);

  while (low != high)
{
  unsigned int mid = low + (high - low) / 2;
  if (n > prime_tab[mid].prime)
low = mid + 1;
  else
high = mid;
}

  /* If we've run out of primes, abort.  */
  if (n > prime_tab[low].prime)
{
  fprintf (stderr, "Cannot find prime bigger than %lu\n", n);
  abort ();
}

  return low;
}


int
main (int argc, char **argv)
{
  if (argc < 2)
{
  fprintf (stderr, "Usage: hash \n");
  return 1;
}

  printf ("Answer: %d\n", higher_prime_index (strtoul (argv[1], NULL, 0)));
  return 0;
}


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder

DJ Delorie wrote:

As written, the function will access element [30] of a 30-element array.


Um, no?

  unsigned int mid = low + (high - low) / 2;

This can never give mid == high unless low == high, which won't happen
in that loop.

The math wants to search everything from (including) low to
(excluding) high.

(but I'm willing to be proven wrong...)



Whee, here we go...


(gdb) b higher_prime_index
Breakpoint 2 at 0x79bed4: file 
/data/home/msnyder/cvs/localhost/src/libiberty/hashtab.c, line 175.

(gdb) print higher_prime_index(0x)

Breakpoint 2, higher_prime_index (n=4294967295)
at /data/home/msnyder/cvs/localhost/src/libiberty/hashtab.c:175
175   unsigned int low = 0;
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(higher_prime_index) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) n
176   unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]) - 1;
(gdb)
178   while (low < high)
(gdb)
180   unsigned int mid = low + (high - low) / 2;
(gdb) display low
1: low = 0
(gdb) n
181   if (n > prime_tab[mid].prime)
1: low = 0
(gdb)
182 low = mid + 1;
1: low = 0(gdb) b higher_prime_index
Breakpoint 2 at 0x79bed4: file 
/data/home/msnyder/cvs/localhost/src/libiberty/hashtab.c, line 175.

(gdb) print higher_prime_index(0x)

Breakpoint 2, higher_prime_index (n=4294967295)
at /data/home/msnyder/cvs/localhost/src/libiberty/hashtab.c:175
175   unsigned int low = 0;
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(higher_prime_index) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) n
176   unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]) - 1;
(gdb)
178   while (low < high)
(gdb)
180   unsigned int mid = low + (high - low) / 2;
(gdb) display low
1: low = 0
(gdb) n
181   if (n > prime_tab[mid].prime)
1: low = 0
(gdb)
182 low = mid + 1;
1: low = 0
(gdb)
178   while (low < high)
1: low = 16
(gdb)
180   unsigned int mid = low + (high - low) / 2;
1: low = 16
(gdb)
181   if (n > prime_tab[mid].prime)
1: low = 16
(gdb)
182 low = mid + 1;

(gdb)
178   while (low < high)
1: low = 16
(gdb)
180   unsigned int mid = low + (high - low) / 2;
1: low = 16
(gdb)
181   if (n > prime_tab[mid].prime)
1: low = 16
(gdb)
182 low = mid + 1;
1: low = 16
(gdb)
178   while (low < high)
1: low = 24
(gdb)
180   unsigned int mid = low + (high - low) / 2;
1: low = 24
(gdb)
181   if (n > prime_tab[mid].prime)
1: low = 24
(gdb)
182 low = mid + 1;
1: low = 24
(gdb)
178   while (low < high)
1: low = 28
(gdb)
180   unsigned int mid = low + (high - low) / 2;
1: low = 28
(gdb)
181   if (n > prime_tab[mid].prime)
1: low = 28
(gdb)
182 low = mid + 1;
1: low = 28
(gdb)
178   while (low < high)
1: low = 30
(gdb)
188   if (n > prime_tab[low].prime)
1: low = 30
(gdb)


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie

Bizzare, the problem isn't the hash loop, it's the error handler at
the end!  It never uses [30] for the main loop, only if you give it a
number between 0xfffb and 0x - and in the case where it
would use [30], it's supposed to abort anyway.

I couldn't figure out why your patch worked until I realized that the
main loop still fails!  It works because the error handler just
doesn't abort, returning the last array entry, which happens to be the
right one.

I think a suitable comment explaining what's actually going on, and
why it still works, is warranted... but your patch is OK with me
otherwise :-)


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Mike Stump
On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote:
> DJ Delorie wrote:
>>> As written, the function will access element [30] of a 30-element array.
>> Um, no?
> 
> Y-uh-huh!

fight fight fight...  :-)  There can be only one.


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Michael Snyder

Mike Stump wrote:

On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote:

DJ Delorie wrote:

As written, the function will access element [30] of a 30-element array.

Um, no?

Y-uh-huh!


fight fight fight...  :-)  There can be only one.


Oh, did I forget the smiley?   ;-)




Re: build_function_call and TREE_ADDRESSABLE

2011-03-03 Thread Alan Modra
On Thu, Mar 03, 2011 at 04:43:15PM +0100, Richard Guenther wrote:
> On Thu, Mar 3, 2011 at 4:42 PM, Richard Guenther
>  wrote:
> > On Thu, Mar 3, 2011 at 3:33 PM, Alan Modra  wrote:
> >> TREE_ADDRESSABLE comment says "In a FUNCTION_DECL, nonzero means its
> >> address is needed".  However, as I point out in
> >> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html, this flag
> >> gets set when making normal calls.  It wasn't always like this.
> >> gcc-4.0 was careful to not set TREE_ADDRESSABLE on FUNCTION_DECLs in
> >> build_function_call, a feature lost in revision 100984.  I'd like to
> >> have that feature back for the above patch.  Bootstrapped and
> >> regression tested powerpc-linux.  OK for 4.6?
> >
> > You'll get the addressable flag re-applied by the operand scanner.

Eh?  I didn't see that happening.  Are you confusing the FUNCTION_TYPE
node with the FUNCTION_DECL?

> The proper way to check "if its address is needed" is via cgraph
> predicates.

That was the first thing that occurred to me too.  Then I noticed

Breakpoint 1, init_cumulative_args (cum=0xe620, fntype=0xf7eee540, 
libname=0x0, incoming=1, libcall=0, n_named_args=1000, fndecl=0xf7f51100, 
return_mode=VOIDmode) at 
/home/alan/src/gcc-current/gcc/config/rs6000/rs6000.c:7896
(gdb) up
#1  0x103c10a0 in assign_parms_initialize_all (all=0xe620) at 
/home/alan/src/gcc-current/gcc/function.c:2195
(gdb) 
#2  0x103c6bb4 in gimplify_parameters () at 
/home/alan/src/gcc-current/gcc/function.c:3576
(gdb) 
#3  0x1040fa88 in gimplify_body (body_p=0xf7f5115c, fndecl=0xf7f51100, 
do_parms=) at 
/home/alan/src/gcc-current/gcc/gimplify.c:7706
(gdb) 
#4  0x1040fd64 in gimplify_function_tree (fndecl=0xf7f51100) at 
/home/alan/src/gcc-current/gcc/gimplify.c:7846
(gdb) 
#5  0x1076457c in cgraph_analyze_function (node=0xf7ed22b8) at 
/home/alan/src/gcc-current/gcc/cgraphunit.c:797

That scared me away from that idea.  Hmm, I guess all I need to do is
check cgraph node->analyzed.

-- 
Alan Modra
Australia Development Lab, IBM


Re: [PING^2] [PR46003, C++] Fix the assertion failure in build_target_expr

2011-03-03 Thread Jason Merrill

On 03/02/2011 12:53 PM, Yufeng Zhang wrote:

The calls to build_cplus_new in convert_like_real don't seem to be
redundant.


Hmm, I guess you're right.  I think rather that the problem is in 
build_conditional_expr; it should have a template case that just 
determines the appropriate type and then builds up a COND_EXPR with that 
type from the unconverted operands, like we do for calls in 
finish_call_expr.


Jason


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread Dave Korn
On 03/03/2011 23:00, Mike Stump wrote:
> On Mar 3, 2011, at 2:26 PM, Michael Snyder wrote:
>> DJ Delorie wrote:
 As written, the function will access element [30] of a 30-element array.
>>> Um, no?
>> Y-uh-huh!
> 
> fight fight fight...  :-)  There can be only one.

  I was just wondering whether now would be a good time to mention that having
prime-sized hash tables is only a workaround against the danger of someone
providing an inadequate hash function implementation in the first place?

cheers,
  DaveK



Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-03 Thread DJ Delorie

>   I was just wondering whether now would be a good time to mention

Probably not, gcc being in stage 4 and all...


Re: [PATCH, i386 AVX] Type error in vpmaddubsw instruction pattern

2011-03-03 Thread Liu
On Thursday, March 3, 2011, Uros Bizjak  wrote:
> On Thu, Mar 3, 2011 at 12:11 PM, Liu  wrote:
>
>> When I read sse.md, I find there is a type error in vpmaddubsw
>> define_insn pattern.
>> Attached is the patch that fix the type error.
>> Is it OK to commit to 4.6 trunk?
>
> The same problem is with ssse3_pmadddubsw128 pattern.  Can you also
> provide the ChangeLog for the patch and how you test the change?
>
> Thanks,
> Uros.
>

Hi Uros,
When I get my office this morning, run "svn up" in gcc tree, I see
that you have fixed it yesterday:)

Thanks,
Liu.


[4.7] Avoid global state in iq2000_handle_option

2011-03-03 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the IQ2000 handle_option hook from using global state.  Because
all the hook did was handle fixed sets of arguments to particular
options (setting a variable for one, ignoring the other), the handling
is converted to use the Enum .opt failure, with a .opt Variable entry
for the variable the code previously set.  In the case of the -march=
option, whose arguments were checked but otherwise ignored, Enum is
used without Var (a valid, if unusual, combination of .opt features)
so that the option continues to check but otherwise ignore its
argument.

Tested building cc1 and xgcc for cross to iq2000-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-03  Joseph Myers  

* config/iq2000/iq2000-opts.h: New.
* config/iq2000/iq2000.c: Don't include opts.h.
(iq2000_tune, iq2000_handle_option, TARGET_HANDLE_OPTION): Remove.
* config/iq2000/iq2000.h (enum processor_type, iq2000_tune):
Remove.
* config/iq2000/iq2000.opt (config/iq2000/iq2000-opts.h): New
HeaderInclude entry.
(iq2000_tune): New Variable entry.
(march=): Add comment.  Use Enum.
(iq2000_arch): New Enum and EnumValue entries.
(mcpu=): Use Enum and Var.
(iq2000_tune): New Enum and EnumValue entries.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/iq2000/iq2000-opts.h 
gcc-mainline/gcc/config/iq2000/iq2000-opts.h
--- gcc-mainline-1/gcc/config/iq2000/iq2000-opts.h  1969-12-31 
16:00:00.0 -0800
+++ gcc-mainline/gcc/config/iq2000/iq2000-opts.h2011-03-03 
10:20:14.0 -0800
@@ -0,0 +1,33 @@
+/* Definitions for option handling for Vitesse IQ2000 processors.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+#ifndef IQ2000_OPTS_H
+#define IQ2000_OPTS_H
+
+/* Which processor to schedule for.  */
+
+enum processor_type
+{
+  PROCESSOR_DEFAULT,
+  PROCESSOR_IQ2000,
+  PROCESSOR_IQ10
+};
+
+#endif
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/iq2000/iq2000.c 
gcc-mainline/gcc/config/iq2000/iq2000.c
--- gcc-mainline-1/gcc/config/iq2000/iq2000.c   2011-02-23 15:50:10.0 
-0800
+++ gcc-mainline/gcc/config/iq2000/iq2000.c 2011-03-03 10:27:50.0 
-0800
@@ -45,7 +45,6 @@ along with GCC; see the file COPYING3.  
 #include "target-def.h"
 #include "langhooks.h"
 #include "df.h"
-#include "opts.h"
 
 /* Enumeration for all of the relational tests, so that we can build
arrays indexed by the test type, and not worry about the order
@@ -112,9 +111,6 @@ struct GTY(()) machine_function
 /* List of all IQ2000 punctuation characters used by iq2000_print_operand.  */
 static char iq2000_print_operand_punct[256];
 
-/* The target cpu for optimization and scheduling.  */
-enum processor_type iq2000_tune;
-
 /* Which instruction set architecture to use.  */
 int iq2000_isa;
 
@@ -146,10 +142,6 @@ static enum machine_mode gpr_mode;
 
 /* Initialize the GCC target structure.  */
 static struct machine_function* iq2000_init_machine_status (void);
-static bool iq2000_handle_option  (struct gcc_options *,
-  struct gcc_options *,
-  const struct cl_decoded_option *,
-  location_t);
 static void iq2000_option_override(void);
 static section *iq2000_select_rtx_section (enum machine_mode, rtx,
   unsigned HOST_WIDE_INT);
@@ -197,8 +189,6 @@ static const struct default_options iq20
 #define TARGET_EXPAND_BUILTIN  iq2000_expand_builtin
 #undef  TARGET_ASM_SELECT_RTX_SECTION
 #define TARGET_ASM_SELECT_RTX_SECTION  iq2000_select_rtx_section
-#undef  TARGET_HANDLE_OPTION
-#define TARGET_HANDLE_OPTION   iq2000_handle_option
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE iq2000_option_override
 #undef  TARGET_OPTION_OPTIMIZATION_TABLE
@@ -1438,41 +1428,6 @@ iq2000_init_machine_status (void)
   return ggc_alloc_cleared_machine_function ();
 }
 
-/* Implement TARGET_HANDLE_OPTION.  */
-
-static bool
-iq2000_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
-   

[4.7] Avoid global state in m32c_handle_option

2011-03-03 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the M32C handle_option hook from using global state.  All the
hook did was process an integer argument and set a variable to
indicate that the option had been used explicitly; this can all be
done with .opt features, so the hook is removed and replaced with use
of UInteger in m32c.opt (nothing made any use of the string variable
previously set by the option through use of Var there without
UInteger).  (This means that there is now error checking that the
argument actually has the syntax of a nonnegative integer rather than
blindly passing any argument to atoi.  So there's one fewer use of
atoi that will need removing to fix PR 44574.)

Tested building cc1 and xgcc for cross to m32c-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-03  Joseph Myers  

* config/m32c/m32c.c: Don't include opts.h.
(target_memregs, target_memregs_set, TARGET_HANDLE_OPTION,
m32c_handle_option): Remove.
(m32c_option_override): Check global_options_set.x_target_memregs
instead of target_memregs_set.
* config/m32c/m32c.h (target_memregs): Remove.
* config/m32c/m32c.opt (memregs=): Use UInteger with integer
variable.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/m32c/m32c.c 
gcc-mainline/gcc/config/m32c/m32c.c
--- gcc-mainline-1/gcc/config/m32c/m32c.c   2011-02-23 16:00:03.0 
-0800
+++ gcc-mainline/gcc/config/m32c/m32c.c 2011-03-03 17:14:56.0 -0800
@@ -48,7 +48,6 @@
 #include "langhooks.h"
 #include "gimple.h"
 #include "df.h"
-#include "opts.h"
 
 /* Prototypes */
 
@@ -408,31 +407,8 @@ class_can_hold_mode (reg_class_t rclass,
Memregs are provided by m32c-lib1.S.
 */
 
-int target_memregs = 16;
-static bool target_memregs_set = FALSE;
 int ok_to_change_target_memregs = TRUE;
 
-#undef  TARGET_HANDLE_OPTION
-#define TARGET_HANDLE_OPTION m32c_handle_option
-static bool
-m32c_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
-   const struct cl_decoded_option *decoded,
-   location_t loc ATTRIBUTE_UNUSED)
-{
-  size_t code = decoded->opt_index;
-  const char *arg = decoded->arg;
-
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
-  if (code == OPT_memregs_)
-{
-  target_memregs_set = TRUE;
-  target_memregs = atoi (arg);
-}
-  return TRUE;
-}
-
 /* Implements TARGET_OPTION_OVERRIDE.  */
 
 #undef TARGET_OPTION_OVERRIDE
@@ -442,7 +418,7 @@ static void
 m32c_option_override (void)
 {
   /* We limit memregs to 0..16, and provide a default.  */
-  if (target_memregs_set)
+  if (global_options_set.x_target_memregs)
 {
   if (target_memregs < 0 || target_memregs > 16)
error ("invalid target memregs value '%d'", target_memregs);
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/m32c/m32c.h 
gcc-mainline/gcc/config/m32c/m32c.h
--- gcc-mainline-1/gcc/config/m32c/m32c.h   2011-02-16 15:01:11.0 
-0800
+++ gcc-mainline/gcc/config/m32c/m32c.h 2011-03-03 17:15:06.0 -0800
@@ -86,7 +86,6 @@
beginning of the file.  This variable starts off TRUE and later
becomes FALSE.  */
 extern int ok_to_change_target_memregs;
-extern int target_memregs;
 
 /* TARGET_CPU is a multi-way option set in m32c.opt.  While we could
use enums or defines for this, this and m32c.opt are the only
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/m32c/m32c.opt 
gcc-mainline/gcc/config/m32c/m32c.opt
--- gcc-mainline-1/gcc/config/m32c/m32c.opt 2009-03-28 00:38:02.0 
-0700
+++ gcc-mainline/gcc/config/m32c/m32c.opt   2011-03-03 17:14:10.0 
-0800
@@ -1,5 +1,5 @@
 ; Target Options for R8C/M16C/M32C
-; Copyright (C) 2005 2007
+; Copyright (C) 2005, 2007, 2011
 ; Free Software Foundation, Inc.
 ; Contributed by Red Hat.
 ;
@@ -40,5 +40,5 @@ Target RejectNegative Var(target_cpu,'3'
 -mcpu=m32c Compile code for M32C variants
 
 memregs=
-Target RejectNegative Joined Var(target_memregs_string)
+Target RejectNegative Joined UInteger Var(target_memregs) Init(16)
 -memregs=  Number of memreg bytes (default: 16, range: 0..16)

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


[4.7] Avoid global state in m32r_handle_option

2011-03-03 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the M32R handle_option hook from using global state.  Some
options are converted to using .opt features; in particular, -mmodel=
and -msdata= are converted to use Enum.  (Because variables in the
gcc_options structure get corresponding macro names, the m32r_model
and m32r_sdata variables needed renaming with an _selected suffix to
avoid conflict with the enum names.)

The Code Models and Small Data Areas sections of m32r.h had long
comments tht appear to apply to all the definitions there, so rather
than move just the minimum (the enum definitions) into m32r-opts.h,
away from the comments, I moved those whole sections into m32r-opts.h.

Tested building cc1 and xgcc for cross to m32r-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-03  Joseph Myers  

* config/m32r/m32r-opts.h: New.
* config/m32r/m32r.c (m32r_model, m32r_sdata): Remove.
(m32r_handle_option): Don't assert that global structures are in
use.  Access target_flags and m32r_cache_flush_func via opts
pointer.  Don't handle OPT_mmodel_, OPT_msdata_ or
OPT_mno_flush_trap here.
* config/m32r/m32r.h (Code Models, Small Data Area): Replace by
include of m32r-opts.h.
* config/m32r/m32r.opt (config/m32r/m32r-opts.h): New
HeaderInclude entry.
(m32r_model_selected, m32r_sdata_selected): New Variable entries.
(mmodel=): Use Enum and Var.
(m32r_model): New Enum and EnumValue entries.
(mno-flush-trap): Use Var.
(msdata=): Use Enum and Var.
(m32r_sdata): New Enum and EnumValue entries.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/m32r/m32r-opts.h 
gcc-mainline/gcc/config/m32r/m32r-opts.h
--- gcc-mainline-1/gcc/config/m32r/m32r-opts.h  1969-12-31 16:00:00.0 
-0800
+++ gcc-mainline/gcc/config/m32r/m32r-opts.h2011-03-03 18:02:55.0 
-0800
@@ -0,0 +1,109 @@
+/* Definitions for option handling for Renesas M32R cpu.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+#ifndef M32R_OPTS_H
+#define M32R_OPTS_H
+
+/* Code Models
+
+   Code models are used to select between two choices of two separate
+   possibilities (address space size, call insn to use):
+
+   small: addresses use 24 bits, use bl to make calls
+   medium: addresses use 32 bits, use bl to make calls (*1)
+   large: addresses use 32 bits, use seth/add3/jl to make calls (*2)
+
+   The fourth is "addresses use 24 bits, use seth/add3/jl to make calls" but
+   using this one doesn't make much sense.
+
+   (*1) The linker may eventually be able to relax seth/add3 -> ld24.
+   (*2) The linker may eventually be able to relax seth/add3/jl -> bl.
+
+   Internally these are recorded as TARGET_ADDR{24,32} and
+   TARGET_CALL{26,32}.
+
+   The __model__ attribute can be used to select the code model to use when
+   accessing particular objects.  */
+
+enum m32r_model { M32R_MODEL_SMALL, M32R_MODEL_MEDIUM, M32R_MODEL_LARGE };
+
+#define TARGET_MODEL_SMALL  (m32r_model_selected == M32R_MODEL_SMALL)
+#define TARGET_MODEL_MEDIUM (m32r_model_selected == M32R_MODEL_MEDIUM)
+#define TARGET_MODEL_LARGE  (m32r_model_selected == M32R_MODEL_LARGE)
+#define TARGET_ADDR24   (m32r_model_selected == M32R_MODEL_SMALL)
+#define TARGET_ADDR32   (! TARGET_ADDR24)
+#define TARGET_CALL26   (! TARGET_CALL32)
+#define TARGET_CALL32   (m32r_model_selected == M32R_MODEL_LARGE)
+
+/* The default is the small model.  */
+#ifndef M32R_MODEL_DEFAULT
+#define M32R_MODEL_DEFAULT M32R_MODEL_SMALL
+#endif
+
+/* Small Data Area
+
+   The SDA consists of sections .sdata, .sbss, and .scommon.
+   .scommon isn't a real section, symbols in it have their section index
+   set to SHN_M32R_SCOMMON, though support for it exists in the linker script.
+
+   Two switches control the SDA:
+
+   -G NNN- specifies the maximum size of variable to go in the SDA
+
+   -msdata=foo   - specifies how such variables are handled
+
+-msdata=none  - small data area is disabled
+
+-msdata=sdata - small data goes in the SDA, special code isn't
+

[4.7] Avoid global state in microblaze_handle_option

2011-03-03 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the Microblaze handle_option hook from using global state.
Everything the hook does - warnings and setting a variable also set by
another option - can be done using .opt features, so the hook is
removed and replaced by use of those features.

Tested building cc1 and xgcc for cross to microblaze-elf.  Will commit
to trunk for 4.7 in the absence of target maintainer objections.

2011-03-03  Joseph Myers  

* config/microblaze/microblaze.c: Don't include opts.h.
(microblaze_handle_option, TARGET_HANDLE_OPTION): Remove.
* config/microblaze/microblaze.opt (mxl-stack-check): Use Warn.
(mno-clearbss): Use Var and Warn.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/microblaze/microblaze.c 
gcc-mainline/gcc/config/microblaze/microblaze.c
--- gcc-mainline-1/gcc/config/microblaze/microblaze.c   2011-02-23 
18:23:27.0 -0800
+++ gcc-mainline/gcc/config/microblaze/microblaze.c 2011-03-03 
19:26:55.0 -0800
@@ -48,7 +48,6 @@
 #include "df.h"
 #include "optabs.h"
 #include "diagnostic-core.h"
-#include "opts.h"
 
 #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
 
@@ -1272,30 +1271,6 @@ microblaze_version_to_int (const char *v
   return iver;
 }
 
-static bool
-microblaze_handle_option (struct gcc_options *opts,
- struct gcc_options *opts_set,
- const struct cl_decoded_option *decoded,
- location_t loc ATTRIBUTE_UNUSED)
-{
-  size_t code = decoded->opt_index;
-
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
-  switch (code)
-{
-case OPT_mno_clearbss:
-  flag_zero_initialized_in_bss = 0;
-  warning (0, "-mno-clearbss is deprecated; use 
-fno-zero-initialized-in-bss");
-  break;
-case OPT_mxl_stack_check:
-  warning (0, "-mxl_stack_check is deprecated; use -fstack-check");
-  break;
-}
-  return true;
-}
-
 
 static void
 microblaze_option_override (void)
@@ -3007,9 +2982,6 @@ microblaze_adjust_cost (rtx insn ATTRIBU
 #define TARGET_ASM_FUNCTION_END_PROLOGUE \
 microblaze_function_end_prologue
 
-#undef TARGET_HANDLE_OPTION
-#define TARGET_HANDLE_OPTION   microblaze_handle_option
-
 #undef TARGET_DEFAULT_TARGET_FLAGS
 #define TARGET_DEFAULT_TARGET_FLAGSTARGET_DEFAULT
 
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/microblaze/microblaze.opt 
gcc-mainline/gcc/config/microblaze/microblaze.opt
--- gcc-mainline-1/gcc/config/microblaze/microblaze.opt 2011-02-21 
17:05:40.0 -0800
+++ gcc-mainline/gcc/config/microblaze/microblaze.opt   2011-03-03 
19:26:12.0 -0800
@@ -72,7 +72,7 @@ Target Mask(PATTERN_COMPARE)
 Use pattern compare instructions
 
 mxl-stack-check
-Target Mask(STACK_CHECK)
+Target Mask(STACK_CHECK) Warn(%qs is deprecated; use -fstack-check)
 Check for stack overflow at runtime
 
 mxl-gp-opt
@@ -80,7 +80,7 @@ Target Mask(XLGPOPT)
 Use GP relative sdata/sbss sections
 
 mno-clearbss
-Target RejectNegative
+Target RejectNegative Var(flag_zero_initialized_in_bss, 0) Warn(%qs is 
deprecated; use -fno-zero-initialized-in-bss)
 Clear the BSS to zero and place zero initialized in BSS
 
 mxl-multiply-high

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


Re: [4.7] Avoid global state in m32c_handle_option

2011-03-03 Thread DJ Delorie

> Tested building cc1 and xgcc for cross to m32c-elf.  Will commit to
> trunk for 4.7 in the absence of target maintainer objections.

Go for it :-)


Re: PowerPC32 .gnu.attributes

2011-03-03 Thread Alan Modra
Re http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html

Updated patch, using cgraph to decide whether a function is visible
outside of the object file.  Bootstrapped and regression tested
powerpc-linux.  OK for 4.6?

* config/rs6000/linux.h (TARGET_ASM_FILE_END): Don't define.
* config/rs6000/linux64.h (TARGET_ASM_FILE_END): Don't define.
* config/rs6000/sysv4.h (TARGET_ASM_FILE_END): Define.
* config/rs6000/rs6000-protos.h (init_cumulative_args): Add fndecl and
return_mode args.
* config/rs6000/rs6000.h (CUMULATIVE_ARGS): Add "escapes".
(INIT_CUMULATIVE_ARGS): Pass FNDECL, VOIDmode.
(INIT_CUMULATIVE_INCOMING_ARGS): Pass current_function_decl, VOIDmode.
(INIT_CUMULATIVE_LIBCALL_ARGS): Pass NULL_TREE, MODE.
* config/rs6000/rs6000.c
(rs6000_elf_end_indicate_exec_stack): Rename to..
(rs6000_elf_file_end): ..this.  Only call file_end_indicate_exec_stack
for POWERPC_LINUX.  Move code emitting .gnu_attribute to here, from..
(rs6000_file_start): ..here.
(rs6000_passes_float, rs6000_passes_vector, rs6000_returns_struct): New
file scope variables.
(call_ABI_of_interest): New function.
(init_cumulative_args): Set above vars when function return value
is a float, vector, or small struct.
(rs6000_function_arg_advance_1): Likewise for function args.
(rs6000_va_start): Set rs6000_passes_float if variable arg function
references float args.

Index: gcc/config/rs6000/linux.h
===
--- gcc/config/rs6000/linux.h   (revision 170665)
+++ gcc/config/rs6000/linux.h   (working copy)
@@ -114,8 +114,6 @@
 #define RELOCATABLE_NEEDS_FIXUP \
   (target_flags & target_flags_explicit & MASK_RELOCATABLE)
 
-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
 #define TARGET_POSIX_IO
 
 #define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h"
Index: gcc/config/rs6000/linux64.h
===
--- gcc/config/rs6000/linux64.h (revision 170665)
+++ gcc/config/rs6000/linux64.h (working copy)
@@ -537,8 +537,6 @@ extern int dot_symbols;
 #undef DRAFT_V4_STRUCT_RET
 #define DRAFT_V4_STRUCT_RET (!TARGET_64BIT)
 
-#define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
-
 #define TARGET_POSIX_IO
 
 #define LINK_GCC_C_SEQUENCE_SPEC \
Index: gcc/config/rs6000/sysv4.h
===
--- gcc/config/rs6000/sysv4.h   (revision 170665)
+++ gcc/config/rs6000/sysv4.h   (working copy)
@@ -1031,6 +1031,8 @@ ncrtn.o%s"
 /* Generate entries in .fixup for relocatable addresses.  */
 #define RELOCATABLE_NEEDS_FIXUP 1
 
+#define TARGET_ASM_FILE_END rs6000_elf_file_end
+
 /* This target uses the sysv4.opt file.  */
 #define TARGET_USES_SYSV4_OPT 1
 
Index: gcc/config/rs6000/rs6000-protos.h
===
--- gcc/config/rs6000/rs6000-protos.h   (revision 170665)
+++ gcc/config/rs6000/rs6000-protos.h   (working copy)
@@ -28,7 +28,8 @@
 #ifdef RTX_CODE
 
 #ifdef TREE_CODE
-extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, int, int, int);
+extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, int, int, int,
+ tree, enum machine_mode);
 #endif /* TREE_CODE */
 
 extern bool easy_altivec_constant (rtx, enum machine_mode);
Index: gcc/config/rs6000/rs6000.h
===
--- gcc/config/rs6000/rs6000.h  (revision 170665)
+++ gcc/config/rs6000/rs6000.h  (working copy)
@@ -1570,25 +1598,29 @@ typedef struct rs6000_args
   int floats_in_gpr;   /* count of SFmode floats taking up
   GPR space (darwin64) */
   int named;   /* false for varargs params */
+  int escapes; /* if function visible outside tu */
 } CUMULATIVE_ARGS;
 
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
for a call to a function whose data type is FNTYPE.
For a library call, FNTYPE is 0.  */
 
-#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
-  init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE, FALSE, N_NAMED_ARGS)
+#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
+  init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE, FALSE, \
+   N_NAMED_ARGS, FNDECL, VOIDmode)
 
 /* Similar, but when scanning the definition of a procedure.  We always
set NARGS_PROTOTYPE large so we never return an EXPR_LIST.  */
 
 #define INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
-  init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE, FALSE, 1000)
+  init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE, FALSE, \
+   1000, current_function_decl, VOIDmode)
 
 /* Like INIT_CUMULATIVE_ARGS' but only used for outgoing libcalls.  */
 
 #def

Re: build_function_call and TREE_ADDRESSABLE

2011-03-03 Thread Alan Modra
Warn off anyone trying to do as I did, and the bit about inlines is
no longer relevant.  OK to apply?

* tree.h (TREE_ADDRESSABLE): Note that direct calls set the
flag on FUNCTION_DECLs.

Index: gcc/tree.h
===
--- gcc/tree.h  (revision 170665)
+++ gcc/tree.h  (working copy)
@@ -1106,8 +1106,8 @@ extern void omp_clause_range_check_faile
 
 /* In VAR_DECL, PARM_DECL and RESULT_DECL nodes, nonzero means address
of this is needed.  So it cannot be in a register.
-   In a FUNCTION_DECL, nonzero means its address is needed.
-   So it must be compiled even if it is an inline function.
+   In a FUNCTION_DECL, nonzero means its address is needed.  This even
+   happens on a direct call, making the flag fairly useless.
In CONSTRUCTOR nodes, it means object constructed must be in memory.
In LABEL_DECL nodes, it means a goto for this label has been seen
from a place outside all binding contours that restore stack levels.

-- 
Alan Modra
Australia Development Lab, IBM


Re: [ping] Re: [patch, powerpc] #undef LINK_EH_SPEC before defining it

2011-03-03 Thread Alan Modra
On Wed, Feb 16, 2011 at 11:36:09PM +0100, Matthias Klose wrote:
> >../../src/gcc/config/rs6000/sysv4.h:839:1: warning: "LINK_EH_SPEC" redefined
> >In file included from ./tm.h:33,
> >from ../../src/gcc/cp/rtti.c:27:
> >../../src/gcc/config/freebsd-spec.h:135:1: warning: this is the location of 
> >the
> >previous definition

In mainline sources the two macro definitions are identical.  Self-
inflicted wound?

-- 
Alan Modra
Australia Development Lab, IBM


Re: [PATCH, i386] Introduce a flag to generate only 128-bit avx instructions

2011-03-03 Thread Richard Henderson
On 03/04/2011 03:59 AM, Fang, Changpeng wrote:
> +mprefers-avx128
> +Target Report Var(flag_prefers_avx128) Init(0)

Use "mprefer-avx128".  A switch should use a verb in command form -- you're 
telling the compiler what to do.  Change both the switch and the flag spelling.


> +Auto-vectorizer prefers to generate 128-bit AVX instructions instead of 
> 256-bit
> +ones.

"Use 128-bit AVX instructions instead of 256-bit AVX instructions in the 
auto-vectorizer".

Ok with those changes.


r~


Re: ivopts improvement

2011-03-03 Thread Paolo Bonzini

On 03/03/2011 03:28 PM, Tom de Vries wrote:

reg-tested on x86_64. Better?


Yes, very much so (talking about patch 6.5; the other one is an 
optimization but not essential based on the new comments).


Just one question: what happens if the COND_EXPR is indeed turned into a 
MAX_EXPR?  Is it a missed optimization?  Is it because of overflow that 
you aren't _always_ creating a MAX_EXPR directly?


Paolo


Re: [ping] Re: [patch, powerpc] #undef LINK_EH_SPEC before defining it

2011-03-03 Thread Jakub Jelinek
On Fri, Mar 04, 2011 at 05:30:10PM +1030, Alan Modra wrote:
> On Wed, Feb 16, 2011 at 11:36:09PM +0100, Matthias Klose wrote:
> > >../../src/gcc/config/rs6000/sysv4.h:839:1: warning: "LINK_EH_SPEC" 
> > >redefined
> > >In file included from ./tm.h:33,
> > >from ../../src/gcc/cp/rtti.c:27:
> > >../../src/gcc/config/freebsd-spec.h:135:1: warning: this is the location 
> > >of the
> > >previous definition
> 
> In mainline sources the two macro definitions are identical.  Self-
> inflicted wound?

We see it because we add --no-add-needed to linux LINK_EH_SPECs.
Including freebsd-spec.h in a Linux configuration is certainly very
questionable and undefining LINK_EH_SPEC and other macros before defining
them would be certainly cleaner if the freebsd-spec.h include can't be just
killed.

Jakub