[patch] Generate block moves for bitfield initialization

2012-05-13 Thread Eric Botcazou
Hi,

this patch has been in our tree for a while and helps in Ada where you can do 
block assignments to structures at will.  I've attached a C testcase.  The 
unpatch compiler generates for it on PowerPC at -O2:

foo:
lis 10,s@ha
li 8,27
la 9,s@l(10)
stb 8,s@l(10)
li 10,108
stb 10,1(9)
li 10,-79
stb 10,2(9)
li 10,-58
stb 10,3(9)
blr
.size   foo, .-foo
.comm   s,4,1

because it isn't able to put back together the individual initializations.

The patched compiler generates instead:

foo:
lis 9,.LANCHOR0@ha
lis 10,s@ha
lwz 9,.LANCHOR0@l(9)
stw 9,s@l(10)
blr
.size   foo, .-foo
.comm   s,4,1

.section.rodata
.set.LANCHOR0,. + 0
.LC0:
.byte   27
.byte   108
.byte   177
.byte   198


Bootstrapped/regtested on i586-suse-linux, OK for mainline?


2012-05-13  Eric Botcazou  

* gimplify.c (gimplify_init_constructor): Do a block move for very
small objects as well.


-- 
Eric Botcazou
Index: gimplify.c
===
--- gimplify.c	(revision 187393)
+++ gimplify.c	(working copy)
@@ -4033,9 +4033,13 @@ gimplify_init_constructor (tree *expr_p,
 	else
 	  align = TYPE_ALIGN (type);
 
+	/* Do a block move either if the size is so small as to make
+	   each individual move a sub-unit move on average, or if it
+	   is so large as to make individual moves inefficient.  */
 	if (size > 0
 		&& num_nonzero_elements > 1
-		&& !can_move_by_pieces (size, align))
+		&& (size < num_nonzero_elements
+		|| !can_move_by_pieces (size, align)))
 	  {
 		if (notify_temp_creation)
 		  return GS_ERROR;
struct __attribute__ ((packed)) S1 {
  unsigned int a1 : 2;
  unsigned int a2 : 2;
  unsigned int a3 : 2;
  unsigned int a4 : 2;
};

struct S {
  struct S1 a[4];
};

struct S s;

extern foo (void)
{
  struct S my_s = {{{ 0, 1, 2, 3 }, { 1, 2, 3, 0 }, { 2, 3, 0, 1 }, { 3, 0, 1, 2 }}};
  s = my_s;
}


make conflicting help text an error

2012-05-13 Thread Manuel López-Ibáñez
Hi,

These warnings are invisible when building but they may help to detect
if an option is duplicated somewhere else with different purpose , so
it would be better to make this an error,

Only 2 options in Ada trigger this warning, and their help text has no
effect, since it gest overridden by the ones in c.opt. Fixing this
properly would require language-specific namespace, so two options
with the same name in different languages can have completely
different help text (and Init() and other flags). Not something I am
planning to work on in the future.

OK?

2012-05-13  Manuel López-Ibáñez  

gcc/
* optc-gen.awk: Error instead of warning for conflicting help.
ada/
* gcc-interface/lang.opt (I): Comment out help text with no effect.
(nostdinc): Comment out help text with no effect.


p.diff
Description: Binary data


Re: [Fortran, patch] PR 52158 - Regression on character function with gfortran 4.7

2012-05-13 Thread Tobias Burnus

Tobias Burnus wrote:

I think the ChangeLog is okay - as is the whole patch.

I wouldn't mind if someone else (Paul? Janus?) could also glance at 
the patch; however, if there are no comments, I intent to commit the 
patch soon.


Committed as Rev. 187436. Thanks for the patch and congratulation to 
your first GCC contribution!


Tobias


Re: make conflicting help text an error

2012-05-13 Thread Joseph S. Myers
On Sun, 13 May 2012, Manuel L?pez-Ib??ez wrote:

> Hi,
> 
> These warnings are invisible when building but they may help to detect
> if an option is duplicated somewhere else with different purpose , so
> it would be better to make this an error,
> 
> Only 2 options in Ada trigger this warning, and their help text has no
> effect, since it gest overridden by the ones in c.opt. Fixing this
> properly would require language-specific namespace, so two options
> with the same name in different languages can have completely
> different help text (and Init() and other flags). Not something I am
> planning to work on in the future.
> 
> OK?

This is OK.  I don't think we want to support different help strings for 
different languages; if an option is supported for multiple languages, we 
should have a generic description of that option that is correct for all 
of them.

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

more enabledby updates

2012-05-13 Thread Manuel López-Ibáñez
A few more straightforward uses. Bootstrapped and regression tested.

A strange thing is that -Wextra enables -Wtype-limits only in
C-family, however, it remains with value -1 in the rest of languages,
that is, enabled by default. I am surprised it does not trigger often
for Fortran and Ada.

OK?

2012-05-13  Manuel López-Ibáñez  

c-family/
* c.opt (Wclobbered,Wempty-body,Wignored-qualifiers,
Wmissing-field-initializers,Wmissing-parameter-type,
Wold-style-declaration,Woverride-init): Use EnabledBy.
* c-opts.c (c_common_post_options): Do not set here explicitly.
gcc/
* common.opt (Wtype-limits): Use EnabledBy.


enabledby.diff
Description: Binary data


Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-05-13 Thread Tobias Burnus

Tobias Burnus wrote:
Note that the patch assumes that the function's result variable's 
length specification expression is completely known to the caller. I 
think that's always the case in gfortran - or is it not?


Thinking about it, I came to the conclusion has explicitly been designed 
such that it is known.


Note: The attached patch is required in addition to make sure that the 
variable has the correct name mangling and to ensure that the string 
length is TREE_PUBLIC() = 1, when needed.


The trans-expr.c part of the patch has been posted at 
http://gcc.gnu.org/ml/fortran/2012-05/msg00054.html



Compile ("-c") the following code - with the function commented or not 
and with PUBLIC and PRIVATE - and look resulting .o file via nm. It 
shouldn't show the "str" variable (and the length variable) if (and 
only) if it is private and not used in the function result expression. 
Result for the program as shown below:


0008 B .__m_MOD_str
 T __m_MOD_bar
 B __m_MOD_str


module m
!  character(len=:), PRIVATE, allocatable :: str
  character(len=:), PUBLIC, allocatable :: str
contains
  ! Note due to technical reasons (TBP, generic, cf. resolve.c),
  ! a "PRIVATE :: bar" still counts a publicly using "str".
  function bar()
character(len=len(str)) :: str
  end function bar
end module m

Tobias
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index b03d393..3c1118e 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1087,11 +1087,14 @@ gfc_create_string_length (gfc_symbol * sym)
   if (sym->ts.u.cl->backend_decl == NULL_TREE)
 {
   tree length;
-  char name[GFC_MAX_MANGLED_SYMBOL_LEN + 2];
+  const char *name;
 
   /* Also prefix the mangled name.  */
-  strcpy (&name[1], sym->name);
-  name[0] = '.';
+  if (sym->module)
+	name = gfc_get_string (".__%s_MOD_%s", sym->module, sym->name);
+  else
+	name = gfc_get_string (".%s", sym->name);
+
   length = build_decl (input_location,
 			   VAR_DECL, get_identifier (name),
 			   gfc_charlen_type_node);
@@ -1101,6 +1104,13 @@ gfc_create_string_length (gfc_symbol * sym)
 	gfc_defer_symbol_init (sym);
 
   sym->ts.u.cl->backend_decl = length;
+
+  if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE)
+	TREE_STATIC (length) = 1;
+
+  if (sym->ns->proc_name->attr.flavor == FL_MODULE
+	  && (sym->attr.access != ACCESS_PRIVATE || sym->attr.public_used))
+	TREE_PUBLIC (length) = 1;
 }
 
   gcc_assert (sym->ts.u.cl->backend_decl != NULL_TREE);
@@ -1395,29 +1405,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 
   gfc_finish_var_decl (decl, sym);
 
-  if (sym->ts.type == BT_CHARACTER)
-{
-  /* Character variables need special handling.  */
-  gfc_allocate_lang_decl (decl);
-
-  if (TREE_CODE (length) != INTEGER_CST)
-	{
-	  char name[GFC_MAX_MANGLED_SYMBOL_LEN + 2];
-
-	  if (sym->module)
-	{
-	  /* Also prefix the mangled name for symbols from modules.  */
-	  strcpy (&name[1], sym->name);
-	  name[0] = '.';
-	  strcpy (&name[1],
-		  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (length)));
-	  gfc_set_decl_assembler_name (decl, get_identifier (name));
-	}
-	  gfc_finish_var_decl (length, sym);
-	  gcc_assert (!sym->value);
-	}
-}
-  else if (sym->attr.subref_array_pointer)
+  if (sym->attr.subref_array_pointer)
 {
   /* We need the span for these beasts.  */
   gfc_allocate_lang_decl (decl);


Re: [Patch, fortran] PR 52428 Reading of large negative values and range checking

2012-05-13 Thread Jerry DeLisle

On 05/11/2012 09:07 AM, Janne Blomqvist wrote:

PING #2!

On Wed, May 2, 2012 at 10:22 PM, Janne Blomqvist
  wrote:

PING

On Thu, Apr 26, 2012 at 12:08 AM, Janne Blomqvist
  wrote:

Hi,

currently when -frange-check is enabled, we check for overflow when
doing a formatted read of an integer value. This check, however, is
against the Fortran numerical model (see 13.4 in F2008), which defines
a symmetric interval [-huge(), huge()], whereas all targets gfortran
supports use a two's complement representation with a range of
[-huge()-1, huge()].

However, there is no checking against the numerical model when doing
arithmetic, and thus we can generate and write the value -huge()-1,
but we cannot read it back in! With the -fno-range-check option, this
overflow checking can be disabled, but at the cost of disabling all
overflow checking, which leads to reading nonsense values if the
hardware supported range overflows.

The attached patch changes this logic such that overflow checking
against the hardware supported range [-huge()-1, huge()] is always
done when reading, regardless of the -frange-check flag setting. This
also seems to be what ifort 12.0 does, I haven't checked other
compilers.

For some more arguments back and forth, see the PR.

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


Patch OK for trunk.  In spite of myself, it does not hurt anything.

Regards,

Jerry


[PATCH, i386]: Handle TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL in SSE bitops

2012-05-13 Thread Uros Bizjak
Hello!

2012-05-13  Uros Bizjak  

* config/i386/sse.md (_andnot3): Handle
TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL.
(3): Ditto.
(*andnot3): Ditto.
(*andnottf3): Ditto.
(*3): Ditto.
(tf3): Ditto.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

Uros.
Index: config/i386/sse.md
===
--- config/i386/sse.md  (revision 187435)
+++ config/i386/sse.md  (working copy)
@@ -1600,29 +1600,46 @@
   "TARGET_SSE"
 {
   static char buf[32];
-  const char *insn;
-  const char *suffix
-= TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL ? "ps" : "";
+  const char *ops;
+  const char *suffix;
 
+  switch (get_attr_mode (insn))
+{
+case MODE_V8SF:
+case MODE_V4SF:
+  suffix = "ps";
+  break;
+default:
+  suffix = "";
+}
+
   switch (which_alternative)
 {
 case 0:
-  insn = "andn%s\t{%%2, %%0|%%0, %%2}";
+  ops = "andn%s\t{%%2, %%0|%%0, %%2}";
   break;
 case 1:
-  insn = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
+  ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
   break;
 default:
   gcc_unreachable ();
 }
 
-  snprintf (buf, sizeof (buf), insn, suffix);
+  snprintf (buf, sizeof (buf), ops, suffix);
   return buf;
 }
   [(set_attr "isa" "noavx,avx")
(set_attr "type" "sselog")
(set_attr "prefix" "orig,vex")
-   (set_attr "mode" "")])
+   (set (attr "mode")
+   (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+(const_string "")
+  (match_test "TARGET_AVX")
+(const_string "")
+  (match_test "optimize_function_for_size_p (cfun)")
+(const_string "V4SF")
+  ]
+  (const_string "")))])
 
 (define_expand "3"
   [(set (match_operand:VF 0 "register_operand")
@@ -1640,29 +1657,46 @@
   "TARGET_SSE && ix86_binary_operator_ok (, mode, operands)"
 {
   static char buf[32];
-  const char *insn;
-  const char *suffix
-= TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL ? "ps" : "";
+  const char *ops;
+  const char *suffix;
 
+  switch (get_attr_mode (insn))
+{
+case MODE_V8SF:
+case MODE_V4SF:
+  suffix = "ps";
+  break;
+default:
+  suffix = "";
+}
+
   switch (which_alternative)
 {
 case 0:
-  insn = "%s\t{%%2, %%0|%%0, %%2}";
+  ops = "%s\t{%%2, %%0|%%0, %%2}";
   break;
 case 1:
-  insn = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
+  ops = "v%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
   break;
 default:
   gcc_unreachable ();
 }
 
-  snprintf (buf, sizeof (buf), insn, suffix);
+  snprintf (buf, sizeof (buf), ops, suffix);
   return buf;
 }
   [(set_attr "isa" "noavx,avx")
(set_attr "type" "sselog")
(set_attr "prefix" "orig,vex")
-   (set_attr "mode" "")])
+   (set (attr "mode")
+   (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+(const_string "")
+  (match_test "TARGET_AVX")
+(const_string "")
+  (match_test "optimize_function_for_size_p (cfun)")
+(const_string "V4SF")
+  ]
+  (const_string "")))])
 
 (define_expand "copysign3"
   [(set (match_dup 4)
@@ -1696,30 +1730,85 @@
   "SSE_FLOAT_MODE_P (mode)"
 {
   static char buf[32];
-  const char *insn;
+  const char *ops;
   const char *suffix
-= TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL ? "ps" : "";
+= (get_attr_mode (insn) == MODE_V4SF) ? "ps" : "";
 
   switch (which_alternative)
 {
 case 0:
-  insn = "andn%s\t{%%2, %%0|%%0, %%2}";
+  ops = "andn%s\t{%%2, %%0|%%0, %%2}";
   break;
 case 1:
-  insn = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
+  ops = "vandn%s\t{%%2, %%1, %%0|%%0, %%1, %%2}";
   break;
 default:
   gcc_unreachable ();
 }
 
-  snprintf (buf, sizeof (buf), insn, suffix);
+  snprintf (buf, sizeof (buf), ops, suffix);
   return buf;
 }
   [(set_attr "isa" "noavx,avx")
(set_attr "type" "sselog")
(set_attr "prefix" "orig,vex")
-   (set_attr "mode" "")])
+   (set (attr "mode")
+   (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+(const_string "V4SF")
+  (match_test "TARGET_AVX")
+(const_string "")
+  (match_test "optimize_function_for_size_p (cfun)")
+(const_string "V4SF")
+  ]
+  (const_string "")))])
 
+(define_insn "*andnottf3"
+  [(set (match_operand:TF 0 "register_operand" "=x,x")
+   (and:TF
+ (not:TF (match_operand:TF 1 "register_operand" "0,x"))
+ (match_operand:TF 2 "nonimmediate_operand" "xm,xm")))]
+  "TARGET_SSE"
+{
+  static char buf[32];
+  const char *ops;
+  const char *tmp
+= (get_attr_mode (insn) == MODE_V4SF) ? "andnps" : "pandn";
+
+  switch (which_alternative)
+{
+case 0:
+  ops = "%s\t{%%2, %%0|%%0, %%2}";
+  break;
+case 1:
+  ops = "v%s\t{%%

Refining autopar cost model for outer loops

2012-05-13 Thread Razya Ladelsky
Hi,

This patch changes the minimum number of iterations of outer loops for the 
runtime check which tests whether it is worthwhile to parallelize the loop 
or not.
The current minimum number of iterations for all loops is MIN_PER_THREAD * 
number of threads, when MIN_PER_THREAD is arbitrarily set to 100.
This prevents some of the promising loops of SPEC2006 from getting 
parallelized.
I changed the minimum bound for outer loops, under the assumption that 
even if there are not enough iterations, the fact that an outer loop 
contains more loops, obtains enough work to get parallelized.
This indeed allowed for a lot more loops to get parallelized, resulting in 
substantial performance improvements for SPEC2006 benchmarks, measured on 
a Power7 6 core, 4 way SMT each.
I compared  the trunk with O3 + autopar (parallelizing with 6 threads) vs. 
the trunk with   O3  minus vectorization.
None of the benchmarks shows any significant degradation.

The speedup shown for  libquatum  with autopar has been obtained with 
previous versions of autopar, having no relation to this patch, but surely 
not degraded by it either.

These are the speedups I collected:

462.libquantum  2.5 X
410.bwaves  3.3 X
436.cactusADM   4.5 X
459.GemsFDTD1.27 X
481.wrf 1.25 X


Bootstrap and testsuite (with -ftree-parallelize-loops=4) pass 
successfully.
spec-2006 showed no regressions.


OK for trunk?
Thanks,
razya

2012-05-08  Razya Ladelsky  
 
 * tree-parloops.c (gen_parallel_loop): Change 
many_iterations_cond for outer loops.
 Index: tree-parloops.c
===
--- tree-parloops.c (revision 186667)
+++ tree-parloops.c (working copy)
@@ -1732,6 +1732,7 @@ gen_parallel_loop (struct loop *loop, htab_t reduc
   unsigned prob;
   location_t loc;
   gimple cond_stmt;
+  unsigned int m_p_thread=2;
 
   /* From
 
@@ -1792,9 +1793,15 @@ gen_parallel_loop (struct loop *loop, htab_t reduc
   if (stmts)
 gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
 
-  many_iterations_cond =
-fold_build2 (GE_EXPR, boolean_type_node,
-nit, build_int_cst (type, MIN_PER_THREAD * n_threads));
+  if (loop->inner)
+m_p_thread=2;
+  else
+m_p_thread=MIN_PER_THREAD;
+
+   many_iterations_cond =
+ fold_build2 (GE_EXPR, boolean_type_node,
+nit, build_int_cst (type, m_p_thread * n_threads));
+
   many_iterations_cond
 = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
   invert_truthvalue (unshare_expr (niter->may_be_zero)),
=

[Patch / RFC] PR 39681

2012-05-13 Thread Paolo Carlini

Hi,

I had a look to this rather old PR, which doesn't seem particularly 
high-priority, to be honest. It's about the error message we produce for 
things like:


int main()
{
int* p = new foo;
}

where, besides the obvious error message about foo, we also print:

39681.C:3:16: error: expected ‘,’ or ‘;’ before ‘foo’

which seems redundant and boring. The first thing I noticed is that in 
cp_parser_new_type_id, at variance with cp_parser_type_id, when 
cp_parser_type_specifier_seq sets error_mark_node as 
type_specifier_seq.type we don't notice. If change it to also return 
error_mark_node we have a chance to do something in the immediate 
callers. That would allow to avoid the above error message. However, I 
noticed that I could do the check a couple of levels above, that is in 
cp_parser_init_declarator and cp_parser_late_parse_one_default_arg, and 
this allows to catch more redundant error messages about expected 
semicolons (see the ext and c-c++-common testcases below, I like that *a 
lot* ;): it's just matter of skipping to the end of the statement. I'm 
not 100% sure about many details of this, eg, whether the diagnostics 
could somehow regress in some particular situations. But the patch boots 
and tests fine (the cp_parser_late_parse_one_default_arg bits take care 
of the C++11 NSDMI case, for example, see error8.C).


Finally, as a last remark, the PR also talks about "expected 
type-specifier before ‘foo’" not being an optimal error message, or at 
least not being clear enough. Well, ICC prints something quite similar 
in this case and related ones (only talks about type instead of 
type-specifier, less technical). All in all I'm not convinced we should 
change cp_parser_type_specifier_seq to print something else, but I think 
it would be just an additional tweak.


Thanks,
Paolo.

/
/cp

PR c++/39681
* parser.c (cp_parser_new_type_id): Early return error_mark_node
if the cp_parser_type_specifier_seq call has type_specifier_seq.type
error_mark_node; tidy.
(cp_parser_new_expression): Always initialize nelts to NULL_TREE to
avoid uninitialized warnings.
(cp_parser_init_declarator, cp_parser_late_parse_one_default_arg):
Call cp_parser_skip_to_end_of_statement if cp_parser_initializer
returns error_mark_node.

/testsuite

PR c++/39681
* g++.dg/parse/error48.C: New.
* g++.dg/cpp0x/error8.C: Likewise.
* g++.dg/ext/utf-cxx98.C: Adjust dg-error directive.
* g++.dg/ext/utf-dflt2.C: Likewise.
* g++.dg/ext/utf-gnuxx98.C: Likewise.
* g++.dg/ext/utf-dflt.C: Likewise.
* c-c++-common/raw-string-3.c: Likewise.
* c-c++-common/raw-string-4.c: Likewise.

Index: testsuite/g++.dg/ext/utf-cxx98.C
===
--- testsuite/g++.dg/ext/utf-cxx98.C(revision 187435)
+++ testsuite/g++.dg/ext/utf-cxx98.C(working copy)
@@ -8,9 +8,7 @@ const static char16_t   c0  = 'a';  /* { dg-error "not
 const static char32_t  c1  = 'a';  /* { dg-error "not name a type" } */
 
 const unsigned short   c2  = u'a'; /* { dg-error "not declared" } */
-   /* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
 const unsigned longc3  = U'a'; /* { dg-error "not declared" } */
-   /* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
 
 #define u  1 +
 #define U  2 +
Index: testsuite/g++.dg/ext/utf-dflt2.C
===
--- testsuite/g++.dg/ext/utf-dflt2.C(revision 187435)
+++ testsuite/g++.dg/ext/utf-dflt2.C(working copy)
@@ -3,7 +3,6 @@
 // { dg-options "-std=c++98" }
 
 const void *s0 = u8"a";// { dg-error "was not declared" }
-   // { dg-error "expected ',' or ';'" "" { target *-*-* } 5 }
 
 #define u8 "a"
 
Index: testsuite/g++.dg/ext/utf-gnuxx98.C
===
--- testsuite/g++.dg/ext/utf-gnuxx98.C  (revision 187435)
+++ testsuite/g++.dg/ext/utf-gnuxx98.C  (working copy)
@@ -8,9 +8,7 @@ const static char16_t   c0  = 'a';  /* { dg-error "not
 const static char32_t  c1  = 'a';  /* { dg-error "not name a type" } */
 
 const unsigned short   c2  = u'a'; /* { dg-error "not declared" } */
-   /* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
 const unsigned longc3  = U'a'; /* { dg-error "not declared" } */
-   /* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
 
 #define u  1 +
 #define U  2 +
Index: testsuite/g++.dg/ext/utf-dflt.C
===
--- testsuite/g++.dg/ext/utf-dflt.C (revision 187435)
+++ testsuite/g++.dg/ext/utf-dflt.C (working copy)
@@ -8,9 +8,7 @@ const static char16_t   c0  = 'a';  /* { dg-error "not
 const static char32_t  c1  = 'a';  /* { dg-error "not name a type" } *

Re: more enabledby updates

2012-05-13 Thread Joseph S. Myers
On Sun, 13 May 2012, Manuel L?pez-Ib??ez wrote:

> 2012-05-13  Manuel L?pez-Ib??ez  
> 
> c-family/
>   * c.opt (Wclobbered,Wempty-body,Wignored-qualifiers,
>   Wmissing-field-initializers,Wmissing-parameter-type,
>   Wold-style-declaration,Woverride-init): Use EnabledBy.
>   * c-opts.c (c_common_post_options): Do not set here explicitly.
> gcc/
>   * common.opt (Wtype-limits): Use EnabledBy.

OK.

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

Re: [PATCH, i386]: Handle TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL in SSE bitops

2012-05-13 Thread Uros Bizjak
On Sun, May 13, 2012 at 5:16 PM, Uros Bizjak  wrote:

> 2012-05-13  Uros Bizjak  
>
>        * config/i386/sse.md (_andnot3): Handle
>        TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL.
>        (3): Ditto.
>        (*andnot3): Ditto.
>        (*andnottf3): Ditto.
>        (*3): Ditto.
>        (tf3): Ditto.
>
> Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

For some reason, the attached part was left out of my previous mail and commit.

Uros.
Index: config/i386/sse.md
===
--- config/i386/sse.md  (revision 187438)
+++ config/i386/sse.md  (working copy)
@@ -6729,13 +6729,20 @@
(const_string "*")))
(set_attr "prefix" "orig,vex")
(set (attr "mode")
- (cond [(and (not (match_test "TARGET_AVX2"))
-(match_test "GET_MODE_SIZE (mode) > 16"))
- (const_string "V8SF")
-   (not (match_test "TARGET_SSE2"))
- (const_string "V4SF")
-  ]
-  (const_string "")))])
+   (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+(const_string "")
+  (match_test "TARGET_AVX2")
+(const_string "")
+  (match_test "TARGET_AVX")
+(if_then_else
+  (match_test "GET_MODE_SIZE (mode) > 16")
+  (const_string "V8SF")
+  (const_string ""))
+  (ior (not (match_test "TARGET_SSE2"))
+   (match_test "optimize_function_for_size_p (cfun)"))
+(const_string "V4SF")
+ ]
+ (const_string "")))])
 
 (define_expand "3"
   [(set (match_operand:VI 0 "register_operand")
@@ -6804,13 +6811,20 @@
(const_string "*")))
(set_attr "prefix" "orig,vex")
(set (attr "mode")
- (cond [(and (not (match_test "TARGET_AVX2"))
-(match_test "GET_MODE_SIZE (mode) > 16"))
- (const_string "V8SF")
-   (not (match_test "TARGET_SSE2"))
- (const_string "V4SF")
-  ]
-  (const_string "")))])
+   (cond [(match_test "TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL")
+(const_string "")
+  (match_test "TARGET_AVX2")
+(const_string "")
+  (match_test "TARGET_AVX")
+(if_then_else
+  (match_test "GET_MODE_SIZE (mode) > 16")
+  (const_string "V8SF")
+  (const_string ""))
+  (ior (not (match_test "TARGET_SSE2"))
+   (match_test "optimize_function_for_size_p (cfun)"))
+(const_string "V4SF")
+ ]
+ (const_string "")))])
 
 ;
 ;;


Re: [PATCH] Remove TYPE_IS_SIZETYPE

2012-05-13 Thread Eric Botcazou
> I get a bootstrap failure on x86 (verify_flow_info failed) with it.

It's actually pre-existing: it's PRE value-numbering a call that can make an 
abnormal goto, hence the CFG mess in the end.  The call is ECF_PURE but also 
ECF_LOOPING_CONST_OR_PURE, so gimple_has_side_effects returns true and, in 
turn, call_can_make_abnormal_goto .  The bug is in can_value_number_call.

I can come up with two solutions:
 - testing ECF_LOOPING_CONST_OR_PURE as well, like gimple_has_side_effects, or
 - calling call_can_make_abnormal_goto explicitly.

The attached patch implements the former.  With it, I could bootstrap and test 
the stor-layout.c patch on our internal testsuite.

What do you think?


* stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype
in a PLUS_EXPR byte offset.

* tree-ssa-pre.c (can_value_number_call): Return false if the call
has the ECF_LOOPING_CONST_OR_PURE flag.


-- 
Eric Botcazou
Index: stor-layout.c
===
--- stor-layout.c	(revision 187435)
+++ stor-layout.c	(working copy)
@@ -786,25 +786,29 @@ start_record_layout (tree t)
 }
 
 /* Return the combined bit position for the byte offset OFFSET and the
-   bit position BITPOS.  */
+   bit position BITPOS.
+
+   These functions operate on byte and bit positions present in FIELD_DECLs
+   and assume that these expressions result in no (intermediate) overflow.
+   This assumption is necessary to fold the expressions as much as possible,
+   so as to avoid creating artificially variable-sized types in languages
+   supporting variable-sized types like Ada.  */
 
 tree
 bit_from_pos (tree offset, tree bitpos)
 {
+  if (TREE_CODE (offset) == PLUS_EXPR)
+offset = size_binop (PLUS_EXPR,
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 0)),
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 1)));
+  else
+offset = fold_convert (bitsizetype, offset);
   return size_binop (PLUS_EXPR, bitpos,
-		 size_binop (MULT_EXPR,
- fold_convert (bitsizetype, offset),
- bitsize_unit_node));
+		 size_binop (MULT_EXPR, offset, bitsize_unit_node));
 }
 
 /* Return the combined truncated byte position for the byte offset OFFSET and
-   the bit position BITPOS.
-
-   These functions operate on byte and bit positions as present in FIELD_DECLs
-   and assume that these expressions result in no (intermediate) overflow.
-   This assumption is necessary to fold the expressions as much as possible,
-   so as to avoid creating artificially variable-sized types in languages
-   supporting variable-sized types like Ada.  */
+   the bit position BITPOS.  */
 
 tree
 byte_from_pos (tree offset, tree bitpos)
Index: tree-ssa-pre.c
===
--- tree-ssa-pre.c	(revision 187435)
+++ tree-ssa-pre.c	(working copy)
@@ -2592,10 +2592,15 @@ compute_antic (void)
 static bool
 can_value_number_call (gimple stmt)
 {
+  int flags;
+
   if (gimple_call_internal_p (stmt))
 return false;
-  if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
+
+  flags = gimple_call_flags (stmt);
+  if ((flags & (ECF_PURE | ECF_CONST)) && !(flags & ECF_LOOPING_CONST_OR_PURE))
 return true;
+
   return false;
 }
 


[PATCH, i386]: Enable TFmode moves via XMM registers for 32bit SSE targets

2012-05-13 Thread Uros Bizjak
Hello!

With all recent mode handling cleanups to move patterns and SSE
bitops, it is now possible to enable TFmode moves via XMM registers
for 32bit SSE targets. The compiler emits packed single operations in
this case, so following testcase:

--cut here--
__float128 test_abs (__float128 a)
{
  return (__builtin_fabsq (a));
}

__float128 test_copysign (__float128 a, __float128 b)
{
  return (__builtin_copysignq (a, b));
}
--cut here--

compiles with "-O2 -msse" to:

test_abs:
movl4(%esp), %eax
movaps  20(%esp), %xmm0
andps   .LC0, %xmm0
movaps  %xmm0, (%eax)
ret $4

test_copysign:
movaps  20(%esp), %xmm0
movaps  36(%esp), %xmm1
movl4(%esp), %eax
andps   .LC1, %xmm1
andps   .LC0, %xmm0
orps%xmm1, %xmm0
movaps  %xmm0, (%eax)
ret $4

For comparison, with -msse2 compiler generates:

test_abs:
movl4(%esp), %eax
movdqa  20(%esp), %xmm0
pand.LC0, %xmm0
movdqa  %xmm0, (%eax)
ret $4

test_copysign:
movl4(%esp), %eax
movdqa  20(%esp), %xmm0
movdqa  36(%esp), %xmm1
pand.LC0, %xmm0
pand.LC1, %xmm1
por %xmm1, %xmm0
movdqa  %xmm0, (%eax)
ret $4

With unpached 4.7 compiler, the same code compiles (-O2 -msse) to some
40 SImode moves, with calls to __fabstf2 and __copysigntf2.

2012-05-13  Uros Bizjak  

* config/i386/i386.md (*pushtf): Enable for TARGET_SSE.
(pushtf splitter): Ditto.
(movtf): Ditto.
(*movtf_internal): Ditto. Use V4SFmode for !TARGET_SSE2.
(tf2): Enable for TARGET_SSE.
(*absnegtf2_sse): Ditto.
(copysign3): Enable TFmode for TARGET_SSE.
(copysign3_const): Ditto.
(copysign3_var): Ditto.
* config/i386/sse.md (tf3): Enable for TARGET_SSE.
(*andnottf3): Ditto.  Use V4SFmode for !TARGET_SSE2.
(*tf3): Ditto.
* config/i386/i386.c (struct builtin_description bdesc_args)
: Enable for TARGET_SSE.
: Ditto.
(ix86_expand_builtin) :
Emit a normal call if SSE isn't available.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
{,-m32} and committed to mainline SVN.

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 187435)
+++ config/i386/i386.c  (working copy)
@@ -26327,6 +26327,9 @@ static const struct builtin_description bdesc_args
   { OPTION_MASK_ISA_SSE, CODE_FOR_sse_vmrsqrtv4sf2, "__builtin_ia32_rsqrtss", 
IX86_BUILTIN_RSQRTSS, UNKNOWN, (int) V4SF_FTYPE_V4SF_VEC_MERGE },
   { OPTION_MASK_ISA_SSE, CODE_FOR_sse_vmrcpv4sf2, "__builtin_ia32_rcpss", 
IX86_BUILTIN_RCPSS, UNKNOWN, (int) V4SF_FTYPE_V4SF_VEC_MERGE },
 
+  { OPTION_MASK_ISA_SSE, CODE_FOR_abstf2, 0, IX86_BUILTIN_FABSQ, UNKNOWN, 
(int) FLOAT128_FTYPE_FLOAT128 },
+  { OPTION_MASK_ISA_SSE, CODE_FOR_copysigntf3, 0, IX86_BUILTIN_COPYSIGNQ, 
UNKNOWN, (int) FLOAT128_FTYPE_FLOAT128_FLOAT128 },
+
   /* SSE MMX or 3Dnow!A */
   { OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_3DNOW_A, CODE_FOR_mmx_uavgv8qi3, 
"__builtin_ia32_pavgb", IX86_BUILTIN_PAVGB, UNKNOWN, (int) V8QI_FTYPE_V8QI_V8QI 
},
   { OPTION_MASK_ISA_SSE | OPTION_MASK_ISA_3DNOW_A, CODE_FOR_mmx_uavgv4hi3, 
"__builtin_ia32_pavgw", IX86_BUILTIN_PAVGW, UNKNOWN, (int) V4HI_FTYPE_V4HI_V4HI 
},
@@ -26510,9 +26513,6 @@ static const struct builtin_description bdesc_args
 
   { OPTION_MASK_ISA_SSE2, CODE_FOR_sse2_vmsqrtv2df2, "__builtin_ia32_sqrtsd", 
IX86_BUILTIN_SQRTSD, UNKNOWN, (int) V2DF_FTYPE_V2DF_VEC_MERGE },
 
-  { OPTION_MASK_ISA_SSE2, CODE_FOR_abstf2, 0, IX86_BUILTIN_FABSQ, UNKNOWN, 
(int) FLOAT128_FTYPE_FLOAT128 },
-  { OPTION_MASK_ISA_SSE2, CODE_FOR_copysigntf3, 0, IX86_BUILTIN_COPYSIGNQ, 
UNKNOWN, (int) FLOAT128_FTYPE_FLOAT128_FLOAT128 },
-
   { OPTION_MASK_ISA_SSE, CODE_FOR_sse2_movq128, "__builtin_ia32_movq128", 
IX86_BUILTIN_MOVQ128, UNKNOWN, (int) V2DI_FTYPE_V2DI },
 
   /* SSE2 MMX */
@@ -28081,7 +28081,7 @@ ix86_init_builtins (void)
   def_builtin_const (0, "__builtin_huge_valq",
 FLOAT128_FTYPE_VOID, IX86_BUILTIN_HUGE_VALQ);
 
-  /* We will expand them to normal call if SSE2 isn't available since
+  /* We will expand them to normal call if SSE isn't available since
  they are used by libgcc. */
   t = ix86_get_builtin_func_type (FLOAT128_FTYPE_FLOAT128);
   t = add_builtin_function ("__builtin_fabsq", t, IX86_BUILTIN_FABSQ,
@@ -30215,8 +30215,8 @@ rdrand_step:
{
case IX86_BUILTIN_FABSQ:
case IX86_BUILTIN_COPYSIGNQ:
- if (!TARGET_SSE2)
-   /* Emit a normal call if SSE2 isn't available.  */
+ if (!TARGET_SSE)
+   /* Emit a normal call if SSE isn't available.  */
return expand_call (exp, target, ignore);
default:
  return ix86_expand_args_builtin (d, exp, target);
Index: config/i386/i386.md
=

Re: [PATCH] Remove TYPE_IS_SIZETYPE

2012-05-13 Thread Richard Guenther
On Sun, May 13, 2012 at 7:50 PM, Eric Botcazou  wrote:
>> I get a bootstrap failure on x86 (verify_flow_info failed) with it.
>
> It's actually pre-existing: it's PRE value-numbering a call that can make an
> abnormal goto, hence the CFG mess in the end.  The call is ECF_PURE but also
> ECF_LOOPING_CONST_OR_PURE, so gimple_has_side_effects returns true and, in
> turn, call_can_make_abnormal_goto .  The bug is in can_value_number_call.
>
> I can come up with two solutions:
>  - testing ECF_LOOPING_CONST_OR_PURE as well, like gimple_has_side_effects, or
>  - calling call_can_make_abnormal_goto explicitly.
>
> The attached patch implements the former.  With it, I could bootstrap and test
> the stor-layout.c patch on our internal testsuite.
>
> What do you think?

I'd say simply test gimple_has_side_effects instead.

Richard.

>
>        * stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype
>        in a PLUS_EXPR byte offset.
>
>        * tree-ssa-pre.c (can_value_number_call): Return false if the call
>        has the ECF_LOOPING_CONST_OR_PURE flag.
>
>
> --
> Eric Botcazou


Re: [PATCH] Remove TYPE_IS_SIZETYPE

2012-05-13 Thread Eric Botcazou
> I'd say simply test gimple_has_side_effects instead.

We could go one step farther then and do the replacement in

  if (gimple_has_volatile_ops (stmt)
  || stmt_could_throw_p (stmt))
continue;

I think that's equivalent.  Revised patch attached.


* stor-layout.c (bit_from_pos): Distribute conversion to bitsizetype
in a PLUS_EXPR byte offset.

* tree-ssa-pre.c (can_value_number_call): Delete.
(compute_avail): Skip all statements with side effects.
: Skip calls to internal functions.


-- 
Eric Botcazou
Index: stor-layout.c
===
--- stor-layout.c	(revision 187435)
+++ stor-layout.c	(working copy)
@@ -786,25 +786,29 @@ start_record_layout (tree t)
 }
 
 /* Return the combined bit position for the byte offset OFFSET and the
-   bit position BITPOS.  */
+   bit position BITPOS.
+
+   These functions operate on byte and bit positions present in FIELD_DECLs
+   and assume that these expressions result in no (intermediate) overflow.
+   This assumption is necessary to fold the expressions as much as possible,
+   so as to avoid creating artificially variable-sized types in languages
+   supporting variable-sized types like Ada.  */
 
 tree
 bit_from_pos (tree offset, tree bitpos)
 {
+  if (TREE_CODE (offset) == PLUS_EXPR)
+offset = size_binop (PLUS_EXPR,
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 0)),
+			 fold_convert (bitsizetype, TREE_OPERAND (offset, 1)));
+  else
+offset = fold_convert (bitsizetype, offset);
   return size_binop (PLUS_EXPR, bitpos,
-		 size_binop (MULT_EXPR,
- fold_convert (bitsizetype, offset),
- bitsize_unit_node));
+		 size_binop (MULT_EXPR, offset, bitsize_unit_node));
 }
 
 /* Return the combined truncated byte position for the byte offset OFFSET and
-   the bit position BITPOS.
-
-   These functions operate on byte and bit positions as present in FIELD_DECLs
-   and assume that these expressions result in no (intermediate) overflow.
-   This assumption is necessary to fold the expressions as much as possible,
-   so as to avoid creating artificially variable-sized types in languages
-   supporting variable-sized types like Ada.  */
+   the bit position BITPOS.  */
 
 tree
 byte_from_pos (tree offset, tree bitpos)
Index: tree-ssa-pre.c
===
--- tree-ssa-pre.c	(revision 187435)
+++ tree-ssa-pre.c	(working copy)
@@ -2586,19 +2586,6 @@ compute_antic (void)
   sbitmap_free (changed_blocks);
 }
 
-/* Return true if we can value number the call in STMT.  This is true
-   if we have a pure or constant call to a real function.  */
-
-static bool
-can_value_number_call (gimple stmt)
-{
-  if (gimple_call_internal_p (stmt))
-return false;
-  if (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
-return true;
-  return false;
-}
-
 /* Return true if OP is a tree which we can perform PRE on.
This may not match the operations we can value number, but in
a perfect world would.  */
@@ -3998,7 +3985,7 @@ compute_avail (void)
 	  bitmap_value_insert_into_set (AVAIL_OUT (block), e);
 	}
 
-	  if (gimple_has_volatile_ops (stmt)
+	  if (gimple_has_side_effects (stmt)
 	  || stmt_could_throw_p (stmt))
 	continue;
 
@@ -4017,7 +4004,8 @@ compute_avail (void)
 		pre_expr result = NULL;
 		VEC(vn_reference_op_s, heap) *ops = NULL;
 
-		if (!can_value_number_call (stmt))
+		/* We can value number only calls to real functions.  */
+		if (gimple_call_internal_p (stmt))
 		  continue;
 
 		copy_reference_ops_from_call (stmt, &ops);


implement LangEnabledBy

2012-05-13 Thread Manuel López-Ibáñez
Hi Joseph, I think this implementation matches what we were
discussing. Bootstrapped and regression tested.

OK?

2012-05-13  Manuel López-Ibáñez  

c-family/
* c.opt (Wc++0X-compat,Wdelete-non-virtual-dtor,Wjump-misses-init,
Wreorder): Use LangEnabledBy.
* c-opts.c (c_common_handle_option): Do not enable them
explicitly. Call lang-specific generated functions.
(c_common_post_options): Do not set them here.
gcc/
* doc/options.texi: (LangEnabledBy): Document it.
* optc-gen.awk: Handle LangEnabledBy.
* opth-gen.awk: Generate declaration for lang-specific functions.
* opt-read.awk: Record lang numbers.
* opt-functions.awk (flag_set_p): Ignore the arguments of flags.
(lang_sanitized_name): New.
ada/
* gcc-interface/misc.c: Include opts.h and options.h before tm.h.
(gnat_handle_option): Call lang-specific generated function.
fortran/
* options.c (gfc_handle_option): Call lang-specific generated function.


langenabledby.diff
Description: Binary data


[C++ Patch] PR 44516

2012-05-13 Thread Paolo Carlini

Hi,

this fixes the remaining bit of 44516 - the wrong location, thus caret 
position - in the obvious way, that is by passing from 
cp_parser_assignment_expression the right one to build_x_modify_expr via 
an additional location_t parameter. The latter can simply forward it to 
build_new_op.


Tested x86_64-linux.

Thanks,
Paolo.

//
/cp
2012-05-14  Paolo Carlini  

PR c++/44516
* typeck.c (build_x_modify_expr): Add location_t parameter.
* parser.c (cp_parser_assignment_expression, cp_parser_omp_for_loop):
Adjust callers.
* pt.c (tsubst_omp_for_iterator, tsubst_copy_and_build): Likewise.
* semantics.c (handle_omp_for_class_iterator): Likewise.
* cp-tree.h (build_x_modify_expr): Update.

/testsuite
2012-05-14  Paolo Carlini  

PR c++/44516
* g++.dg/parse/error49.C: New.
Index: testsuite/g++.dg/parse/error49.C
===
--- testsuite/g++.dg/parse/error49.C(revision 0)
+++ testsuite/g++.dg/parse/error49.C(revision 0)
@@ -0,0 +1,10 @@
+// PR c++/44516
+
+struct WebService {  };
+struct Server {  };
+
+void addHTTPService(Server const &server,
+   WebService const *http)
+{
+  server += http; // { dg-error "10:no match for 'operator\\+='" }
+}
Index: cp/typeck.c
===
--- cp/typeck.c (revision 187435)
+++ cp/typeck.c (working copy)
@@ -7105,8 +7105,8 @@ cp_build_modify_expr (tree lhs, enum tree_code mod
 }
 
 tree
-build_x_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
-tsubst_flags_t complain)
+build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
+tree rhs, tsubst_flags_t complain)
 {
   if (processing_template_decl)
 return build_min_nt (MODOP_EXPR, lhs,
@@ -7114,7 +7114,7 @@ tree
 
   if (modifycode != NOP_EXPR)
 {
-  tree rval = build_new_op (input_location, MODIFY_EXPR, LOOKUP_NORMAL,
+  tree rval = build_new_op (loc, MODIFY_EXPR, LOOKUP_NORMAL,
lhs, rhs, make_node (modifycode),
/*overload=*/NULL, complain);
   if (rval)
Index: cp/pt.c
===
--- cp/pt.c (revision 187435)
+++ cp/pt.c (working copy)
@@ -12672,7 +12672,8 @@ tsubst_omp_for_iterator (tree t, int i, tree declv
   cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i));
   incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i);
   if (TREE_CODE (incr) == MODIFY_EXPR)
-   incr = build_x_modify_expr (RECUR (TREE_OPERAND (incr, 0)), NOP_EXPR,
+   incr = build_x_modify_expr (input_location,
+   RECUR (TREE_OPERAND (incr, 0)), NOP_EXPR,
RECUR (TREE_OPERAND (incr, 1)),
complain);
   else
@@ -13692,7 +13693,8 @@ tsubst_copy_and_build (tree t,
 case MODOP_EXPR:
   {
tree r = build_x_modify_expr
- (RECUR (TREE_OPERAND (t, 0)),
+ (input_location,
+  RECUR (TREE_OPERAND (t, 0)),
   TREE_CODE (TREE_OPERAND (t, 1)),
   RECUR (TREE_OPERAND (t, 2)),
   complain);
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 187435)
+++ cp/semantics.c  (working copy)
@@ -4520,7 +4520,8 @@ handle_omp_for_class_iterator (int i, location_t l
incr = error_mark_node;
  else
{
- iter_incr = build_x_modify_expr (iter, TREE_CODE (rhs),
+ iter_incr = build_x_modify_expr (input_location,
+  iter, TREE_CODE (rhs),
   TREE_OPERAND (rhs, 1),
   tf_warning_or_error);
  if (error_operand_p (iter_incr))
@@ -4553,7 +4554,8 @@ handle_omp_for_class_iterator (int i, location_t l
 tf_warning_or_error);
  if (error_operand_p (iter_incr))
return true;
- iter_incr = build_x_modify_expr (iter, NOP_EXPR,
+ iter_incr = build_x_modify_expr (input_location,
+  iter, NOP_EXPR,
   iter_incr,
   tf_warning_or_error);
  if (error_operand_p (iter_incr))
@@ -4604,18 +4606,22 @@ handle_omp_for_class_iterator (int i, location_t l
   if (orig_pre_body)
 add_stmt (orig_pre_body);
   if (init != NULL)
-finish_expr_stmt (build_x_modify_expr (iter, NOP_EXPR, init,
+finish_expr_stmt (build_x_modify_expr (input_location,
+  iter, NOP_EXPR, init,
   

Re: [C++ Patch] PR 44516

2012-05-13 Thread Jason Merrill

On 05/13/2012 07:25 PM, Paolo Carlini wrote:

You're adding a lot of uses of input_location; I think we can do better.


if (TREE_CODE (incr) == MODIFY_EXPR)
-   incr = build_x_modify_expr (RECUR (TREE_OPERAND (incr, 0)), NOP_EXPR,
+   incr = build_x_modify_expr (input_location,


EXPR_LOC_OR_HERE (incr), I would think.


tree r = build_x_modify_expr
- (RECUR (TREE_OPERAND (t, 0)),
+ (input_location,


And EXPR_LOC_OR_HERE (t).


- iter_incr = build_x_modify_expr (iter, TREE_CODE (rhs),
+ iter_incr = build_x_modify_expr (input_location,
+  iter, TREE_CODE (rhs),
   TREE_OPERAND (rhs, 1),


And EXPR_LOC_OR_HERE (rhs).

And so on.

Jason


Re: [C++ Patch] PR 44516

2012-05-13 Thread Paolo Carlini

Hi,

On 05/14/2012 03:50 AM, Jason Merrill wrote:

On 05/13/2012 07:25 PM, Paolo Carlini wrote:

You're adding a lot of uses of input_location; I think we can do better.


if (TREE_CODE (incr) == MODIFY_EXPR)
-incr = build_x_modify_expr (RECUR (TREE_OPERAND (incr, 0)), 
NOP_EXPR,

+incr = build_x_modify_expr (input_location,


EXPR_LOC_OR_HERE (incr), I would think.

Ok.



 tree r = build_x_modify_expr
-  (RECUR (TREE_OPERAND (t, 0)),
+  (input_location,


And EXPR_LOC_OR_HERE (t).

Here I think EXPR_LOC_OR_HERE (TREE_OPERAND (t, 1)) is better.



-  iter_incr = build_x_modify_expr (iter, TREE_CODE (rhs),
+  iter_incr = build_x_modify_expr (input_location,
+   iter, TREE_CODE (rhs),
TREE_OPERAND (rhs, 1),


And EXPR_LOC_OR_HERE (rhs).

And so on.
Agreed, sorry about a bit of sloppiness on my part, I didn't see any 
obvious "expr" very close and gave up too quickly (because wasn't 
risking regressions ;) Now I went through all of them and also fixed two 
or three input_location which I added days ago in build_x_binary_op 
calls. Also, in the case of the code synthesized in the final part of 
handle_omp_for_class_iterator Jakub had already prepared elocus (and 
used it in error_at).


Anyway, the below is finishing testing. Ok if it passes?

Thanks,
Paolo.

///
Index: testsuite/g++.dg/parse/error49.C
===
--- testsuite/g++.dg/parse/error49.C(revision 0)
+++ testsuite/g++.dg/parse/error49.C(revision 0)
@@ -0,0 +1,10 @@
+// PR c++/44516
+
+struct WebService {  };
+struct Server {  };
+
+void addHTTPService(Server const &server,
+   WebService const *http)
+{
+  server += http; // { dg-error "10:no match for 'operator\\+='" }
+}
Index: cp/typeck.c
===
--- cp/typeck.c (revision 187435)
+++ cp/typeck.c (working copy)
@@ -7105,8 +7105,8 @@ cp_build_modify_expr (tree lhs, enum tree_code mod
 }
 
 tree
-build_x_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
-tsubst_flags_t complain)
+build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
+tree rhs, tsubst_flags_t complain)
 {
   if (processing_template_decl)
 return build_min_nt (MODOP_EXPR, lhs,
@@ -7114,7 +7114,7 @@ tree
 
   if (modifycode != NOP_EXPR)
 {
-  tree rval = build_new_op (input_location, MODIFY_EXPR, LOOKUP_NORMAL,
+  tree rval = build_new_op (loc, MODIFY_EXPR, LOOKUP_NORMAL,
lhs, rhs, make_node (modifycode),
/*overload=*/NULL, complain);
   if (rval)
Index: cp/pt.c
===
--- cp/pt.c (revision 187435)
+++ cp/pt.c (working copy)
@@ -12672,7 +12672,8 @@ tsubst_omp_for_iterator (tree t, int i, tree declv
   cond = RECUR (TREE_VEC_ELT (OMP_FOR_COND (t), i));
   incr = TREE_VEC_ELT (OMP_FOR_INCR (t), i);
   if (TREE_CODE (incr) == MODIFY_EXPR)
-   incr = build_x_modify_expr (RECUR (TREE_OPERAND (incr, 0)), NOP_EXPR,
+   incr = build_x_modify_expr (EXPR_LOC_OR_HERE (incr),
+   RECUR (TREE_OPERAND (incr, 0)), NOP_EXPR,
RECUR (TREE_OPERAND (incr, 1)),
complain);
   else
@@ -13692,7 +13693,8 @@ tsubst_copy_and_build (tree t,
 case MODOP_EXPR:
   {
tree r = build_x_modify_expr
- (RECUR (TREE_OPERAND (t, 0)),
+ (EXPR_LOC_OR_HERE (TREE_OPERAND (t, 1)),
+  RECUR (TREE_OPERAND (t, 0)),
   TREE_CODE (TREE_OPERAND (t, 1)),
   RECUR (TREE_OPERAND (t, 2)),
   complain);
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 187435)
+++ cp/semantics.c  (working copy)
@@ -4456,7 +4456,8 @@ handle_omp_for_class_iterator (int i, location_t l
cond = error_mark_node;
   else
{
- tree tem = build_x_binary_op (input_location, TREE_CODE (cond),
+ tree tem = build_x_binary_op (EXPR_LOC_OR_HERE (cond),
+   TREE_CODE (cond),
iter, ERROR_MARK,
TREE_OPERAND (cond, 1), ERROR_MARK,
NULL, tf_warning_or_error);
@@ -4473,7 +4474,7 @@ handle_omp_for_class_iterator (int i, location_t l
   error_at (elocus, "invalid controlling predicate");
   return true;
 }
-  diff = build_x_binary_op (input_location, MINUS_EXPR, TREE_OPERAND (cond, 1),
+  diff = build_x_binary_op (elocus, MINUS_EXPR, TREE_OPERAND (cond, 1),
ERROR_MARK, iter, ERROR_MARK, NULL,
tf_warning_or_error);
   if (error_op

Re: [PATCH] Support for known unknown alignment

2012-05-13 Thread H.J. Lu
On Fri, Apr 27, 2012 at 5:02 AM, Martin Jambor  wrote:
> Hi,
>
> On Tue, Apr 24, 2012 at 12:31:38PM +0200, Martin Jambor wrote:
>> Hi,
>>
>> On Mon, Apr 23, 2012 at 03:30:19PM +0200, Richard Guenther wrote:
>> > On Mon, 23 Apr 2012, Martin Jambor wrote:
>> >
>> > > Hi,
>> > >
>> > > On Mon, Apr 23, 2012 at 12:50:51PM +0200, Richard Guenther wrote:
>> > > > On Fri, 20 Apr 2012, Martin Jambor wrote:
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > two days ago I talked to Richi on IRC about the functions to 
>> > > > > determine
>> > > > > the expected alignment of objects and pointers we have and he
>> > > > > suggested that get_object_alignment_1 and get_pointer_alignment_1
>> > > > > should return whether the alignment is actually known and return the
>> > > > > actual alignment in a reference variable (as they currently return
>> > > > > bitpos).
>> > > > >
>>
> ...
>
>> The testsuite differences I got on Friday were probably noise, tonight
>> (on an updated svn tree) I did not get any on ppc64-linux,
>> x86_64-linux or i686-linux.  Considering that and the OK above, I'm
>> going to bootstrap and test also on sparc64-linux and ia64-linux and
>> if those pass too, I'll commit the patch tomorrow, unless there are
>> any objections.
>>
>
> There is a Fortran testsuite that, on sparc64-linux, showed that my
> clever simplification of get_object_alignment_1 handling of
> TARGET_MEM_REFs was actually very dumb.  So this is the working patch,
> successfully bootstrapped and tested on x86_64-linux (all languages
> and Ada), i686-linux (likewise), sparc64-linux (all languages - Java +
> Ada), ia64-linux (all languages) and ppc64-linux (likewise) and tested
> on hppa-linux (C and C++ only).
>
> I still consider the patch approved because it actually changes less
> stuff but do not want to commit it before a weekend so intend to do it
> next week.
>
> Thanks,
>
> Martin
>
>
> 2012-04-25  Martin Jambor  
>
>        * builtins.c (get_object_alignment_1): Return whether we can determine
>        the alignment or conservatively assume byte alignment.  Return the
>        alignment by reference.  Use get_pointer_alignment_1 for dereference
>        alignment.
>        (get_pointer_alignment_1): Return whether we can determine the
>        alignment or conservatively assume byte alignment.  Return the
>        alignment by reference.  Use get_ptr_info_alignment to get SSA name
>        alignment.
>        (get_object_alignment): Update call to get_object_alignment_1.
>        (get_object_or_type_alignment): Likewise, fall back to type alignment
>        only when it returned false.
>        (get_pointer_alignment): Update call to get_pointer_alignment_1.
>        * fold-const.c (get_pointer_modulus_and_residue): Update call to
>        get_object_alignment_1.
>        * ipa-prop.c (ipa_modify_call_arguments): Update call to
>        get_pointer_alignment_1.
>        * tree-sra.c (build_ref_for_offset): Likewise, fall back to the type
>        of MEM_REF or TARGET_MEM_REF only when it returns false.
>        * tree-ssa-ccp.c (get_value_from_alignment): Update call to
>        get_object_alignment_1.
>        (ccp_finalize): Use set_ptr_info_alignment.
>        * tree.h (get_object_alignment_1): Update declaration.
>        (get_pointer_alignment_1): Likewise.
>        * gimple-pretty-print.c (dump_gimple_phi): Use get_ptr_info_alignment.
>        (dump_gimple_stmt): Likewise.
>        * tree-flow.h (ptr_info_def): Updated comments of fields align and
>        misalign.
>        (get_ptr_info_alignment): Declared.
>        (mark_ptr_info_alignment_unknown): Likewise.
>        (set_ptr_info_alignment): Likewise.
>        (adjust_ptr_info_misalignment): Likewise.
>        * tree-ssa-address.c (copy_ref_info): Use new access functions to get
>        and set alignment of SSA names.
>        * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Call
>        mark_ptr_info_alignment_unknown.
>        * tree-ssanames.c (get_ptr_info_alignment): New function.
>        (mark_ptr_info_alignment_unknown): Likewise.
>        (set_ptr_info_alignment): Likewise.
>        (adjust_ptr_info_misalignment): Likewise.
>        (get_ptr_info): Call mark_ptr_info_alignment_unknown.
>        * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
>        Likewise.
>        (bump_vector_ptr): Likewise.
>        * tree-vect-stmts.c (create_array_ref): Use set_ptr_info_alignment.
>        (vectorizable_store): Likewise.
>        (vectorizable_load): Likewise.
>
>

This caused:

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


-- 
H.J.


Re: [C++ Patch] PR 44516

2012-05-13 Thread Jason Merrill

On 05/13/2012 11:24 PM, Paolo Carlini wrote:

 tree r = build_x_modify_expr
-  (RECUR (TREE_OPERAND (t, 0)),
+  (input_location,


And EXPR_LOC_OR_HERE (t).

Here I think EXPR_LOC_OR_HERE (TREE_OPERAND (t, 1)) is better.


Why?  TREE_OPERAND (t,1) is a dummy tree that we only use for its code.

Of course, currently it doesn't matter because we don't 
SET_EXPR_LOCATION on either the MODOP_EXPR or its operand 1, so 
EXPR_LOC_OR_HERE on either one will give input_location.


I guess we want a build_min_nt_loc function.

Jason


Re: [C++ Patch] fix semi-random template specialization ICE

2012-05-13 Thread Alexandre Oliva
On May 10, 2012, Jason Merrill  wrote:

> OK.

Thanks, installed a few days ago.

Is it ok for the 4.7 branch too?  I didn't realize the bug could occur
there as well, but PR c++/53209 suggests it does.  Regstrapping now.

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist  Red Hat Brazil Compiler Engineer