Re: [PATCH] use cfglayout mode for instatiate_virtual_regs

2011-03-24 Thread H.J. Lu
On Thu, Mar 24, 2011 at 9:11 PM, H.J. Lu  wrote:
> On Thu, Mar 24, 2011 at 4:47 AM, Nathan Froyd  
> wrote:
>> As $SUBJECT suggests.  The patch looks much bigger than it actually is
>> due to re-indentation.
>>
>> Tested on x86_64-unknown-linux-gnu.  OK to commit?

Did you run -m32 tests on Linux/x86-64? Many 32bit tests failed on Linux/x86-64:

http://gcc.gnu.org/ml/gcc-testresults/2011-03/msg02419.html

>>
>> -Nathan
>>
>>        * function.c (instantiate_virtual_regs): Use FOR_EACH_BB and
>>        FOR_BB_INSNS_SAFE to iterate through insns.  Re-indent.
>>        * passes.c (init_optimization_passes): Move
>>        pass_instantiate_virtual_regs after pass_into_cfg_layout_mode.
>>
>
> This caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48282
>

-- 
H.J.


Go patch committed: Remove closed function

2011-03-24 Thread Ian Lance Taylor
The predeclared function "closed" has been removed from the Go language,
as it is no longer necessary now that v, ok = <-c returns whether the
channel is closed.  This patch implements that in gccgo.  This patch
also fixes the handling of case v, ok := <-c in a select statement.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 8de7f64be423 go/expressions.cc
--- a/go/expressions.cc	Thu Mar 24 16:37:44 2011 -0700
+++ b/go/expressions.cc	Thu Mar 24 21:58:25 2011 -0700
@@ -6530,7 +6530,6 @@
   BUILTIN_APPEND,
   BUILTIN_CAP,
   BUILTIN_CLOSE,
-  BUILTIN_CLOSED,
   BUILTIN_COMPLEX,
   BUILTIN_COPY,
   BUILTIN_IMAG,
@@ -6588,8 +6587,6 @@
 this->code_ = BUILTIN_CAP;
   else if (name == "close")
 this->code_ = BUILTIN_CLOSE;
-  else if (name == "closed")
-this->code_ = BUILTIN_CLOSED;
   else if (name == "complex")
 this->code_ = BUILTIN_COMPLEX;
   else if (name == "copy")
@@ -7185,9 +7182,6 @@
 case BUILTIN_PRINTLN:
   return Type::make_void_type();
 
-case BUILTIN_CLOSED:
-  return Type::lookup_bool_type();
-
 case BUILTIN_RECOVER:
   return Type::make_interface_type(NULL, BUILTINS_LOCATION);
 
@@ -7451,7 +7445,6 @@
   break;
 
 case BUILTIN_CLOSE:
-case BUILTIN_CLOSED:
   if (this->check_one_arg())
 	{
 	  if (this->one_arg()->type()->channel_type() == NULL)
@@ -7936,7 +7929,6 @@
   }
 
 case BUILTIN_CLOSE:
-case BUILTIN_CLOSED:
   {
 	const Expression_list* args = this->args();
 	gcc_assert(args != NULL && args->size() == 1);
@@ -7944,28 +7936,14 @@
 	tree arg_tree = arg->get_tree(context);
 	if (arg_tree == error_mark_node)
 	  return error_mark_node;
-	if (this->code_ == BUILTIN_CLOSE)
-	  {
-	static tree close_fndecl;
-	return Gogo::call_builtin(&close_fndecl,
-  location,
-  "__go_builtin_close",
-  1,
-  void_type_node,
-  TREE_TYPE(arg_tree),
-  arg_tree);
-	  }
-	else
-	  {
-	static tree closed_fndecl;
-	return Gogo::call_builtin(&closed_fndecl,
-  location,
-  "__go_builtin_closed",
-  1,
-  boolean_type_node,
-  TREE_TYPE(arg_tree),
-  arg_tree);
-	  }
+	static tree close_fndecl;
+	return Gogo::call_builtin(&close_fndecl,
+  location,
+  "__go_builtin_close",
+  1,
+  void_type_node,
+  TREE_TYPE(arg_tree),
+  arg_tree);
   }
 
 case BUILTIN_SIZEOF:
diff -r 8de7f64be423 go/gogo.cc
--- a/go/gogo.cc	Thu Mar 24 16:37:44 2011 -0700
+++ b/go/gogo.cc	Thu Mar 24 21:58:25 2011 -0700
@@ -173,15 +173,6 @@
   close_type->set_is_builtin();
   this->globals_->add_function_declaration("close", NULL, close_type, loc);
 
-  Typed_identifier_list* closed_result = new Typed_identifier_list();
-  closed_result->push_back(Typed_identifier("", Type::lookup_bool_type(),
-	loc));
-  Function_type* closed_type = Type::make_function_type(NULL, NULL,
-			closed_result, loc);
-  closed_type->set_is_varargs();
-  closed_type->set_is_builtin();
-  this->globals_->add_function_declaration("closed", NULL, closed_type, loc);
-
   Typed_identifier_list* copy_result = new Typed_identifier_list();
   copy_result->push_back(Typed_identifier("", int_type, loc));
   Function_type* copy_type = Type::make_function_type(NULL, NULL,
@@ -3506,12 +3497,15 @@
 	  true);
   this->init_ = NULL;
 }
+  else if (this->type_from_chan_element_)
+{
+  Expression* init = this->init_;
+  init->determine_type_no_context();
+  this->type_ = this->type_from_chan_element(init, true);
+  this->init_ = NULL;
+}
   else
 {
-  // type_from_chan_element_ should have been cleared during
-  // lowering.
-  gcc_assert(!this->type_from_chan_element_);
-
   Type_context context(this->type_, false);
   this->init_->determine_type(&context);
   if (this->type_ == NULL)
diff -r 8de7f64be423 go/parse.cc
--- a/go/parse.cc	Thu Mar 24 16:37:44 2011 -0700
+++ b/go/parse.cc	Thu Mar 24 21:58:25 2011 -0700
@@ -1717,6 +1717,7 @@
   Statement* s = Statement::make_tuple_receive_assignment(val_var,
 			  received_var,
 			  receive->channel(),
+			  false,
 			  location);
 
   if (!this->gogo_->in_global_scope())
@@ -3629,6 +3630,7 @@
   Expression* channel = receive->channel();
   Statement* s = Statement::make_tuple_receive_assignment(val, success,
 			  channel,
+			  false,
 			  location);
   this->gogo_->add_statement(s);
 }
diff -r 8de7f64be423 go/statements.cc
--- a/go/statements.cc	Thu Mar 24 16:37:44 2011 -0700
+++ b/go/statements.cc	Thu Mar 24 21:58:25 2011 -0700
@@ -1148,10 +1148,10 @@
 {
  public:
   Tuple_receive_assignment_statement(Expression* val, Expression* closed,
- Expression* channel,
+ Expression* channel, bool for_select,
  source_location location)
 : Statement(STATEMENT_TUPLE_RECEIVE_ASSIGNMENT, location),
-  

Re: [PATCH] use cfglayout mode for instatiate_virtual_regs

2011-03-24 Thread H.J. Lu
On Thu, Mar 24, 2011 at 4:47 AM, Nathan Froyd  wrote:
> As $SUBJECT suggests.  The patch looks much bigger than it actually is
> due to re-indentation.
>
> Tested on x86_64-unknown-linux-gnu.  OK to commit?
>
> -Nathan
>
>        * function.c (instantiate_virtual_regs): Use FOR_EACH_BB and
>        FOR_BB_INSNS_SAFE to iterate through insns.  Re-indent.
>        * passes.c (init_optimization_passes): Move
>        pass_instantiate_virtual_regs after pass_into_cfg_layout_mode.
>

This caused:

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


-- 
H.J.


Re: [alpha] Revert input_operand change for vms

2011-03-24 Thread Richard Henderson
On 03/24/2011 05:06 PM, Richard Henderson wrote:
> While purging Windows code, I failed to remember that VMS has a 32-bit
> mode as well, and thus this line still matters.

Bah.  This patch, not the other one.


r~
commit 3351cef043c126925829c9b414a087251dc67e45
Author: rth 
Date:   Fri Mar 25 00:04:19 2011 +

alpha: Revert change to input_operand for 32-bit vms.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171428 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 85c45b6..aef5088 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-24  Richard Henderson  
+
+   * config/alpha/predicates.md (input_operand): Revert last change;
+   update comment to mention 32-bit VMS rather than Windows.
+
 2011-03-24  Nathan Froyd  
 
* function.c (instantiate_virtual_regs): Use FOR_EACH_BB and
diff --git a/gcc/config/alpha/predicates.md b/gcc/config/alpha/predicates.md
index 9514b8a..da76d4f 100644
--- a/gcc/config/alpha/predicates.md
+++ b/gcc/config/alpha/predicates.md
@@ -195,7 +195,8 @@
  || gotdtp_symbolic_operand (op, mode)
  || gottp_symbolic_operand (op, mode));
}
-  return mode == Pmode;
+  /* VMS still has a 32-bit mode.  */
+  return mode == ptr_mode || mode == Pmode;
 
 case HIGH:
   return (TARGET_EXPLICIT_RELOCS


[alpha] Tidy some byte manipulation users.

2011-03-24 Thread Richard Henderson
We have helper expanders -- originally for the builtins -- so that we can
write mskwh instead of mskxh-plus-magic-argument.  Use them more often.


r~
+   * config/alpha/alpha.c (alpha_expand_unaligned_load): Use extql.
+   (alpha_expand_unaligned_store): Use mskwl, mskll, mskql.
+   (alpha_expand_unaligned_load_words): Use extql.
+   (alpha_expand_unaligned_store_words): Use insqh, mskqh, mskql.
+   (emit_insxl): Handle all modes for consistency.



diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 4885be6..c55587b 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -3347,7 +3347,7 @@ alpha_expand_unaligned_load (rtx tgt, rtx mem, 
HOST_WIDE_INT size,
 {
   emit_move_insn (addr, plus_constant (mema, ofs+2));
 
-  emit_insn (gen_extxl (extl, meml, GEN_INT (64), addr));
+  emit_insn (gen_extql (extl, meml, addr));
   emit_insn (gen_extqh (exth, memh, addr));
 
   /* We must use tgt here for the target.  Alpha-vms port fails if we use
@@ -3367,17 +3367,14 @@ alpha_expand_unaligned_load (rtx tgt, rtx mem, 
HOST_WIDE_INT size,
  emit_insn (gen_extwh (exth, memh, addr));
  mode = HImode;
  break;
-
case 4:
  emit_insn (gen_extlh (exth, memh, addr));
  mode = SImode;
  break;
-
case 8:
  emit_insn (gen_extqh (exth, memh, addr));
  mode = DImode;
  break;
-
default:
  gcc_unreachable ();
}
@@ -3475,16 +3472,13 @@ alpha_expand_unaligned_store (rtx dst, rtx src,
   switch ((int) size)
 {
 case 2:
-  emit_insn (gen_mskxl (dstl, dstl, GEN_INT (0x), addr));
+  emit_insn (gen_mskwl (dstl, dstl, addr));
   break;
 case 4:
-  {
-   rtx msk = immed_double_const (0x, 0, DImode);
-   emit_insn (gen_mskxl (dstl, dstl, msk, addr));
-   break;
-  }
+  emit_insn (gen_mskll (dstl, dstl, addr));
+  break;
 case 8:
-  emit_insn (gen_mskxl (dstl, dstl, constm1_rtx, addr));
+  emit_insn (gen_mskql (dstl, dstl, addr));
   break;
 default:
   gcc_unreachable ();
@@ -3516,7 +3510,6 @@ alpha_expand_unaligned_load_words (rtx *out_regs, rtx 
smem,
   HOST_WIDE_INT words, HOST_WIDE_INT ofs)
 {
   rtx const im8 = GEN_INT (-8);
-  rtx const i64 = GEN_INT (64);
   rtx ext_tmps[MAX_MOVE_WORDS], data_regs[MAX_MOVE_WORDS+1];
   rtx sreg, areg, tmp, smema;
   HOST_WIDE_INT i;
@@ -3563,7 +3556,7 @@ alpha_expand_unaligned_load_words (rtx *out_regs, rtx 
smem,
   1, OPTAB_WIDEN);
   for (i = 0; i < words; ++i)
 {
-  emit_insn (gen_extxl (data_regs[i], data_regs[i], i64, sreg));
+  emit_insn (gen_extql (data_regs[i], data_regs[i], sreg));
   emit_insn (gen_extqh (ext_tmps[i], data_regs[i+1], sreg));
   emit_insn (gen_rtx_SET (VOIDmode, ext_tmps[i],
  gen_rtx_IF_THEN_ELSE (DImode,
@@ -3588,7 +3581,6 @@ alpha_expand_unaligned_store_words (rtx *data_regs, rtx 
dmem,
HOST_WIDE_INT words, HOST_WIDE_INT ofs)
 {
   rtx const im8 = GEN_INT (-8);
-  rtx const i64 = GEN_INT (64);
   rtx ins_tmps[MAX_MOVE_WORDS];
   rtx st_tmp_1, st_tmp_2, dreg;
   rtx st_addr_1, st_addr_2, dmema;
@@ -3628,7 +3620,7 @@ alpha_expand_unaligned_store_words (rtx *data_regs, rtx 
dmem,
 {
   for (i = words-1; i >= 0; --i)
{
- emit_insn (gen_insxh (ins_tmps[i], data_regs[i], i64, dreg));
+ emit_insn (gen_insqh (ins_tmps[i], data_regs[i], dreg));
  emit_insn (gen_insql (data_regs[i], data_regs[i], dreg));
}
   for (i = words-1; i > 0; --i)
@@ -3640,8 +3632,8 @@ alpha_expand_unaligned_store_words (rtx *data_regs, rtx 
dmem,
 }
 
   /* Split and merge the ends with the destination data.  */
-  emit_insn (gen_mskxh (st_tmp_2, st_tmp_2, i64, dreg));
-  emit_insn (gen_mskxl (st_tmp_1, st_tmp_1, constm1_rtx, dreg));
+  emit_insn (gen_mskqh (st_tmp_2, st_tmp_2, dreg));
+  emit_insn (gen_mskql (st_tmp_1, st_tmp_1, dreg));
 
   if (data_regs != NULL)
 {
@@ -4311,12 +4303,24 @@ emit_insxl (enum machine_mode mode, rtx op1, rtx op2)
   rtx ret = gen_reg_rtx (DImode);
   rtx (*fn) (rtx, rtx, rtx);
 
-  if (mode == QImode)
-fn = gen_insbl;
-  else
-fn = gen_inswl;
+  switch (mode)
+{
+case QImode:
+  fn = gen_insbl;
+  break;
+case HImode:
+  fn = gen_inswl;
+  break;
+case SImode:
+  fn = gen_insll;
+  break;
+case DImode:
+  fn = gen_insql;
+  break;
+default:
+  gcc_unreachable ();
+}
 
-  /* The insbl and inswl patterns require a register operand.  */
   op1 = force_reg (mode, op1);
   emit_insn (fn (ret, op1, op2));
 


[alpha] Unify movdi with attribute enabled.

2011-03-24 Thread Richard Henderson
This handles the movdi pattern, of which there were four copies...


r~
+   * config/alpha/alpha.md (attribute isa): Add er, ner.
+   (attribute enabled): Handle them.
+   (*movdi): Merge *movdi_{er_nofix,nofix,er_fix,fix}.


diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index 0f71292..2161e64 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -181,7 +181,7 @@
 ;; Used to control the "enabled" attribute on a per-instruction basis.
 ;; For convenience, conflate ABI issues re loading of addresses with
 ;; an "isa".
-(define_attr "isa" "base,bwx,max,fix,cix,vms"
+(define_attr "isa" "base,bwx,max,fix,cix,vms,ner,er"
   (const_string "base"))
 
 (define_attr "enabled" ""
@@ -189,7 +189,9 @@
 (eq_attr "isa" "max")  (symbol_ref "TARGET_MAX")
 (eq_attr "isa" "fix")  (symbol_ref "TARGET_FIX")
 (eq_attr "isa" "cix")  (symbol_ref "TARGET_CIX")
- (eq_attr "isa" "vms")  (symbol_ref "TARGET_ABI_OPEN_VMS")
+(eq_attr "isa" "vms")  (symbol_ref "TARGET_ABI_OPEN_VMS")
+(eq_attr "isa" "ner")  (symbol_ref "!TARGET_EXPLICIT_RELOCS")
+(eq_attr "isa" "er")   (symbol_ref "TARGET_EXPLICIT_RELOCS")
]
(const_int 1)))
 
@@ -4869,54 +4871,13 @@
   operands[2] = pic_offset_table_rtx;
 })
 
-(define_insn "*movdi_er_nofix"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,r,r,m,*f,*f,Q")
-   (match_operand:DI 1 "input_operand" "rJ,K,L,T,s,n,m,rJ,*fJ,Q,*f"))]
-  "TARGET_EXPLICIT_RELOCS && ! TARGET_FIX
-   && (register_operand (operands[0], DImode)
-   || reg_or_0_operand (operands[1], DImode))"
-  "@
-   mov %r1,%0
-   lda %0,%1($31)
-   ldah %0,%h1($31)
-   #
-   #
-   #
-   ldq%A1 %0,%1
-   stq%A0 %r1,%0
-   fmov %R1,%0
-   ldt %0,%1
-   stt %R1,%0"
-  [(set_attr "type" "ilog,iadd,iadd,iadd,ldsym,multi,ild,ist,fcpys,fld,fst")
-   (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*,*")])
-
-(define_insn "*movdi_nofix"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,r,r,r,m,*f,*f,Q")
-   (match_operand:DI 1 "input_operand" "rJ,K,L,s,n,m,rJ,*fJ,Q,*f"))]
-  "! TARGET_FIX
-   && (register_operand (operands[0], DImode)
-   || reg_or_0_operand (operands[1], DImode))"
-  "@
-   bis $31,%r1,%0
-   lda %0,%1($31)
-   ldah %0,%h1($31)
-   lda %0,%1
-   #
-   ldq%A1 %0,%1
-   stq%A0 %r1,%0
-   cpys %R1,%R1,%0
-   ldt %0,%1
-   stt %R1,%0"
-  [(set_attr "type" "ilog,iadd,iadd,ldsym,multi,ild,ist,fcpys,fld,fst")])
-
-(define_insn "*movdi_er_fix"
+(define_insn "*movdi"
   [(set (match_operand:DI 0 "nonimmediate_operand"
-   "=r,r,r,r,r,r,r, m, *f,*f, Q, r,*f")
+   "=r,r,r,r,r,r,r,r, m, *f,*f, Q, r,*f")
(match_operand:DI 1 "input_operand"
-   "rJ,K,L,T,s,n,m,rJ,*fJ, Q,*f,*f, r"))]
-  "TARGET_EXPLICIT_RELOCS && TARGET_FIX
-   && (register_operand (operands[0], DImode)
-   || reg_or_0_operand (operands[1], DImode))"
+   "rJ,K,L,T,s,n,s,m,rJ,*fJ, Q,*f,*f, r"))]
+  "register_operand (operands[0], DImode)
+   || reg_or_0_operand (operands[1], DImode)"
   "@
mov %r1,%0
lda %0,%1($31)
@@ -4924,36 +4885,17 @@
#
#
#
-   ldq%A1 %0,%1
-   stq%A0 %r1,%0
-   fmov %R1,%0
-   ldt %0,%1
-   stt %R1,%0
-   ftoit %1,%0
-   itoft %1,%0"
-  [(set_attr "type" 
"ilog,iadd,iadd,iadd,ldsym,multi,ild,ist,fcpys,fld,fst,ftoi,itof")
-   (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*,*,*,*")])
-
-(define_insn "*movdi_fix"
-  [(set (match_operand:DI 0 "nonimmediate_operand" 
"=r,r,r,r,r,r,m,*f,*f,Q,r,*f")
-   (match_operand:DI 1 "input_operand" "rJ,K,L,s,n,m,rJ,*fJ,Q,*f,*f,r"))]
-  "! TARGET_EXPLICIT_RELOCS && TARGET_FIX
-   && (register_operand (operands[0], DImode)
-   || reg_or_0_operand (operands[1], DImode))"
-  "@
-   bis $31,%r1,%0
-   lda %0,%1($31)
-   ldah %0,%h1($31)
lda %0,%1
-   #
ldq%A1 %0,%1
stq%A0 %r1,%0
-   cpys %R1,%R1,%0
+   fmov %R1,%0
ldt %0,%1
stt %R1,%0
ftoit %1,%0
itoft %1,%0"
-  [(set_attr "type" 
"ilog,iadd,iadd,ldsym,multi,ild,ist,fcpys,fld,fst,ftoi,itof")])
+  [(set_attr "type" 
"ilog,iadd,iadd,iadd,ldsym,multi,ldsym,ild,ist,fcpys,fld,fst,ftoi,itof")
+   (set_attr "isa" "*,*,*,er,er,*,ner,*,*,*,*,*,fix,fix")
+   (set_attr "usegp" "*,*,*,yes,*,*,*,*,*,*,*,*,*,*")])
 
 ;; VMS needs to set up "vms_base_regno" for unwinding.  This move
 ;; often appears dead to the life analysis code, at which point we


[alpha] Unify most move patterns with attribute enabled

2011-03-24 Thread Richard Henderson
This handles everything except movdi, which is more complex.

One perhaps non-obvious thing is the use of the ABI as an "isa"
entry with respect to the loading of an address constant.  This
appears in movsi for VMS.  This turns out to be significantly
easier than using two different attributes to control "enabled"
and I couldn't think of a better name than "isa".


r~
+   * config/alpha/alpha.md (attribute isa): Add vms.
+   (attribute enabled): Handle it.
+   (*movsf): Merge *movsf_{nofix,fix,nofp}.
+   (*movdf): Merge *movdf_{nofix,fix,nofp}.
+   (*movtf): Rename from *movtf_internal for consistency.
+   (*movsi): Merge with *movsi_nt_vms.
+   (*movhi): Merge *movhi_nobwx, *movhi_bwx.
+   (*movqi): Merge *movqi_nobwx, *movqi_bwx.
+   (*mov): Merge *mov_fix, *mov_nofix.
+   * config/alpha/constraint.md ("f"): Use NO_REGS when fpu is disabled.



diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index f37a5b3..0f71292 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -179,7 +179,9 @@
   (const_string "false"))
 
 ;; Used to control the "enabled" attribute on a per-instruction basis.
-(define_attr "isa" "base,bwx,max,fix,cix"
+;; For convenience, conflate ABI issues re loading of addresses with
+;; an "isa".
+(define_attr "isa" "base,bwx,max,fix,cix,vms"
   (const_string "base"))
 
 (define_attr "enabled" ""
@@ -187,6 +189,7 @@
 (eq_attr "isa" "max")  (symbol_ref "TARGET_MAX")
 (eq_attr "isa" "fix")  (symbol_ref "TARGET_FIX")
 (eq_attr "isa" "cix")  (symbol_ref "TARGET_CIX")
+ (eq_attr "isa" "vms")  (symbol_ref "TARGET_ABI_OPEN_VMS")
]
(const_int 1)))
 
@@ -4607,27 +4610,21 @@
 ;; are done via define_expand.  Start with the floating-point insns, since
 ;; they are simpler.
 
-(define_insn "*movsf_nofix"
-  [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
-   (match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
-  "TARGET_FPREGS && ! TARGET_FIX
-   && (register_operand (operands[0], SFmode)
-   || reg_or_0_operand (operands[1], SFmode))"
-  "@
-   cpys %R1,%R1,%0
-   ld%, %0,%1
-   bis $31,%r1,%0
-   ldl %0,%1
-   st%, %R1,%0
-   stl %r1,%0"
-  [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
+(define_expand "movsf"
+  [(set (match_operand:SF 0 "nonimmediate_operand" "")
+   (match_operand:SF 1 "general_operand" ""))]
+  ""
+{
+  if (MEM_P (operands[0])
+  && ! reg_or_0_operand (operands[1], SFmode))
+operands[1] = force_reg (SFmode, operands[1]);
+})
 
-(define_insn "*movsf_fix"
+(define_insn "*movsf"
   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
(match_operand:SF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
-  "TARGET_FPREGS && TARGET_FIX
-   && (register_operand (operands[0], SFmode)
-   || reg_or_0_operand (operands[1], SFmode))"
+  "register_operand (operands[0], SFmode)
+   || reg_or_0_operand (operands[1], SFmode)"
   "@
cpys %R1,%R1,%0
ld%, %0,%1
@@ -4637,41 +4634,24 @@
stl %r1,%0
itofs %1,%0
ftois %1,%0"
-  [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
-
-(define_insn "*movsf_nofp"
-  [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m")
-   (match_operand:SF 1 "input_operand" "rG,m,r"))]
-  "! TARGET_FPREGS
-   && (register_operand (operands[0], SFmode)
-   || reg_or_0_operand (operands[1], SFmode))"
-  "@
-   bis $31,%r1,%0
-   ldl %0,%1
-   stl %r1,%0"
-  [(set_attr "type" "ilog,ild,ist")])
-
-(define_insn "*movdf_nofix"
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m")
-   (match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r"))]
-  "TARGET_FPREGS && ! TARGET_FIX
-   && (register_operand (operands[0], DFmode)
-   || reg_or_0_operand (operands[1], DFmode))"
-  "@
-   cpys %R1,%R1,%0
-   ld%- %0,%1
-   bis $31,%r1,%0
-   ldq %0,%1
-   st%- %R1,%0
-   stq %r1,%0"
-  [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist")])
+  [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")
+   (set_attr "isa" "*,*,*,*,*,*,fix,fix")])
 
-(define_insn "*movdf_fix"
+(define_expand "movdf"
+  [(set (match_operand:DF 0 "nonimmediate_operand" "")
+   (match_operand:DF 1 "general_operand" ""))]
+  ""
+{
+  if (MEM_P (operands[0])
+  && ! reg_or_0_operand (operands[1], DFmode))
+operands[1] = force_reg (DFmode, operands[1]);
+})
+
+(define_insn "*movdf"
   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,*r,*r,m,m,f,*r")
(match_operand:DF 1 "input_operand" "fG,m,*rG,m,fG,*r,*r,f"))]
-  "TARGET_FPREGS && TARGET_FIX
-   && (register_operand (operands[0], DFmode)
-   || reg_or_0_operand (operands[1], DFmode))"
+  "register_operand (operands[0], DFmode)
+   || reg_or_0_operand (operands[1], DFmode)"
   "@
cpys %R1,%R1,%0
ld%- %0,%1
@@ -4681,24 +4661,24 @@
stq %r1,%0
itoft %1,%0
ftoit %1,%0"
-  [(set_attr "type" "fcpys,fld,ilog,ild,fst,ist,itof,ftoi")])
-
-(define_insn "*movdf_nofp"
-  [(set 

[alpha] cleanup sign_extension patterns

2011-03-24 Thread Richard Henderson
We don't get a chance to use attribute enabled here, but we can
eliminate some unnecessary expanders.

The non-BWX expansion paths wound up subregging the input to 
DImode to perform the operation and subregging it back.  Exactly
as the generic code paths would do.

I didn't investigate what eliminating the sub-word patterns
for BWX code has on the generated code.  In theory these are
not needed either, also handled by the generic code paths...


r~
+   * config/alpha/alpha.md (extendqihi2): Implement for BWX only.
+   (extendqisi2, extendhisi2): Likewise.
+   (extendqidi2): Simplify BWX/non-BWX expansions.
+   (extendhidi2): Similarly.



diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index cb3821c..f37a5b3 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -1413,194 +1413,103 @@
   "sra %r1,%2,%0"
   [(set_attr "type" "shift")])
 
-(define_expand "extendqihi2"
-  [(set (match_dup 2)
-   (ashift:DI (match_operand:QI 1 "some_operand" "")
-  (const_int 56)))
-   (set (match_operand:HI 0 "register_operand" "")
-   (ashiftrt:DI (match_dup 2)
-(const_int 56)))]
-  ""
-{
-  if (TARGET_BWX)
-{
-  emit_insn (gen_extendqihi2x (operands[0],
-  force_reg (QImode, operands[1])));
-  DONE;
-}
-
- /* If we have an unaligned MEM, extend to DImode (which we do
- specially) and then copy to the result.  */
-  if (unaligned_memory_operand (operands[1], HImode))
-{
-  rtx temp = gen_reg_rtx (DImode);
-
-  emit_insn (gen_extendqidi2 (temp, operands[1]));
-  emit_move_insn (operands[0], gen_lowpart (HImode, temp));
-  DONE;
-}
-
-  operands[0] = gen_lowpart (DImode, operands[0]);
-  operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
-  operands[2] = gen_reg_rtx (DImode);
-})
-
-(define_insn "extendqidi2x"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-   (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
+(define_insn "extendqihi2"
+  [(set (match_operand:HI 0 "register_operand" "=r")
+   (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
   "TARGET_BWX"
   "sextb %1,%0"
   [(set_attr "type" "shift")])
 
-(define_insn "extendhidi2x"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-   (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
-  "TARGET_BWX"
-  "sextw %1,%0"
-  [(set_attr "type" "shift")])
-
-(define_insn "extendqisi2x"
+(define_insn "extendqisi2"
   [(set (match_operand:SI 0 "register_operand" "=r")
(sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
   "TARGET_BWX"
   "sextb %1,%0"
   [(set_attr "type" "shift")])
 
-(define_insn "extendhisi2x"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
-  "TARGET_BWX"
-  "sextw %1,%0"
-  [(set_attr "type" "shift")])
-
-(define_insn "extendqihi2x"
-  [(set (match_operand:HI 0 "register_operand" "=r")
-   (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
-  "TARGET_BWX"
-  "sextb %1,%0"
-  [(set_attr "type" "shift")])
-
-(define_expand "extendqisi2"
-  [(set (match_dup 2)
-   (ashift:DI (match_operand:QI 1 "some_operand" "")
-  (const_int 56)))
-   (set (match_operand:SI 0 "register_operand" "")
-   (ashiftrt:DI (match_dup 2)
-(const_int 56)))]
-  ""
-{
-  if (TARGET_BWX)
-{
-  emit_insn (gen_extendqisi2x (operands[0],
-  force_reg (QImode, operands[1])));
-  DONE;
-}
-
-  /* If we have an unaligned MEM, extend to a DImode form of
- the result (which we do specially).  */
-  if (unaligned_memory_operand (operands[1], QImode))
-{
-  rtx temp = gen_reg_rtx (DImode);
-
-  emit_insn (gen_extendqidi2 (temp, operands[1]));
-  emit_move_insn (operands[0], gen_lowpart (SImode, temp));
-  DONE;
-}
-
-  operands[0] = gen_lowpart (DImode, operands[0]);
-  operands[1] = gen_lowpart (DImode, force_reg (QImode, operands[1]));
-  operands[2] = gen_reg_rtx (DImode);
-})
-
 (define_expand "extendqidi2"
-  [(set (match_dup 2)
-   (ashift:DI (match_operand:QI 1 "some_operand" "")
-  (const_int 56)))
-   (set (match_operand:DI 0 "register_operand" "")
-   (ashiftrt:DI (match_dup 2)
-(const_int 56)))]
+  [(set (match_operand:DI 0 "register_operand" "")
+   (sign_extend:DI (match_operand:QI 1 "some_operand" "")))]
   ""
 {
   if (TARGET_BWX)
+operands[1] = force_reg (QImode, operands[1]);
+  else
 {
-  emit_insn (gen_extendqidi2x (operands[0],
-  force_reg (QImode, operands[1])));
-  DONE;
-}
+  rtx x, t1, t2, i56;
 
-  if (unaligned_memory_operand (operands[1], QImode))
-{
-  rtx seq = gen_unaligned_extendqidi (operands[0], XEXP (operands[1], 0));
-  alpha_set_memflags (seq, operands[1]);
-  emit_ins

[alpha] Unify zero_extend patterns with attribute enabled

2011-03-24 Thread Richard Henderson
The attribute enabled feature can help avoid quite a lot of 
duplication in the alpha backend.  This begins the process
by tackling the easiest -- zero_extension, conditionalized
on the existance of the BWX instruction set extension.

Tested on alpha{,ev5,ev56,ev67}-linux.


r~
+   * config/alpha/alpha.md (attribute isa): New.
+   (attribute enabled): New.
+   (zero_extendqihi2): Merge from *zero_extendqihi2_{bwx,nobwx}.
+   (zero_extendqisi2, zero_extendqidi2): Similarly.
+   (zero_extendhisi2, zero_extendhidi2): Similarly.
+   * config/alpha/predicates.md (reg_or_bwx_memory_operand): New.
+
 
diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index 38d40b5..cb3821c 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -177,6 +177,18 @@
 
 (define_attr "cannot_copy" "false,true"
   (const_string "false"))
+
+;; Used to control the "enabled" attribute on a per-instruction basis.
+(define_attr "isa" "base,bwx,max,fix,cix"
+  (const_string "base"))
+
+(define_attr "enabled" ""
+  (cond [(eq_attr "isa" "bwx") (symbol_ref "TARGET_BWX")
+(eq_attr "isa" "max")  (symbol_ref "TARGET_MAX")
+(eq_attr "isa" "fix")  (symbol_ref "TARGET_FIX")
+(eq_attr "isa" "cix")  (symbol_ref "TARGET_CIX")
+   ]
+   (const_int 1)))
 
 ;; Include scheduling descriptions.
   
@@ -1092,130 +1104,60 @@
   operands[4] = GEN_INT (mask2);
 })
 
-(define_expand "zero_extendqihi2"
-  [(set (match_operand:HI 0 "register_operand" "")
-   (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
-
-(define_insn "*zero_extendqihi2_bwx"
+(define_insn "zero_extendqihi2"
   [(set (match_operand:HI 0 "register_operand" "=r,r")
-   (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:HI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_insn "*zero_extendqihi2_nobwx"
-  [(set (match_operand:HI 0 "register_operand" "=r")
-   (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
-
-(define_expand "zero_extendqisi2"
-  [(set (match_operand:SI 0 "register_operand" "")
-   (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
-
-(define_insn "*zero_extendqisi2_bwx"
+(define_insn "zero_extendqisi2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
-   (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:SI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
-
-(define_insn "*zero_extendqisi2_nobwx"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
-
-(define_expand "zero_extendqidi2"
-  [(set (match_operand:DI 0 "register_operand" "")
-   (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_insn "*zero_extendqidi2_bwx"
+(define_insn "zero_extendqidi2"
   [(set (match_operand:DI 0 "register_operand" "=r,r")
-   (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:DI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
-
-(define_insn "*zero_extendqidi2_nobwx"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-   (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
-
-(define_expand "zero_extendhisi2"
-  [(set (match_operand:SI 0 "register_operand" "")
-   (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (HImode, operands[1]);
-})
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_insn "*zero_extendhisi2_bwx"
+(define_insn "zero_extendhisi2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
-   (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:SI
+ (match_operand:HI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
zapnot %1,3,%0
ldwu %0,%1"
-  [(set_attr "type" "shift,ild")])
-
-(define_insn "*zero_extendhisi2_nobwx"
-  [(set (match_operand:SI 0 "register_operand" "=r")

[alpha] Revert input_operand change for vms

2011-03-24 Thread Richard Henderson
While purging Windows code, I failed to remember that VMS has a 32-bit
mode as well, and thus this line still matters.


r~
diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md
index 38d40b5..abd96c7 100644
--- a/gcc/config/alpha/alpha.md
+++ b/gcc/config/alpha/alpha.md
@@ -177,6 +177,19 @@
 
 (define_attr "cannot_copy" "false,true"
   (const_string "false"))
+
+;; Used to control the "enabled" attribute on a per-instruction basis.
+(define_attr "isa" "base,bwx,max,fix,cix,vms"
+  (const_string "base"))
+
+(define_attr "enabled" ""
+  (cond [(eq_attr "isa" "bwx") (symbol_ref "TARGET_BWX")
+(eq_attr "isa" "max")  (symbol_ref "TARGET_MAX")
+(eq_attr "isa" "fix")  (symbol_ref "TARGET_FIX")
+(eq_attr "isa" "cix")  (symbol_ref "TARGET_CIX")
+(eq_attr "isa" "vms")  (symbol_ref "TARGET_ABI_OPEN_VMS")
+   ]
+   (const_int 1)))
 
 ;; Include scheduling descriptions.
   
@@ -1092,130 +1105,60 @@
   operands[4] = GEN_INT (mask2);
 })
 
-(define_expand "zero_extendqihi2"
-  [(set (match_operand:HI 0 "register_operand" "")
-   (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
-
-(define_insn "*zero_extendqihi2_bwx"
+(define_insn "zero_extendqihi2"
   [(set (match_operand:HI 0 "register_operand" "=r,r")
-   (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:HI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
-
-(define_insn "*zero_extendqihi2_nobwx"
-  [(set (match_operand:HI 0 "register_operand" "=r")
-   (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
-
-(define_expand "zero_extendqisi2"
-  [(set (match_operand:SI 0 "register_operand" "")
-   (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_insn "*zero_extendqisi2_bwx"
+(define_insn "zero_extendqisi2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
-   (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:SI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
-
-(define_insn "*zero_extendqisi2_nobwx"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
-
-(define_expand "zero_extendqidi2"
-  [(set (match_operand:DI 0 "register_operand" "")
-   (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (QImode, operands[1]);
-})
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_insn "*zero_extendqidi2_bwx"
+(define_insn "zero_extendqidi2"
   [(set (match_operand:DI 0 "register_operand" "=r,r")
-   (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:DI
+ (match_operand:QI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
and %1,0xff,%0
ldbu %0,%1"
-  [(set_attr "type" "ilog,ild")])
-
-(define_insn "*zero_extendqidi2_nobwx"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-   (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "and %1,0xff,%0"
-  [(set_attr "type" "ilog")])
+  [(set_attr "type" "ilog,ild")
+   (set_attr "isa" "*,bwx")])
 
-(define_expand "zero_extendhisi2"
-  [(set (match_operand:SI 0 "register_operand" "")
-   (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (HImode, operands[1]);
-})
-
-(define_insn "*zero_extendhisi2_bwx"
+(define_insn "zero_extendhisi2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
-   (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_BWX"
+   (zero_extend:SI
+ (match_operand:HI 1 "reg_or_bwx_memory_operand" "r,m")))]
+  ""
   "@
zapnot %1,3,%0
ldwu %0,%1"
-  [(set_attr "type" "shift,ild")])
-
-(define_insn "*zero_extendhisi2_nobwx"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-   (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
-  "! TARGET_BWX"
-  "zapnot %1,3,%0"
-  [(set_attr "type" "shift")])
-
-(define_expand "zero_extendhidi2"
-  [(set (match_operand:DI 0 "register_operand" "")
-   (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "")))]
-  ""
-{
-  if (! TARGET_BWX)
-operands[1] = force_reg (HImode, operands[1]);
-})
+  [(set_attr "type" "shift,ild")
+   (s

Re: [4.7] Avoid global state in sparc_handle_option

2011-03-24 Thread Joseph S. Myers
On Thu, 17 Mar 2011, Eric Botcazou wrote:

> > 2011-03-13  Joseph Myers  
> >
> > * config/sparc/sparc-opts.h: New.
> 
> Do you really need all the dates in there?

They were the dates on sparc.h from which this file was split out.  This 
version uses only the dates of the revisions shown by "svn blame" on the 
enumeration in sparc.h.

> The sparc_cpu/sparc_cpu_option naming is confusing.  What about replacing the 
> latter with sparc_cpu_and_features or something along these lines?

This version includes that renaming - how does it look to you.  Tested 
building cc1 and xgcc for cross to sparc-elf.

2011-03-24  Joseph Myers  

* config/sparc/sparc-opts.h: New.
* config/sparc/sparc.c (sparc_handle_option, sparc_select,
sparc_cpu, fpu_option_set, TARGET_HANDLE_OPTION): Remove.
(sparc_option_override): Store processor_type enumeration rather
than string in cpu_default.  Remove name and enumeration from
cpu_table.  Directly default -mcpu then default -mtune from -mcpu
without using sparc_select.  Use target_flags_explicit instead of
fpu_option_set.
* config/sparc/sparc.h (enum processor_type): Move to
sparc-opts.h.
(sparc_cpu, struct sparc_cpu_select, sparc_select): Remove.
* config/sparc/sparc.opt (config/sparc/sparc-opts.h): New
HeaderInclude entry.
(mcpu=, mtune=): Use Var and Enum.
(sparc_processor_type): New Enum and EnumValue entries.

Index: gcc/config/sparc/sparc.opt
===
--- gcc/config/sparc/sparc.opt  (revision 171425)
+++ gcc/config/sparc/sparc.opt  (working copy)
@@ -1,6 +1,6 @@
 ; Options for the SPARC port of the compiler
 ;
-; Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -18,6 +18,9 @@
 ; along with GCC; see the file COPYING3.  If not see
 ; .
 
+HeaderInclude
+config/sparc/sparc-opts.h
+
 mfpu
 Target Report Mask(FPU)
 Use hardware FP
@@ -83,13 +86,67 @@ Target
 Optimize tail call instructions in assembler and linker
 
 mcpu=
-Target RejectNegative Joined
+Target RejectNegative Joined Var(sparc_cpu_and_features) 
Enum(sparc_processor_type)
 Use features of and schedule code for given CPU
 
 mtune=
-Target RejectNegative Joined
+Target RejectNegative Joined Var(sparc_cpu) Enum(sparc_processor_type)
 Schedule code for given CPU
 
+Enum
+Name(sparc_processor_type) Type(enum processor_type)
+
+EnumValue
+Enum(sparc_processor_type) String(v7) Value(PROCESSOR_V7)
+
+EnumValue
+Enum(sparc_processor_type) String(cypress) Value(PROCESSOR_CYPRESS)
+
+EnumValue
+Enum(sparc_processor_type) String(v8) Value(PROCESSOR_V8)
+
+EnumValue
+Enum(sparc_processor_type) String(supersparc) Value(PROCESSOR_SUPERSPARC)
+
+EnumValue
+Enum(sparc_processor_type) String(hypersparc) Value(PROCESSOR_HYPERSPARC)
+
+EnumValue
+Enum(sparc_processor_type) String(leon) Value(PROCESSOR_LEON)
+
+EnumValue
+Enum(sparc_processor_type) String(sparclite) Value(PROCESSOR_SPARCLITE)
+
+EnumValue
+Enum(sparc_processor_type) String(f930) Value(PROCESSOR_F930)
+
+EnumValue
+Enum(sparc_processor_type) String(f934) Value(PROCESSOR_F934)
+
+EnumValue
+Enum(sparc_processor_type) String(sparclite86x) Value(PROCESSOR_SPARCLITE86X)
+
+EnumValue
+Enum(sparc_processor_type) String(sparclet) Value(PROCESSOR_SPARCLET)
+
+EnumValue
+Enum(sparc_processor_type) String(tsc701) Value(PROCESSOR_TSC701)
+
+EnumValue
+Enum(sparc_processor_type) String(v9) Value(PROCESSOR_V9)
+
+EnumValue
+Enum(sparc_processor_type) String(ultrasparc) Value(PROCESSOR_ULTRASPARC)
+
+EnumValue
+Enum(sparc_processor_type) String(ultrasparc3) Value(PROCESSOR_ULTRASPARC3)
+
+EnumValue
+Enum(sparc_processor_type) String(niagara) Value(PROCESSOR_NIAGARA)
+
+EnumValue
+Enum(sparc_processor_type) String(niagara2) Value(PROCESSOR_NIAGARA2)
+
 mcmodel=
 Target RejectNegative Joined Var(sparc_cmodel_string)
 Use given SPARC-V9 code model
Index: gcc/config/sparc/sparc-opts.h
===
--- gcc/config/sparc/sparc-opts.h   (revision 0)
+++ gcc/config/sparc/sparc-opts.h   (revision 0)
@@ -0,0 +1,47 @@
+/* Definitions for option handling for SPARC.
+   Copyright (C) 1996, 1999, 2002, 2006, 2007, 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

Re: [cxx-mem-model] disallow load data races (1 of some)

2011-03-24 Thread Andrew MacLeod

On Thu, 24 Mar 2011, Aldy Hernandez wrote:


This work is independent of the C++ memory model.  It is just to prevent the
optimizers from introducing new data races due to code movement. This initial
pass is just to make the optimizations data race safe so that if you have a
program which is proven to be free of data races, you can run the optimizers
and it will still be data race free after the optimizers have been run.

See the following summary by Andrew (which in turn is based on a paper by Hans
Boehm):

http://gcc.gnu.org/wiki/Atomic/GCCMM/DataRaces

But hoisting global in this case doesn't result in a data race, since the
loop always accesses global and contains no synchronisation code.  If it
were only accessed conditionally, as in the examples under "Avoiding
Speculation" on that page, then there would be a race in hoisting it, but
not for the code you gave; any data races with the hoisting would still
have been present without it.

My fault for not being specific about it... I tend to just use data race 
as a catch all for all these types of things when talking about them 
with Aldy.


the testcase should have  for (x=0; x< limit; x++)  sum[x] = global; 
rather than x<5,  so that its not a known loop count.


The hoisted load is then not allowed as it become a speculative load of 
'global' on the main path which would not otherwise have been there. 
When the value of limit < 0, this can cause a load race detection on 
systems with either a software or hardware data race detector.


It can be allowed as long as the load happens inside a guard for the 
loop, but I dont think we are that sophisticated yet.


Bottom line is these flags are to prevent the introduction of loads of 
globals on code paths which didn't have had them before.


Andrew




libgo patch committed: Update to current version of Go library

2011-03-24 Thread Ian Lance Taylor
I've committed a patch to libgo to update to the current version of the
master Go library.  The patch is too large to include here, and is in
any case simply a copy of changes available in the master Go library
repository.  See SVN or http://codereview.appspot.com/4281068/ for the
changes as applied to libgo.

Ian


Re: [debug] dwarf2out emits unnecessary null byte in empty .debug_abbrev section

2011-03-24 Thread Richard Henderson
On 03/24/2011 01:54 PM, Mark Wielaard wrote:
> +  if (abbrev_die_table_in_use == 1)
> +return;
> +
>for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
>  {
>dw_die_ref abbrev = abbrev_die_table[abbrev_id];
> 
> Still OK?

Yes.


r~


Re: [toplevel] cleanup mh-cygwin

2011-03-24 Thread Dave Korn
On 24/03/2011 17:11, Paolo Bonzini wrote:
> The cygwin host fragment is using obsolete variables and constructs,
> modernize it.
> 
> Committed to gcc and (shortly) src.

  Thanks, top-level stuff is a bit of a mystery to me :)

cheers,
  DaveK



Re: [google] Port lock annotations/analysis to google/main branch (issue4275075)

2011-03-24 Thread lcwu

Could you also update http://gcc.gnu.org/wiki/ThreadSafetyAnnotation?
It still points to the old branch and seems to have stale content.


Will do.



Any plans for mainline merge?


I don't actually have a time frame for that, but that is the ultimate
goal.



http://codereview.appspot.com/4275075/diff/2001/gcc/common.opt
File gcc/common.opt (right):

http://codereview.appspot.com/4275075/diff/2001/gcc/common.opt#newcode682
gcc/common.opt:682: Make the thread safety analysis try to bind the
function parameters used in the attributes
On 2011/03/24 21:42:18, Diego Novillo wrote:

Hmm, you've added these warnings twice now.  I had added the flags to

fix our

builds.  The warnings I added are just above these.  If there's

anything new,

you can just overwrite it.


Ah, I didn't notice that, and the build went OK. Duplicate entries were
removed.

http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c
File gcc/cp/parser.c (left):

http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#oldcode5766
gcc/cp/parser.c:5766: is_attribute_list = non_attr;
On 2011/03/24 21:42:18, Diego Novillo wrote:

Why are you taking this out?


Without doing, the parser would start evaluating/binding the identifier
nodes after processing the first argument, which would limit our ability
to allow users to use names not in scope. The detailed explanation is in
the comments above (line 5778 to 5801 in the patched file).

http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#oldcode5802
gcc/cp/parser.c:5802: VEC_safe_insert (tree, gc, expression_list, 0,
identifier);
On 2011/03/24 21:42:18, Diego Novillo wrote:

Likewise.


In the original implementation, the first identifier argument was not
pushed into the expression_list vector, so we had to do that here. With
my patch, the first argument is pushed to the vector in line 5802 (in
patched file).

http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c
File gcc/cp/parser.c (right):

http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#newcode1742
gcc/cp/parser.c:1742: tree current_declarator_scope;
On 2011/03/24 21:42:18, Diego Novillo wrote:

You're going to find some amusing merge conflicts the next time

google/main

merges from trunk ;)  All this has been factored out of cp/parser.c


Thanks for the heads-up. We will deal with them then. :-)

http://codereview.appspot.com/4275075/diff/2001/gcc/tree.h
File gcc/tree.h (right):

http://codereview.appspot.com/4275075/diff/2001/gcc/tree.h#newcode5366
gcc/tree.h:5366: /* Extract and return all lock attributes from the
given attribute list.  */
On 2011/03/24 21:42:18, Diego Novillo wrote:

Blank line above comment.


Done.

http://codereview.appspot.com/4275075/


Re: More fixes from static analysis checkers

2011-03-24 Thread Diego Novillo
On Thu, Mar 24, 2011 at 17:52, Jeff Law  wrote:

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

OK.


Diego.


More fixes from static analysis checkers

2011-03-24 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


We had a variety of functions which would fail to call va_end prior to
returning.  I'm not aware of a host were this could cause a problem, but
it's easy enough to fix and keeps the checkers quiet.

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


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNi705AAoJEBRtltQi2kC7i7wIALDzCORDo9tes44r+2TwMiPZ
u3i6nY3Xe6q2wq9pZB9xlsw7kMPlul+0iaC2vcTMNIDmb/xhYvAZmhi2QYOWtvBb
QV3MB1ZLaWIEKDR9r6H0lu5MnRCEt5XGDRheyQPsMoZncmBMiO/IPxs++/P5eH3l
KMue8z2aC2++mYiPkyLb3rUVMTVlwjFXVI58M1BeaxTPYNpqyuIyYK4WZ/+X18fV
yZqn6ogCXiJRCgv8NZ4Nk98wgtLH42aYNnc7zVRA9wKOPorXxB6yMkLV60mWCUtp
4u3Fkw3Ri2TQ3y+fzbjD0N7j6f21bE2KVYqsmxS/bHO9YyskLUKxIVOSiAxE8Tg=
=Jc83
-END PGP SIGNATURE-
* dwarf2asm.c (dw2_asm_output_encoded_addr_rtx): Add missing
va_end.
* c-family/c-common.c (def_fn_type): Likewise.
* ada/gcc-interface/utils.c (def_fn_type): Likewise.
* emit-rtl.c (gen_rtvec): Likewise.
* lto/lto-lang.c (def_fn_type): Likewise.

Index: dwarf2asm.c
===
*** dwarf2asm.c (revision 171351)
--- dwarf2asm.c (working copy)
*** dw2_asm_output_encoded_addr_rtx (int enc
*** 957,962 
--- 957,963 
  {
assemble_align (POINTER_SIZE);
assemble_integer (addr, size, POINTER_SIZE, 1);
+   va_end (ap);
return;
  }
  
Index: c-family/c-common.c
===
*** c-family/c-common.c (revision 171351)
--- c-family/c-common.c (working copy)
*** def_fn_type (builtin_type def, builtin_t
*** 4428,4433 
--- 4428,4434 
  
   egress:
builtin_types[def] = t;
+   va_end (list);
  }
  
  /* Build builtin functions common to both C and C++ language
Index: ada/gcc-interface/utils.c
===
*** ada/gcc-interface/utils.c   (revision 171351)
--- ada/gcc-interface/utils.c   (working copy)
*** def_fn_type (builtin_type def, builtin_t
*** 4930,4935 
--- 4930,4936 
  
   egress:
builtin_types[def] = t;
+   va_end (list);
  }
  
  /* Build the builtin function types and install them in the builtin_types
Index: emit-rtl.c
===
*** emit-rtl.c  (revision 171351)
--- emit-rtl.c  (working copy)
*** gen_rtvec (int n, ...)
*** 805,811 
  
/* Don't allocate an empty rtvec...  */
if (n == 0)
! return NULL_RTVEC;
  
rt_val = rtvec_alloc (n);
  
--- 805,814 
  
/* Don't allocate an empty rtvec...  */
if (n == 0)
! {
!   va_end (p);
!   return NULL_RTVEC;
! }
  
rt_val = rtvec_alloc (n);
  
Index: lto/lto-lang.c
===
*** lto/lto-lang.c  (revision 171351)
--- lto/lto-lang.c  (working copy)
*** def_fn_type (builtin_type def, builtin_t
*** 471,476 
--- 471,477 
  
   egress:
builtin_types[def] = t;
+   va_end (list);
  }
  
  /* Used to help initialize the builtin-types.def table.  When a type of


Re: [cxx-mem-model] disallow load data races (1 of some)

2011-03-24 Thread Joseph S. Myers
On Thu, 24 Mar 2011, Aldy Hernandez wrote:

> This work is independent of the C++ memory model.  It is just to prevent the
> optimizers from introducing new data races due to code movement. This initial
> pass is just to make the optimizations data race safe so that if you have a
> program which is proven to be free of data races, you can run the optimizers
> and it will still be data race free after the optimizers have been run.
> 
> See the following summary by Andrew (which in turn is based on a paper by Hans
> Boehm):
> 
> http://gcc.gnu.org/wiki/Atomic/GCCMM/DataRaces

But hoisting global in this case doesn't result in a data race, since the 
loop always accesses global and contains no synchronisation code.  If it 
were only accessed conditionally, as in the examples under "Avoiding 
Speculation" on that page, then there would be a race in hoisting it, but 
not for the code you gave; any data races with the hoisting would still 
have been present without it.

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


Re: [google] Port lock annotations/analysis to google/main branch (issue4275075)

2011-03-24 Thread Diego Novillo
On Thu, Mar 24, 2011 at 15:30, Le-Chun Wu  wrote:

> 2011-03-24  Le-Chun Wu  
>
>        * Makefile.in: Add new source file and headers in dependencies.
>        * attribs.c (decl_attributes): Handle lock attributes.
>        (is_lock_attribute_with_args): New function.
>        (is_lock_attribute_p): Likewise.
>        (extract_lock_attributes): Likewise.
>        (merge_lock_attr_args): Likewise.
>        * c-decl.c (undeclared_variable): Suppress errors for lock attributes.
>        * c-parser.c (c_parser_declaration_or_fndef): Allow lock attributes on
>        function definitions. Add support for suppressing errors for lock
>        attributes.
>        (c_parser_attributes): Replace the original code that handles the
>        argument list with a call to c_parser_attr_arg_list.
>        (c_parser_attr_arg_list): New function.
>        * common.opt: Add new flags for lock annotations and analysis.
>        * doc/invoke.texi: Add documentation for new flags for lock annotations
>        and analysis.
>        * gimplify.c (lookup_tmp_var): Copy thread safety attributes to tmp
>        variable and save the original variable name.
>        * langhooks-def.h: Define new language hooks.
>        * langhooks.c (lhd_do_nothing_t_return_int): New function.
>        (lhd_do_nothing_t_return_bool): Likewise.
>        (lhd_do_nothing_t_t_return_null_tree): Likewise.
>        * langhooks.h: Add new hook functions in the lang_hooks struct.
>        * passes.c (init_optimization_passes): Add a new pass.
>        * pointer-set.c (pointer_set_copy): New function.
>        (pointer_set_delete): Likewise.
>        (pointer_set_intersection_complement): Likewise.
>        (pointer_set_union_inplace): Likewise.
>        (pointer_set_cardinality): Likewise.
>        * pointer-set.h: Add declarations of new functions.
>        * timevar.def: Add a new time var for thread safety analysis pass.
>        * toplev.c (compile_file): Clean up the global data structures
>        used by the thread safety analysis.
>        * tree-pass.h: Add a new pass declaration.
>        * tree-threadsafe-analyze.c: New file.
>        * tree-threadsafe-analyze.h: New file.
>        * tree.h: Declaration for new functions.
>
> c-family/
>        * c-common.c (c_common_attribute_table): Add new functions to process
>        lock attributes.
>        (attribute_takes_identifier_p): Handle lock attributes.
>        (handle_lockable_attribute): New Handler.
>        (handle_guarded_by_attribute): Likewise.
>        (handle_point_to_guarded_by_attribute): Likewise.
>        (handle_guarded_attribute): Likewise.
>        (handle_point_to_guarded_attribute): Likewise.
>        (handle_acquired_order_attribute): Likewise.
>        (handle_lock_attribute): Likewise.
>        (handle_unlock_attribute): Likewise.
>        (handle_locks_required_excluded_attribute): Likewise.
>        (handle_lock_returned_attribute): Likewise.
>        (handle_no_thread_safety_analysis_attribute): Likewise.
>        (supported_lock_expression): New helper function.
>        (get_lock_decl): Likewise.
>        (populate_acquired_after_map): Likewise.
>        (is_lock_formal_parameter): Likewise.
>        (check_lock_unlock_attr_args): Likewise.
>        * c-cppbuiltin.c (c_cpp_builtins): Define annotalysis-related macros.
>        * c-pretty-print.c (pp_c_expression): Handle SSA_NAME.
>
> cp/
>        * Make-lang.in: Add new includes.
>        * call.c (build_new_op): Support for non-const non-modifying methods.
>        (find_const_memfunc_with_identical_prototype): New function.
>        (build_new_method_call): Suppress errors for calls in lock attributes.
>        Support for non-const non-modifying methods.
>        * class.c (cp_get_virtual_function_decl): New function.
>        (cp_fold_obj_type_ref): Refactored to call 
> cp_get_virtual_function_decl.
>        (cp_decl_is_base_field): New function.
>        (cp_decl_is_constructor): Likewise.
>        (cp_decl_is_destructor): Likewise.
>        (cp_decl_is_const_member_func): Likewise.
>        * cp-lang.c: New language hooks.
>        * cp-tree.h: New function declarations.
>        * decl2.c (is_late_template_attribute): Handle delay parsing of lock
>        attribute arguments.
>        * error.c (dump_expr): Handle SSA_NAME.
>        * lex.c (unqualified_name_lookup_error): Suppress errors for lock
>        attributes.
>        * name-lookup.c (lookup_name_in_func_params): New function.
>        * name-lookup.h: New function declaration.
>        * parser.c (cp_parser): New fields.
>        (cp_parser_name_lookup_error): Suppress errors for lock attributes.
>        (cp_parser_new): Initialize unparsed_attribute_args_queue.
>        (cp_parser_postfix_expression): Add function parameter lookup support.
>        (cp_parser_parenthesized_expression_list): Fix a problem in parsing
>        identifier arguments and skip folding for decl arguments.
>        (cp_parser_lambda_declarator_opt): Add a new argument to

Re: [cxx-mem-model] disallow load data races (1 of some)

2011-03-24 Thread Aldy Hernandez

On 03/24/11 14:58, Richard Henderson wrote:

On 03/24/2011 10:33 AM, Aldy Hernandez wrote:

In the example below we usually hoist "global" into a register or
temporary to avoid reading from it at each step. This would cause a
race if another thread had modified "global" in between iterations.

 for (x=0; x<  5; x++)
 sum[x] =  global;


Um, what?  Doesn't the c++ memory model have, like, sequence points
or somesuch verbage that includes some language like an "atomic"?

Your argument above, in absence of some serializing entity, does not
sound right at all.


This work is independent of the C++ memory model.  It is just to prevent 
the optimizers from introducing new data races due to code movement. 
This initial pass is just to make the optimizations data race safe so 
that if you have a program which is proven to be free of data races, you 
can run the optimizers and it will still be data race free after the 
optimizers have been run.


See the following summary by Andrew (which in turn is based on a paper 
by Hans Boehm):


http://gcc.gnu.org/wiki/Atomic/GCCMM/DataRaces

The code movement is disallowed under specific --param options and will 
later be used for the C++ memory model, though the kernel folk have been 
asking for something similar, so it's not C++ specific.


Does this make sense now?  Or were Andrew and I smoking some heavy duty 
stuff when reading the specs... and not sharing with you?


Aldy


Re: [debug] dwarf2out emits unnecessary null byte in empty .debug_abbrev section

2011-03-24 Thread Mark Wielaard
> >/* Terminate the table. */
> > - dw2_asm_output_data (1, 0, NULL);
> > + if (abbrev_die_table_in_use > 1)
> > + dw2_asm_output_data (1, 0, NULL);
> 
> I'd prefer this to be handled by
> 
> if (abbrev_die_table_in_use == 0)
> return;
> 
> at the beginning of the function.
> 
> Ok with that change.

I assume you meant the following, since abbrev_die_table_in_use is
initialized to one in dwarf2out_init (). Zero-th entry is not written
to the table (as can be seen from the diff context now).

--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11056,6 +11056,9 @@ output_abbrev_section (void)
 {
   unsigned long abbrev_id;
 
+  if (abbrev_die_table_in_use == 1)
+return;
+
   for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id)
 {
   dw_die_ref abbrev = abbrev_die_table[abbrev_id];

Still OK?

Thanks,

Mark


Re: [RFC PATCH, i386]: ICE: in final_scan_insn due to late split

2011-03-24 Thread Uros Bizjak
On Thu, Mar 24, 2011 at 8:59 PM, Rainer Orth
 wrote:
> Uros Bizjak  writes:
>
>> 2011-03-23  Uros Bizjak  
>>
>>       PR target/48237
>>       * config/i386/i386.md (*movdf_internal_rex64): Do not split
>>       alternatives that can be handled with movq or movabsq insn.
>>       (*movdf_internal): Disable for !TARGET_64BIT.
>>       (*movdf_internal_nointeger): Ditto.
>>       * config/i386/i386.c (ix86_print_operand): Handle DFmode immediates.
>
> This patch broke Solaris/x86 bootstrap:
>
> /vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c: In function 
> 'ix86_print_operand':
> /vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c:14416:2: error: format 
> '%lld' expects argument of type 'long long int', but argument 3 has type 
> 'long int' [-Werror=format]

Fixed by attached patch that removes all fancy conditional handling.

2011-03-24  Uros Bizjak  

* config/i386/i386.md (ix86_print_operand): Output DFmode const_double
correctly.

Tested on x86_64-pc-linux-gnu, committed to mainline.

Uros.
>
>        Rainer
>
> --
> -
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 171422)
+++ config/i386/i386.c  (working copy)
@@ -14408,12 +14408,7 @@ ix86_print_operand (FILE *file, rtx x, i
 
   if (ASSEMBLER_DIALECT == ASM_ATT)
putc ('$', file);
-  /* We can use %d if the number is <32 bits and positive.  */
-  if (l[1] || l[0] < 0)
-   fprintf (file, "0x%lx%08lx",
-(unsigned long) l[1], (unsigned long) l[0]);
-  else
-   fprintf (file, HOST_WIDE_INT_PRINT_DEC, l[0]);
+  fprintf (file, "0x%lx%08lx", l[1] & 0x, l[0] & 0x);
 }
 
   /* These float cases don't actually occur as immediate operands.  */


Re: [PATCH] use cfglayout mode for instatiate_virtual_regs

2011-03-24 Thread Richard Henderson
On 03/24/2011 04:47 AM, Nathan Froyd wrote:
>   * function.c (instantiate_virtual_regs): Use FOR_EACH_BB and
>   FOR_BB_INSNS_SAFE to iterate through insns.  Re-indent.
>   * passes.c (init_optimization_passes): Move
>   pass_instantiate_virtual_regs after pass_into_cfg_layout_mode.

Ok.


r~


Re: [patch] Do not generate useless branches for multi-word comparison

2011-03-24 Thread Richard Henderson
On 03/24/2011 07:38 AM, Eric Botcazou wrote:
> +  /* Deal with the special case 0 > x: only one comparison is necessary and
> + we reverse it to avoid jumping to the drop-through label.  */
> +  if (op0 == const0_rtx && drop_through_if_true && !drop_through_if_false)
> +{
> +  code = LE;
> +  if_true_label = if_false_label;
> +  if_false_label = drop_through_label;
> +  drop_through_if_false = true;
> +}

Missing drop_through_if_true = false.

Otherwise ok.


r~


Re: [debug] Remove deprecated DW_FORM_sig8 define

2011-03-24 Thread Richard Henderson
On 03/24/2011 08:30 AM, Mark Wielaard wrote:
> 2010-03-24  Mark Wielaard  
> 
> * dwarf2.h (dwarf_form): Remove deprecated DW_FORM_sig8 define.
> 
> 2011-03-24  Mark Wielaard  
> 
> * dwarf2out.c (size_of_die): Modify comment to say DW_FORM_ref_sig8.
> (value_format): Use DW_FORM_ref_sig8, not DW_FORM_sig8.

Ok.


r~


Re: [PATCH] Fix PR 48144

2011-03-24 Thread Vladimir Makarov

On 03/24/2011 06:50 AM, Andrey Belevantsev wrote:

Hello,

As noted in the PR audit trail, this is a case when we fail to find a 
transformed insn due to incomplete transformation history attached to 
it. The earlier fixes of this issue worked only for bookkeeping 
copies, but now we need a more general mechanism.  Fixed by simply 
picking up additional transformation history from the av sets of basic 
blocks on the way.  The problem can only happen on the bookkeeping 
blocks which have somewhat newer av sets available.


Bootstrapping and testing on x86-64 and ia64 is in progress, ok if it 
succeeds?




Ok, thanks.


2011-03-24  Andrey Belevantsev 

gcc/
PR rtl-optimization/48144
* sel-sched-ir.c (merge_history_vect): Factor out from ...
(merge_expr_data): ... here.
(av_set_intersect): Rename to av_set_code_motion_filter.
Update all callers.  Call merge_history_vect when an expression
is found in both sets.
* sel-sched-ir.h (av_set_code_motion_filter): Add prototype.

gcc/testsuite
PR rtl-optimization/48144
* gcc.dg/pr48144.c: New test.







Re: [debug] dwarf2out emits unnecessary null byte in empty .debug_abbrev section

2011-03-24 Thread Richard Henderson
On 03/24/2011 09:26 AM, Mark Wielaard wrote:
>/* Terminate the table.  */
> -  dw2_asm_output_data (1, 0, NULL);
> +  if (abbrev_die_table_in_use > 1)
> +dw2_asm_output_data (1, 0, NULL);

I'd prefer this to be handled by 

  if (abbrev_die_table_in_use == 0)
return;

at the beginning of the function.

Ok with that change.


r~


More toplevel configure.ac pruning

2011-03-24 Thread Joseph S. Myers
This toplevel configure patch continues pruning useless or incorrect
code, generally specific to particular hosts or targets.

* There are mentions of target-groff, target-librx and tix, but these
  are useless as they are not in Makefile.def, so they can safely be
  removed.

* libmudflap is disabled by default for most targets and so there is
  no need for a couple of individual targets to re-disable it.

* Disabling byacc based on host CPU architecture is clearly wrong.

* The directories built for a given target should not depend on the
  host (if some tools can't be built for a host, that would apply for
  all targets and so should go in the case statement over hosts).  In
  the case of code conditionally adding gprof back in (removing it
  from skipdirs), there was no previous code that could have added it
  to skipdirs in the first place, so the whole sub-case statement was
  dead.

* There doesn't seem to be any use in a commented-out noconfigdirs
  setting alongside a smaller non-commented-out setting.

OK to commit?

2011-03-24  Joseph Myers  

* configure.ac (target_tools): Remove target-groff.
(native_only): Remove target-groff.
(hppa*64*-*-*): Don't disable byacc.
(i[[3456789]]86-*-mingw32*): Remove commented-out noconfigdirs
setting.
(*-*-kaos*): Don't skip target-librx and target-groff.
(*-*-netware*): Don't skip target-libmudflap.
(*-*-tpf*): Don't skip target-libmudflap.
(sh*-*-pe|mips*-*-pe|*arm-wince-pe): Don't condition configured
directories on the host.
(ia64*-*-*vms*): Don't skip tix.
(sh-*-* | sh64-*-*): Don't condition skipped directories on the
host.
* configure: Regenerate.

Index: configure.ac
===
--- configure.ac(revision 171423)
+++ configure.ac(working copy)
@@ -210,7 +210,7 @@
 # list belongs in this list.  those programs are also very likely
 # candidates for the "native_only" list which follows
 #
-target_tools="target-examples target-groff target-gperf target-rda"
+target_tools="target-examples target-gperf target-rda"
 
 

 
@@ -298,7 +298,7 @@
 
 # Some tools are only suitable for building in a "native" situation.
 # Remove these if host!=target.  
-native_only="autoconf automake libtool fileutils find gawk gettext gzip hello 
indent m4 rcs recode sed shellutils tar textutils uudecode wdiff target-groff 
guile perl time ash bash bzip2 prms gnuserv target-gperf"
+native_only="autoconf automake libtool fileutils find gawk gettext gzip hello 
indent m4 rcs recode sed shellutils tar textutils uudecode wdiff guile perl 
time ash bash bzip2 prms gnuserv target-gperf"
 
 # Similarly, some are only suitable for cross toolchains.
 # Remove these if host=target.
@@ -426,9 +426,6 @@
 # exist yet.
 
 case "${host}" in
-  hppa*64*-*-*)
-noconfigdirs="$noconfigdirs byacc"
-;;
   i[[3456789]]86-*-msdosdjgpp*)
 noconfigdirs="$noconfigdirs tcl tk expect dejagnu send-pr uudecode guile 
itcl gnuserv libffi"
 ;;
@@ -436,7 +433,6 @@
 noconfigdirs="$noconfigdirs expect dejagnu autoconf automake send-pr rcs 
guile perl texinfo libtool newlib"
 ;;
   i[[3456789]]86-*-mingw32*)
-# noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc 
send-pr uudecode dejagnu diff guile perl itcl gnuserv"
 noconfigdirs="$noconfigdirs expect dejagnu autoconf automake send-pr rcs 
guile perl texinfo libtool newlib"
 ;;
   *-*-cygwin*)
@@ -583,8 +579,8 @@
 ;;
   *-*-kaos*)
 # Remove unsupported stuff on all kaOS configurations.
-skipdirs="target-libiberty ${libgcj} target-libstdc++-v3 target-librx"
-skipdirs="$skipdirs target-libobjc target-examples target-groff 
target-gperf"
+skipdirs="target-libiberty ${libgcj} target-libstdc++-v3"
+skipdirs="$skipdirs target-libobjc target-examples target-gperf"
 skipdirs="$skipdirs zlib fastjar target-libjava target-boehm-gc 
target-zlib"
 noconfigdirs="$noconfigdirs target-libgloss"
 ;;
@@ -602,7 +598,7 @@
 esac
 ;;
   *-*-netware*)
-noconfigdirs="$noconfigdirs target-newlib target-libiberty target-libgloss 
${libgcj} target-libmudflap"
+noconfigdirs="$noconfigdirs target-newlib target-libiberty target-libgloss 
${libgcj}"
 ;;
   *-*-rtems*)
 skipdirs="${skipdirs} target-libiberty"
@@ -610,7 +606,7 @@
 ;;
 # The tpf target doesn't support gdb yet.
   *-*-tpf*)
-noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libiberty 
${libgcj} target-libmudflap gdb tcl tk libgui itcl"
+noconfigdirs="$noconfigdirs target-newlib target-libgloss target-libiberty 
${libgcj} gdb tcl tk libgui itcl"
 ;;
   *-*-uclinux*)
 noconfigdirs="$noconfigdirs target-newlib target-libgloss target-rda 
${libgcj}"
@@ -650,11 +646,6 @@
 # the C++ libraries don't build on top of CE's C li

Re: [RFC PATCH, i386]: ICE: in final_scan_insn due to late split

2011-03-24 Thread Rainer Orth
Uros Bizjak  writes:

> 2011-03-23  Uros Bizjak  
>
>   PR target/48237
>   * config/i386/i386.md (*movdf_internal_rex64): Do not split
>   alternatives that can be handled with movq or movabsq insn.
>   (*movdf_internal): Disable for !TARGET_64BIT.
>   (*movdf_internal_nointeger): Ditto.
>   * config/i386/i386.c (ix86_print_operand): Handle DFmode immediates.

This patch broke Solaris/x86 bootstrap:

/vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c: In function 
'ix86_print_operand':
/vol/gcc/src/hg/trunk/local/gcc/config/i386/i386.c:14416:2: error: format 
'%lld' expects argument of type 'long long int', but argument 3 has type 'long 
int' [-Werror=format]

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [cxx-mem-model] disallow load data races (1 of some)

2011-03-24 Thread Richard Henderson
On 03/24/2011 10:33 AM, Aldy Hernandez wrote:
> In the example below we usually hoist "global" into a register or
> temporary to avoid reading from it at each step. This would cause a
> race if another thread had modified "global" in between iterations.
> 
> for (x=0; x< 5; x++)
> sum[x] =  global;

Um, what?  Doesn't the c++ memory model have, like, sequence points
or somesuch verbage that includes some language like an "atomic"?

Your argument above, in absence of some serializing entity, does not
sound right at all.


r~


Re: Remove old host cases from toplevel configure

2011-03-24 Thread Joseph S. Myers
On Thu, 24 Mar 2011, Joseph S. Myers wrote:

> Furthermore, the whole idea of the toplevel configure tentative_cc
> setting code is dubious since this is an autoconf-generated script and
> it's autoconf's job to deal with finding a working compiler, putting
> it in ANSI C mode, etc. - so if someone did wish to resupport one of

Related to that point, I notice a piece of code starting "we might need to 
use some other shell than /bin/sh for running subshells" that tries to 
determine a shell on Windows hosts.  It's autoconf's job to find a 
suitable shell, so if this code is still relevant I think there's 
something missing in autoconf.

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


Re: [patch middle-end c c++]: Optimize cost of comp_type_attributes

2011-03-24 Thread Kai Tietz
2011/3/24 Kai Tietz :
> 2011/3/24 Jason Merrill :
>> On 03/24/2011 06:06 PM, Kai Tietz wrote:
>>>
>>> +/* Compare two attributes for identity.  Return true if the attributes
>>> +   are known to be equal; otherwise return false.  */
>>> +
>>> +static bool
>>> +attribute_equal (const_tree attr1, const_tree attr2)
>>> +{
>>> +  if (attr1 == attr2)
>>> +    return true;
>>> +
>>
>> Shouldn't this compare the TREE_VALUEs?
>>
>> This function is also assuming that the TREE_PURPOSEs name the same
>> attribute.  I had figured that we would pull out the TREE_VALUE in the
>> caller, but doing it in here is fine too as long as the function is
>> documented as making that assumption.
>>
>> Jason
>>
>
> I added an note to the documentation of the helper function. Ok by this?
>
> Kai
>

I thought a bit about it and renamed function's name to
attribute_value_equal and adjusted helper functions comment to point
out that just value identity is checked by it.  Previous variant was a
bit weak.

Kai
Index: gcc/gcc/c-typeck.c
===
--- gcc.orig/gcc/c-typeck.c 2011-03-24 08:23:42.441173500 +0100
+++ gcc/gcc/c-typeck.c  2011-03-24 09:24:53.445892300 +0100
@@ -1079,7 +1079,7 @@ comptypes_internal (const_tree type1, co
 return 1;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  if (!(attrval = targetm.comp_type_attributes (t1, t2)))
+  if (!(attrval = comp_type_attributes (t1, t2)))
  return 0;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
Index: gcc/gcc/cp/decl.c
===
--- gcc.orig/gcc/cp/decl.c  2011-03-24 08:23:42.443173500 +0100
+++ gcc/gcc/cp/decl.c   2011-03-24 09:24:53.573408500 +0100
@@ -1012,8 +1012,8 @@ decls_match (tree newdecl, tree olddecl)
types_match =
  compparms (p1, p2)
  && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
- || targetm.comp_type_attributes (TREE_TYPE (newdecl),
-  TREE_TYPE (olddecl)) != 0);
+ || comp_type_attributes (TREE_TYPE (newdecl),
+  TREE_TYPE (olddecl)) != 0);
}
   else
types_match = 0;
Index: gcc/gcc/cp/search.c
===
--- gcc.orig/gcc/cp/search.c2011-03-24 08:23:42.444173500 +0100
+++ gcc/gcc/cp/search.c 2011-03-24 09:24:53.645417600 +0100
@@ -1897,7 +1897,7 @@ check_final_overrider (tree overrider, t
 }
 
   /* Check for conflicting type attributes.  */
-  if (!targetm.comp_type_attributes (over_type, base_type))
+  if (!comp_type_attributes (over_type, base_type))
 {
   error ("conflicting type attributes specified for %q+#D", overrider);
   error ("  overriding %q+#D", basefn);
Index: gcc/gcc/cp/typeck.c
===
--- gcc.orig/gcc/cp/typeck.c2011-03-24 08:23:42.495173500 +0100
+++ gcc/gcc/cp/typeck.c 2011-03-24 09:24:53.697424200 +0100
@@ -1338,7 +1338,7 @@ structural_comptypes (tree t1, tree t2,
   /* If we get here, we know that from a target independent POV the
  types are the same.  Make sure the target attributes are also
  the same.  */
-  return targetm.comp_type_attributes (t1, t2);
+  return comp_type_attributes (t1, t2);
 }
 
 /* Return true if T1 and T2 are related as allowed by STRICT.  STRICT
Index: gcc/gcc/gimple.c
===
--- gcc.orig/gcc/gimple.c   2011-03-24 08:23:42.496173500 +0100
+++ gcc/gcc/gimple.c2011-03-24 09:24:53.793936500 +0100
@@ -3615,7 +3615,7 @@ gimple_types_compatible_p_1 (tree t1, tr
 state, sccstack, sccstate, sccstate_obstack))
goto different_types;
 
-  if (!targetm.comp_type_attributes (t1, t2))
+  if (!comp_type_attributes (t1, t2))
goto different_types;
 
   if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2))
Index: gcc/gcc/tree-ssa.c
===
--- gcc.orig/gcc/tree-ssa.c 2011-03-24 08:23:42.498173500 +0100
+++ gcc/gcc/tree-ssa.c  2011-03-24 09:24:53.831441200 +0100
@@ -1438,7 +1438,7 @@ useless_type_conversion_p (tree outer_ty
 
   /* Defer to the target if necessary.  */
   if (TYPE_ATTRIBUTES (inner_type) || TYPE_ATTRIBUTES (outer_type))
-   return targetm.comp_type_attributes (outer_type, inner_type) != 0;
+   return comp_type_attributes (outer_type, inner_type) != 0;
 
   return true;
 }
Index: gcc/gcc/tree.c
===
--- gcc.orig/gcc/tree.c 2011-03-24 08:23:42.499173500 +0100
+++ gcc/gcc/tree.c  2011-03-24 20:42:37.699096700 +0100
@@ -4283,7 +4283,7 @@ build_type_attribute_qual_variant (tree
 its canonical type, we will need to use structural equalit

Re: mt-mep using EXTRA_TARGET_HOST_ALL_MODULES?

2011-03-24 Thread Joseph S. Myers
On Thu, 24 Mar 2011, Paolo Bonzini wrote:

> > One thing I wonder is if we can
> > kill the toplevel support for building lots of miscellaneous tools that
> > aren't in the gcc or src trees and that aren't libraries used by tools in
> > those trees (such as the support for dropping a GMP source tree into a GCC
> > source tree) either.  There are plenty of packaging systems out there, but
> > I'm not convinced it's any longer useful for this toplevel build/configure
> > code to care about building autoconf, send-pr, rcs or guile, for example.
> 
> Not sure about that.  For sure, people are using in-tree GMP.

My question is really whether people are using *any* of the following 
in-tree (in a way that wouldn't better be served by either some other 
package management system, or by their maintaining a local fork of the GCC 
or src tree): bison byacc flex m4 texinfo ash autoconf automake bash bzip2 
dejagnu diff dosutils fastjar fileutils findutils find gawk gettext libelf 
gnuserv gzip hello indent libiconv libtool make mmalloc patch perl prms 
rcs release recode sed send-pr shellutils tar textutils time uudecode 
wdiff zip expect guile target-gperf target-examples target-qthreads.  
Rules for GMP are directly useful to people building FSF GCC in a way that 
rules for those components aren't.  I would note for a start that several 
of the names above are names for long-obsolete GNU packages (merged into 
coreutils or sharutils, for example), and that mmalloc was probably there 
because of formerly having been used by GDB a long time ago.

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


Re: [PATCH, 4.7] Have all inlining destinations "analyzed"

2011-03-24 Thread Martin Jambor
Ping.

Thanks,

Martin

--
On Sat, Mar 19, 2011 at 01:48:36AM +0100, Martin Jambor wrote:

Hi,

On Fri, Mar 11, 2011 at 03:30:53PM +0100, Jan Hubicka wrote:
> > Index: src/gcc/cgraph.c
> > ===
> > --- src.orig/gcc/cgraph.c
> > +++ src/gcc/cgraph.c
> > @@ -2495,11 +2495,11 @@ cgraph_add_new_function (tree fndecl, bo
> >case CGRAPH_STATE_FINISHED:
> > /* At the very end of compilation we have to do all the work up
> >to expansion.  */
> > +   node = cgraph_node (fndecl);
> > +   cgraph_analyze_function (node);
> > push_cfun (DECL_STRUCT_FUNCTION (fndecl));
> > current_function_decl = fndecl;
> > gimple_register_cfg_hooks ();
> > -   if (!lowered)
> > -  tree_lowering_passes (fndecl);
> 
> The analysis shoud happent in cgraph_process_new_functions that
> should be called after every IPA pass.

I'm not sure I understand.  Since cgraph_state is in
CGRAPH_STATE_FINISHED, new functions are not added to cgraph_new_nodes
linked list to be picked up by cgraph_process_new_functions.  If you
are wondering why cgraph_state has that value because mudflap passes
are early passes and so that should not happen if the function was
invoked from them, the explanation is simple, it is not invoked from
them.  Instead this is some part of mudflap finalization invoked
directly from toplev.c:

#0  fancy_abort (file=0xe07230 "/home/mjambor/icln/src/gcc/tree-inline.c", 
line=4206,
function=0xe08860 "optimize_inline_calls") at 
/home/mjambor/icln/src/gcc/diagnosti
c.c:892 
  
#1  0x00a4ce05 in optimize_inline_calls (fn=0x75237f00) 
  
at /home/mjambor/icln/src/gcc/tree-inline.c:4206

#2  0x00a1d802 in cgraph_early_inlining ()  
  
at /home/mjambor/icln/src/gcc/ipa-inline.c:1757 

#3  0x00756ccf in execute_one_pass (pass=0x1255a00) 
  
at /home/mjambor/icln/src/gcc/passes.c:1556 

#4  0x00756fc5 in execute_pass_list (pass=0x1255a00)
at /home/mjambor/icln/src/gcc/passes.c:1611
#5  0x00a08518 in cgraph_add_new_function (fndecl=0x75237f00, 
lowered=0 '\000')
at /home/mjambor/icln/src/gcc/cgraph.c:2505
#6  0x00a342bf in cgraph_build_static_cdtor_1 (which=73 'I', 
body=0x753e0820,
priority=, final=0 '\000') at 
/home/mjambor/icln/src/gcc/ipa.c:1593
#7  0x004e2683 in mudflap_finish_file ()
at /home/mjambor/icln/src/gcc/tree-mudflap.c:1366
#8  0x007fe3f9 in compile_file (argc=34, argv=0x7fffddf8)
at /home/mjambor/icln/src/gcc/toplev.c:601
#9  do_compile (argc=34, argv=0x7fffddf8) at 
/home/mjambor/icln/src/gcc/toplev.c:1900
#10 toplev_main (argc=34, argv=0x7fffddf8) at 
/home/mjambor/icln/src/gcc/toplev.c:1963

> I don't think we should move
> analysis here nor we should drop the !lowered path (even if it is
> unused currently, cgraph_add_new_function is supposed to work on
> unlowered functions).

I'm not really dropping that path.  cgraph_analyze_function calls
cgraph_lower_function which calls tree_lowering_passes.  It even calls
lower_nested_functions and, perhaps more importantly, sets
node->lowered to true.  But I see that lowered is actually a function
parameter that we should honor so I adjusted my patch slightly to do
that.

Is the explanation above enough to persuade you that the adjusted
patch below is correct?  (Or is there something else I still miss?)

I'm about to re-bootstrap it, just to make sure it still passes.

Thanks,

Martin


2011-03-18  Martin Jambor  

* tree-inline.c (expand_call_inline): Do not check that destination
node is analyzed.
(optimize_inline_calls): Assert that destination node is analyzed.
* cgraph.c (cgraph_add_new_function): Call cgraph_analyze_function, do
not call tree_lowering_passes.
* cgraph.h (cgraph_analyze_function): Declare.
* cgraphunit.c (cgraph_analyze_function): Make public.

Index: src/gcc/tree-inline.c
===
--- src.orig/gcc/tree-inline.c  2011-03-19 01:17:10.0 +0100
+++ src/gcc/tree-inline.c   2011-03-19 01:31:22.0 +0100
@@ -3766,11 +3766,6 @@ expand_call_inline (basic_block bb, gimp
   if (gimple_code (stmt) != GIMPLE_CALL)
 goto egress;
 
-  /* Objective C and fortran still calls tree_rest_of_compilation directly.
- Kill this check once this is fixed.  */
-  if (!id->dst_node->analyzed)
-goto egress;
-
   cg_edge = cgraph_edge (id->dst_node, stmt);
   gcc_checking_assert (cg_edge);
   /* First, see if we can figure out what function is being called.
@@ -4203,6 +4198,7 @@ optimize_inline_calls (tree fn)
 

Re: mt-mep using EXTRA_TARGET_HOST_ALL_MODULES?

2011-03-24 Thread Paolo Bonzini

On 03/24/2011 06:43 PM, Joseph S. Myers wrote:

On Thu, 24 Mar 2011, Paolo Bonzini wrote:


Is this actually desired?  And what's all-utils?  Can we just kill mt-mep?


utils at least exists in the src tree.


Indeed I didn't know about it. :)  However it's not necessary to add it 
specially nowadays.  It configures its own subdirectories manually, and 
all-utils is always invoked if you execute from the src tree or a 
combined tree.


So mt-mep can go.


One thing I wonder is if we can
kill the toplevel support for building lots of miscellaneous tools that
aren't in the gcc or src trees and that aren't libraries used by tools in
those trees (such as the support for dropping a GMP source tree into a GCC
source tree) either.  There are plenty of packaging systems out there, but
I'm not convinced it's any longer useful for this toplevel build/configure
code to care about building autoconf, send-pr, rcs or guile, for example.


Not sure about that.  For sure, people are using in-tree GMP.

What should go, is the code in the toplevel configure to pick default 
paths for gmp, cloog, ppl and whatnot.  The logic should reside in the 
GCC subdirectory only.


Paolo


Re: [libgo] Support Solaris 8/9

2011-03-24 Thread Rainer Orth
Ian Lance Taylor  writes:

> Just a quick note that I committed patches yesterday which should fix at
> least some of those problems.  I failed to commit some of the test data
> the last time I updated the library.

Fine, I'll give it another try tonight or over the weekend.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [libgo] Support Solaris 8/9

2011-03-24 Thread Ian Lance Taylor
Rainer Orth  writes:

> FAIL: image/png
> Can't open -n
> grep: can't open -n
> grep: can't open -n
> --- FAIL: png.TestReader (1.0 seconds)
>   basn0g01-30 open testdata/pngsuite/basn0g01-30.png: No such file or 
> directory
>   basn0g02-29 open testdata/pngsuite/basn0g02-29.png: No such file or 
> directory
>   basn0g04-31 open testdata/pngsuite/basn0g04-31.png: No such file or 
> directory
> --- FAIL: png.TestWriter (0.2 seconds)
>   basn0g01-30 open testdata/pngsuite/basn0g01-30.png: No such file or 
> directory
>   basn0g02-29 open testdata/pngsuite/basn0g02-29.png: No such file or 
> directory
>   basn0g04-31 open testdata/pngsuite/basn0g04-31.png: No such file or 
> directory
> FAIL
> make: *** [image/png/check] Error 1

Just a quick note that I committed patches yesterday which should fix at
least some of those problems.  I failed to commit some of the test data
the last time I updated the library.

Ian


[toplevel] Target fragments cleanups

2011-03-24 Thread Paolo Bonzini
EXTRA_TARGET_HOST_* has been obsolete for years, GDB_NLM_DEPS was 
touched exactly once in 1995, and mt-v810 has no references.


Committed to gcc and src.

Paolo
2011-03-24  Paolo Bonzini  

* configure.ac: Remove references to mt-mep, mt-netware,
mt-wince.
* Makefile.def: Add all-utils soft dependencies.
* Makefile.tpl: Remove GDB_NLM_DEPS.

config:
2011-03-24  Paolo Bonzini  

* mt-mep: Remove, obsolete.
* mt-netware: Remove, obsolete.
* mt-wince: Remove, obsolete.
* mt-v810: Remove, unused.

Index: Makefile.def
===
--- Makefile.def(revision 171417)
+++ Makefile.def(working copy)
@@ -366,6 +366,8 @@ dependencies = { module=all-gnattools; o
 
 dependencies = { module=all-lto-plugin; on=all-libiberty; };
 
+dependencies = { module=all-utils; on=all-libiberty; };
+
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
 dependencies = { module=configure-ppl; on=all-gmp; };
Index: Makefile.tpl
===
--- Makefile.tpl(revision 171416)
+++ Makefile.tpl(working copy)
@@ -103,8 +103,6 @@ TOPLEVEL_CONFIGURE_ARGUMENTS=@TOPLEVEL_C
 tooldir = @tooldir@
 build_tooldir = @build_tooldir@
 
-GDB_NLM_DEPS = 
-
 # This is the name of the environment variable used for the path to
 # the libraries.
 RPATH_ENVVAR = @RPATH_ENVVAR@
Index: configure.ac
===
--- configure.ac(revision 171421)
+++ configure.ac(working copy)
@@ -2233,9 +2233,6 @@ extra_nmflags_for_target=
 extra_ranlibflags_for_target=
 target_makefile_frag=/dev/null
 case "${target}" in
-  mep*-*-*)
-target_makefile_frag="config/mt-mep"
-;;
   spu-*-*)
 target_makefile_frag="config/mt-spu"
 ;;
@@ -2248,9 +2245,6 @@ case "${target}" in
   mips*-*-*linux* | mips*-*-gnu*)
 target_makefile_frag="config/mt-mips-gnu"
 ;;
-  *-*-netware*)
-target_makefile_frag="config/mt-netware"
-;;
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
 target_makefile_frag="config/mt-gnu"
 ;;
@@ -2265,9 +2259,6 @@ case "${target}" in
 # ranlib before Darwin10 requires the -c flag to look at common symbols.
 extra_ranlibflags_for_target=" -c"
 ;;
-  mips*-*-pe | sh*-*-pe | *arm-wince-pe)
-target_makefile_frag="config/mt-wince"
-;;
 esac
 
 alphaieee_frag=/dev/null
Index: config/mt-mep
===
--- config/mt-mep   (revision 171414)
+++ config/mt-mep   (working copy)
@@ -1,8 +0,0 @@
-
-EXTRA_TARGET_HOST_ALL_MODULES:=$(EXTRA_TARGET_HOST_ALL_MODULES) all-utils
-EXTRA_TARGET_HOST_INSTALL_MODULES:=$(EXTRA_TARGET_HOST_INSTALL_MODULES) 
install-utils
-
-all-utils : all-libiberty
-
-install-utils : all-libiberty
-
Index: config/mt-v810
===
--- config/mt-v810  (revision 171414)
+++ config/mt-v810  (working copy)
@@ -1,3 +0,0 @@
-CC_FOR_TARGET = ca732 -ansi
-AS_FOR_TARGET = as732
-AR_FOR_TARGET = ar732
Index: config/mt-netware
===
--- config/mt-netware   (revision 171414)
+++ config/mt-netware   (working copy)
@@ -1 +0,0 @@
-GDB_NLM_DEPS = all-gcc all-ld
Index: config/mt-wince
===
--- config/mt-wince (revision 171414)
+++ config/mt-wince (working copy)
@@ -1,10 +0,0 @@
-# For Windows CE, we need to build the program that converts, copies,
-# and renames the platform SDK files into gcc directories.
-
-EXTRA_TARGET_HOST_ALL_MODULES:=$(EXTRA_TARGET_HOST_ALL_MODULES) all-utils
-EXTRA_TARGET_HOST_INSTALL_MODULES:=$(EXTRA_TARGET_HOST_INSTALL_MODULES) 
install-utils
-
-all-utils : all-libiberty
-
-install-utils : all-libiberty
-


Re: [patch i386 windows]: Introduce call-abi for 32-bit mingw and make callee_pop_aggregate_return attribute by default on for 32-bit mingw target

2011-03-24 Thread Kai Tietz
2011/3/24 Kai Tietz :
> Hi,
>
> this patch introduces for windows 32-bit target also the call-abi
> specifiers (ms_abi/sys_v) and set its default for this target to
> "ms_abi".  This patch set the default of the
> "callee_pop_aggregate_return" attribute to true for MS_ABI call-abi on
> 32-bit.  Additionally it avoids the check of
> "callee_pop_aggregate_return" for any x86_64 target.
> I didn't changed here by intention the default settings of
> cygwin-target. But of course, if wished this change could be done as
> follow-up patch.
>
> ChangeLog gcc/
>
> 2011-03-24  Kai Tietz
>
>        * config/i386/cygming.h (DWARF_FRAME_REGISTERS): Adjust comment.
>        (STACK_BOUNDARY): Check for bit-ness in case of MS_ABI.
>        * config/i386/i386.c (ix86_conditional_register_usage): Adjust
>        comment and use macro TARGET_64BIT_MS_ABI instead.
>        (ix86_keep_aggregate_return_pointer): Optimize for 64-bit case
>        and change default behavior for 32-bit MS_ABI.
>        (ix86_reg_parm_stack_space): Check additionally for bit-ness.
>        (ix86_function_type_abi): Allow check for ms_abi/sysv_abi for
>        32-bit, too.
>        (ix86_cfun_abi): Likewise.
>        (ix86_maybe_switch_abi): Adjust comment.
>        (init_cumulative_args): Check for bit-ness in MS_ABI case.
>        (ix86_gimplify_va_arg): Check just for not TARGET_64BIT_MS_ABI
>        instead of checking for SYSV_ABI.
>        (ix86_nsaved_sseregs): Likewise.
>        (ix86_compute_frame_layout): Set only for 64-bit MS_ABI alignment
>        to 16 bytes.
>        (ix86_expand_call): Use TARGET_64BIT_MS_ABI macro.
>        * config/i386.h (TARGET_32BIT_MS_ABI): New macro.
>        (ACCUMULATE_OUTGOING_ARGS): Check explicit for 64-bit MS_ABI.
>        (OUTGOING_REG_PARM_STACK_SPACE): Likewise.
>        * config/mingw32.h (DEFAULT_ABI): Change default always to MS_ABI.
>
> Tested for x86_64-w64-mingw32, i686-pc-cygwin, and i686-w64-mingw32.
> Ok for apply?
>
> Regards,
> Kai
>

Duh, and here with patch.

Kai
Index: gcc/gcc/config/i386/cygming.h
===
--- gcc.orig/gcc/config/i386/cygming.h  2011-03-24 17:56:00.289173500 +0100
+++ gcc/gcc/config/i386/cygming.h   2011-03-24 18:08:42.894925500 +0100
@@ -84,7 +84,7 @@ along with GCC; see the file COPYING3.
   (TARGET_64BIT ? dbx64_register_map[(n)]  \
: svr4_dbx_register_map[(n)])
 
-/* The MS_ABI changes the set of call-used registers.  */
+/* The 64-bit MS_ABI changes the set of call-used registers.  */
 #undef DWARF_FRAME_REGISTERS
 #define DWARF_FRAME_REGISTERS (TARGET_64BIT ? 33 : 17)
 
@@ -262,7 +262,7 @@ do {\
 #define CHECK_STACK_LIMIT 4000
 
 #undef STACK_BOUNDARY
-#define STACK_BOUNDARY (ix86_abi == MS_ABI ? 128 : BITS_PER_WORD)
+#define STACK_BOUNDARY (TARGET_64BIT && ix86_abi == MS_ABI ? 128 : 
BITS_PER_WORD)
 
 /* By default, target has a 80387, uses IEEE compatible arithmetic,
returns float values in the 387 and needs stack probes.
Index: gcc/gcc/config/i386/i386.c
===
--- gcc.orig/gcc/config/i386/i386.c 2011-03-24 17:56:00.312173500 +0100
+++ gcc/gcc/config/i386/i386.c  2011-03-24 18:08:42.916428200 +0100
@@ -4347,8 +4347,8 @@ ix86_conditional_register_usage (void)
   if (j != INVALID_REGNUM)
 fixed_regs[j] = call_used_regs[j] = 1;
 
-  /* The MS_ABI changes the set of call-used registers.  */
-  if (TARGET_64BIT && ix86_cfun_abi () == MS_ABI)
+  /* The 64-bit MS_ABI changes the set of call-used registers.  */
+  if (TARGET_64BIT_MS_ABI)
 {
   call_used_regs[SI_REG] = 0;
   call_used_regs[DI_REG] = 0;
@@ -5607,11 +5607,18 @@ ix86_keep_aggregate_return_pointer (tree
 {
   tree attr;
 
-  attr = lookup_attribute ("callee_pop_aggregate_return",
-  TYPE_ATTRIBUTES (fntype));
-  if (attr)
-return (TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr))) == 0);
+  if (!TARGET_64BIT)
+{
+  attr = lookup_attribute ("callee_pop_aggregate_return",
+  TYPE_ATTRIBUTES (fntype));
+  if (attr)
+   return (TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr))) == 0);
 
+  /* For 32-bit MS-ABI the default is to keep aggregate
+ return pointer.  */
+  if (ix86_function_type_abi (fntype) == MS_ABI)
+   return true;
+}
   return KEEP_AGGREGATE_RETURN_POINTER != 0;
 }
 
@@ -5748,7 +5755,7 @@ ix86_reg_parm_stack_space (const_tree fn
 call_abi = ix86_function_abi (fndecl);
   else
 call_abi = ix86_function_type_abi (fndecl);
-  if (call_abi == MS_ABI)
+  if (TARGET_64BIT && call_abi == MS_ABI)
 return 32;
   return 0;
 }
@@ -5758,7 +5765,7 @@ ix86_reg_parm_stack_space (const_tree fn
 enum calling_abi
 ix86_function_type_abi (const_tree fntype)
 {
-  if (TARGET_64BIT && fntype != NULL)
+  if (fntype != NULL)
 {
   enum calling_abi abi = ix86_abi;
   if (abi == SYSV

Re: mt-mep using EXTRA_TARGET_HOST_ALL_MODULES?

2011-03-24 Thread Joseph S. Myers
On Thu, 24 Mar 2011, Paolo Bonzini wrote:

> Is this actually desired?  And what's all-utils?  Can we just kill mt-mep?

utils at least exists in the src tree.  One thing I wonder is if we can 
kill the toplevel support for building lots of miscellaneous tools that 
aren't in the gcc or src trees and that aren't libraries used by tools in 
those trees (such as the support for dropping a GMP source tree into a GCC 
source tree) either.  There are plenty of packaging systems out there, but 
I'm not convinced it's any longer useful for this toplevel build/configure 
code to care about building autoconf, send-pr, rcs or guile, for example.

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


Re: [patch middle-end c c++]: Optimize cost of comp_type_attributes

2011-03-24 Thread Kai Tietz
2011/3/24 Jason Merrill :
> On 03/24/2011 06:06 PM, Kai Tietz wrote:
>>
>> +/* Compare two attributes for identity.  Return true if the attributes
>> +   are known to be equal; otherwise return false.  */
>> +
>> +static bool
>> +attribute_equal (const_tree attr1, const_tree attr2)
>> +{
>> +  if (attr1 == attr2)
>> +    return true;
>> +
>
> Shouldn't this compare the TREE_VALUEs?
>
> This function is also assuming that the TREE_PURPOSEs name the same
> attribute.  I had figured that we would pull out the TREE_VALUE in the
> caller, but doing it in here is fine too as long as the function is
> documented as making that assumption.
>
> Jason
>

I added an note to the documentation of the helper function. Ok by this?

Kai
Index: gcc/gcc/c-typeck.c
===
--- gcc.orig/gcc/c-typeck.c 2011-03-24 08:23:42.441173500 +0100
+++ gcc/gcc/c-typeck.c  2011-03-24 09:24:53.445892300 +0100
@@ -1079,7 +1079,7 @@ comptypes_internal (const_tree type1, co
 return 1;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  if (!(attrval = targetm.comp_type_attributes (t1, t2)))
+  if (!(attrval = comp_type_attributes (t1, t2)))
  return 0;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
Index: gcc/gcc/cp/decl.c
===
--- gcc.orig/gcc/cp/decl.c  2011-03-24 08:23:42.443173500 +0100
+++ gcc/gcc/cp/decl.c   2011-03-24 09:24:53.573408500 +0100
@@ -1012,8 +1012,8 @@ decls_match (tree newdecl, tree olddecl)
types_match =
  compparms (p1, p2)
  && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
- || targetm.comp_type_attributes (TREE_TYPE (newdecl),
-  TREE_TYPE (olddecl)) != 0);
+ || comp_type_attributes (TREE_TYPE (newdecl),
+  TREE_TYPE (olddecl)) != 0);
}
   else
types_match = 0;
Index: gcc/gcc/cp/search.c
===
--- gcc.orig/gcc/cp/search.c2011-03-24 08:23:42.444173500 +0100
+++ gcc/gcc/cp/search.c 2011-03-24 09:24:53.645417600 +0100
@@ -1897,7 +1897,7 @@ check_final_overrider (tree overrider, t
 }
 
   /* Check for conflicting type attributes.  */
-  if (!targetm.comp_type_attributes (over_type, base_type))
+  if (!comp_type_attributes (over_type, base_type))
 {
   error ("conflicting type attributes specified for %q+#D", overrider);
   error ("  overriding %q+#D", basefn);
Index: gcc/gcc/cp/typeck.c
===
--- gcc.orig/gcc/cp/typeck.c2011-03-24 08:23:42.495173500 +0100
+++ gcc/gcc/cp/typeck.c 2011-03-24 09:24:53.697424200 +0100
@@ -1338,7 +1338,7 @@ structural_comptypes (tree t1, tree t2,
   /* If we get here, we know that from a target independent POV the
  types are the same.  Make sure the target attributes are also
  the same.  */
-  return targetm.comp_type_attributes (t1, t2);
+  return comp_type_attributes (t1, t2);
 }
 
 /* Return true if T1 and T2 are related as allowed by STRICT.  STRICT
Index: gcc/gcc/gimple.c
===
--- gcc.orig/gcc/gimple.c   2011-03-24 08:23:42.496173500 +0100
+++ gcc/gcc/gimple.c2011-03-24 09:24:53.793936500 +0100
@@ -3615,7 +3615,7 @@ gimple_types_compatible_p_1 (tree t1, tr
 state, sccstack, sccstate, sccstate_obstack))
goto different_types;
 
-  if (!targetm.comp_type_attributes (t1, t2))
+  if (!comp_type_attributes (t1, t2))
goto different_types;
 
   if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2))
Index: gcc/gcc/tree-ssa.c
===
--- gcc.orig/gcc/tree-ssa.c 2011-03-24 08:23:42.498173500 +0100
+++ gcc/gcc/tree-ssa.c  2011-03-24 09:24:53.831441200 +0100
@@ -1438,7 +1438,7 @@ useless_type_conversion_p (tree outer_ty
 
   /* Defer to the target if necessary.  */
   if (TYPE_ATTRIBUTES (inner_type) || TYPE_ATTRIBUTES (outer_type))
-   return targetm.comp_type_attributes (outer_type, inner_type) != 0;
+   return comp_type_attributes (outer_type, inner_type) != 0;
 
   return true;
 }
Index: gcc/gcc/tree.c
===
--- gcc.orig/gcc/tree.c 2011-03-24 08:23:42.499173500 +0100
+++ gcc/gcc/tree.c  2011-03-24 18:39:38.461052400 +0100
@@ -4283,7 +4283,7 @@ build_type_attribute_qual_variant (tree
 its canonical type, we will need to use structural equality
 checks for this type. */
   if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
-  || !targetm.comp_type_attributes (ntype, ttype))
+  || !comp_type_attributes (ntype, ttype))
SET_TYPE_STRUCTURAL_EQUALITY (ntype);
   else if (TYPE_CANO

Re: mt-mep using EXTRA_TARGET_HOST_ALL_MODULES?

2011-03-24 Thread DJ Delorie

There's a top-level utils/ subdir in some trees.  Yes, MeP has a tool
there.



[patch i386 windows]: Introduce call-abi for 32-bit mingw and make callee_pop_aggregate_return attribute by default on for 32-bit mingw target

2011-03-24 Thread Kai Tietz
Hi,

this patch introduces for windows 32-bit target also the call-abi
specifiers (ms_abi/sys_v) and set its default for this target to
"ms_abi".  This patch set the default of the
"callee_pop_aggregate_return" attribute to true for MS_ABI call-abi on
32-bit.  Additionally it avoids the check of
"callee_pop_aggregate_return" for any x86_64 target.
I didn't changed here by intention the default settings of
cygwin-target. But of course, if wished this change could be done as
follow-up patch.

ChangeLog gcc/

2011-03-24  Kai Tietz

* config/i386/cygming.h (DWARF_FRAME_REGISTERS): Adjust comment.
(STACK_BOUNDARY): Check for bit-ness in case of MS_ABI.
* config/i386/i386.c (ix86_conditional_register_usage): Adjust
comment and use macro TARGET_64BIT_MS_ABI instead.
(ix86_keep_aggregate_return_pointer): Optimize for 64-bit case
and change default behavior for 32-bit MS_ABI.
(ix86_reg_parm_stack_space): Check additionally for bit-ness.
(ix86_function_type_abi): Allow check for ms_abi/sysv_abi for
32-bit, too.
(ix86_cfun_abi): Likewise.
(ix86_maybe_switch_abi): Adjust comment.
(init_cumulative_args): Check for bit-ness in MS_ABI case.
(ix86_gimplify_va_arg): Check just for not TARGET_64BIT_MS_ABI
instead of checking for SYSV_ABI.
(ix86_nsaved_sseregs): Likewise.
(ix86_compute_frame_layout): Set only for 64-bit MS_ABI alignment
to 16 bytes.
(ix86_expand_call): Use TARGET_64BIT_MS_ABI macro.
* config/i386.h (TARGET_32BIT_MS_ABI): New macro.
(ACCUMULATE_OUTGOING_ARGS): Check explicit for 64-bit MS_ABI.
(OUTGOING_REG_PARM_STACK_SPACE): Likewise.
* config/mingw32.h (DEFAULT_ABI): Change default always to MS_ABI.

Tested for x86_64-w64-mingw32, i686-pc-cygwin, and i686-w64-mingw32.
Ok for apply?

Regards,
Kai


mt-mep using EXTRA_TARGET_HOST_ALL_MODULES?

2011-03-24 Thread Paolo Bonzini

Is this actually desired?  And what's all-utils?  Can we just kill mt-mep?

Thanks! :)

Paolo


[cxx-mem-model] disallow load data races (1 of some)

2011-03-24 Thread Aldy Hernandez
This is my first stab at disallowing load data races that happen when we 
cache the value of a global.  I would appreciate input before 
committing, especially on the RTL bits, cause it's been quite a while 
since I typed d-e-b-u-g-_-r-t-x. :-)


In the example below we usually hoist "global" into a register or 
temporary to avoid reading from it at each step.  This would cause a 
race if another thread had modified "global" in between iterations.


for (x=0; x< 5; x++)
sum[x] =  global;

As expected, multiple passes can cause the same end result, so plugging 
the problem involves multiple places.  First, loop invariant movement 
moves the invariant.  Barring that, PRE moves the load, and even if we 
get past the SSA passes, rtl-CSE pulls the rug from under us.  If that 
weren't enough, the post-reload pass performs CSE over the hard 
registers, and we end up eliminating subsequent loads of "global".  I am 
sure there are many other places, but I'm starting with whatever it 
takes to fix gcc.dg/memmodel/global-hoist.c.


The patch below fixes the test in question with "--param 
allow-load-data-races=0".  What do y'all think?


Thanks.
* tree.h (DECL_THREAD_VISIBLE_P): New.
* cselib.c (cselib_lookup_mem): Return 0 for globals for
restrictive memory model.
* cse.c (hash_rtx_cb): Same.
* gimple.h (gimple_has_thread_visible_ops): Protoize.
* gimple.c (gimple_has_thread_visible_ops): New.
* tree-ssa-loop-im.c (movement_possibility): Disallow when
avoiding load data races.
* tree-ssa-pre.c (compute_avail): Same, for globals.

Index: tree-ssa-loop-im.c
===
--- tree-ssa-loop-im.c  (revision 170745)
+++ tree-ssa-loop-im.c  (working copy)
@@ -377,6 +377,11 @@ movement_possibility (gimple stmt)
   || stmt_could_throw_p (stmt))
 return MOVE_IMPOSSIBLE;
 
+  /* Do not move loads of globals if under a restrictive memory model.  */
+  if (PARAM_VALUE (PARAM_ALLOW_LOAD_DATA_RACES) == 0
+  && gimple_has_thread_visible_ops (stmt))
+return MOVE_IMPOSSIBLE;
+
   if (is_gimple_call (stmt))
 {
   /* While pure or const call is guaranteed to have no side effects, we
Index: tree.h
===
--- tree.h  (revision 170745)
+++ tree.h  (working copy)
@@ -3102,6 +3102,10 @@ struct GTY(()) tree_parm_decl {
 #define DECL_THREAD_LOCAL_P(NODE) \
   (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model >= TLS_MODEL_REAL)
 
+/* Return true if a VAR_DECL is visible from another thread.  */
+#define DECL_THREAD_VISIBLE_P(NODE) \
+  (TREE_STATIC (NODE) && !DECL_THREAD_LOCAL_P (NODE))
+
 /* In a non-local VAR_DECL with static storage duration, true if the
variable has an initialization priority.  If false, the variable
will be initialized at the DEFAULT_INIT_PRIORITY.  */
Index: cse.c
===
--- cse.c   (revision 170745)
+++ cse.c   (working copy)
@@ -2402,6 +2402,19 @@ hash_rtx_cb (const_rtx x, enum machine_m
   }
 
 case MEM:
+  /* Avoid hoisting loads of globals if under a restrictive memory
+model.  */
+  if (PARAM_VALUE (PARAM_ALLOW_LOAD_DATA_RACES) == 0)
+   {
+ tree decl = MEM_EXPR (x);
+ if (do_not_record_p
+ && decl && TREE_CODE (decl) == VAR_DECL
+ && DECL_THREAD_VISIBLE_P (decl))
+   {
+ *do_not_record_p = 1;
+ return 0;
+   }
+   }
   /* We don't record if marked volatile or if BLKmode since we don't
 know the size of the move.  */
   if (do_not_record_p && (MEM_VOLATILE_P (x) || GET_MODE (x) == BLKmode))
Index: cselib.c
===
--- cselib.c(revision 170745)
+++ cselib.c(working copy)
@@ -1190,6 +1190,16 @@ cselib_lookup_mem (rtx x, int create)
   cselib_val *mem_elt;
   struct elt_list *l;
 
+  /* Forget any reads from globals if under a restrictive memory
+ model.  */
+  if (PARAM_VALUE (PARAM_ALLOW_LOAD_DATA_RACES) == 0)
+{
+  tree decl = MEM_EXPR (x);
+  if (decl && TREE_CODE (decl) == VAR_DECL
+ && DECL_THREAD_VISIBLE_P (decl))
+   return 0;
+}
+
   if (MEM_VOLATILE_P (x) || mode == BLKmode
   || !cselib_record_memory
   || (FLOAT_MODE_P (mode) && flag_float_store))
Index: tree-ssa-pre.c
===
--- tree-ssa-pre.c  (revision 170745)
+++ tree-ssa-pre.c  (working copy)
@@ -4000,6 +4000,12 @@ compute_avail (void)
  || stmt_could_throw_p (stmt))
continue;
 
+ /* Do not move loads of globals if under a restrictive
+memory model.  */
+ if (PARAM_VALUE (PARAM_ALLOW_LOAD_DATA_RACES) == 0
+ && gimple_has_thread_visible_ops (stmt))
+   continue;
+
  

Re: [PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions

2011-03-24 Thread Richard Henderson
On 03/23/2011 02:40 PM, Nathan Froyd wrote:
> I can look into just how many places might need to be fixed up because
> of this, but scattering a bunch of ifs all over the place seemed less
> elegant than handling it all in the emit* functions.

Yeah, maybe.  On the other hand, the other complication that's going on
there is attempting to provide a "sensible" return value in the case of
emitting a NULL_RTX, and doing different things for insns vs non-insns.

Merely removing the "different things" is surely an improvement.
Getting rid of the "sensible" probably cleans things up more, but 
probably interferes more with reload.



r~


Re: Can't use SImode as Pmode for x32

2011-03-24 Thread Richard Henderson
On 03/23/2011 08:40 PM, H.J. Lu wrote:
> Are you suggesting that we should say that SP and BP are 32bits so
> that x32 has 16 integer registers, 14 are 64 bites and 2 are 32 bits?

No, merely that push/pop are valid with (reg:SI 7 sp).

r~


Re: [toplevel] remove empty cases

2011-03-24 Thread Paolo Bonzini
On 03/24/2011 06:18 PM, Joseph S. Myers wrote:
> On Thu, 24 Mar 2011, Paolo Bonzini wrote:
> >  This enables omit-frame-pointer for i386-solaris.  I honestly haven't
> >  bootstrapped it, but I don't expect any problems (and if they appear, it's
> >  much better to fix them;).
> 
> How about killing mh-x86omitfp?  The x86 compiler defaults to
> -fomit-frame-pointer on most platforms now anyway.

Sounds good.

Paolo

2011-03-24  Paolo Bonzini  

* configure.ac: Do not include mh-x86omitfp.
* configure: Regenerate.

config:
2011-03-24  Paolo Bonzini  

* mh-x86omitfp: Remove.

Index: configure.ac
===
--- configure.ac(revision 171419)
+++ configure.ac(working copy)
@@ -1068,11 +1068,6 @@ case "${host}" in
   rs6000-*-aix*)
 host_makefile_frag="config/mh-ppc-aix"
 ;;
-  # This is placed last to prevent interfering with the cases above.
-  i[[3456789]]86-*-*)
-# Build the stage2 and stage3 compilers with -fomit-frame-pointer.
-host_makefile_frag="config/mh-x86omitfp"
-;;
 esac
 fi
 
Index: config/mh-x86omitfp
===
--- config/mh-x86omitfp (revision 171414)
+++ config/mh-x86omitfp (working copy)
@@ -1,2 +0,0 @@
-# Add -fomit-frame-pointer to the usual BOOT_CFLAGS to speed up the compiler.
-BOOT_CFLAGS += -fomit-frame-pointer


Commit: RX: Add alignment for jumps, loops and labels

2011-03-24 Thread Nick Clifton
Hi Guys,

  I am applying the patch below to add alignment control for jumps,
  loops and labels to the RX backend.

  Tested without regressions on an rx-elf target.

Cheers
  Nick

gcc/ChangeLog
2011-03-24  Nick Clifton  

* config/rx/rx.h (LABEL_ALIGN_FOR_BARRIER): Define.
(ASM_OUTPUT_MAX_SKIP_ALIGN): Define.
* config/rx/rx.c (rx_option_override): Set align_jumps,
align_loops and align_labels if not set by the user.
(rx_align_for_label): New function.
(rx_max_skip_for_label): New function.
(TARGET_ASM_JUMP_ALIGN_MAX_SKIP): Define.
(TARGET_ASM_LOOP_ALIGN_MAX_SKIP): Define.
(TARGET_ASM_LABEL_ALIGN_MAX_SKIP): Define.
(TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Define.
* config/rx/rx-protos.h (rx_align_for_label): Add prototype.

Index: gcc/config/rx/rx.h
===
--- gcc/config/rx/rx.h  (revision 171417)
+++ gcc/config/rx/rx.h  (working copy)
@@ -413,6 +413,25 @@
 #undef  USER_LABEL_PREFIX
 #define USER_LABEL_PREFIX  "_"
 
+#define LABEL_ALIGN_AFTER_BARRIER(x)   rx_align_for_label ()
+
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM, LOG, MAX_SKIP)   \
+  do   \
+{  \
+  if ((LOG) == 0 || (MAX_SKIP) == 0)   \
+break; \
+  if (TARGET_AS100_SYNTAX) \
+   {   \
+ if ((LOG) >= 2)   \
+   fprintf (STREAM, "\t.ALIGN 4\t; %d alignment actually requested\n", 
1 << (LOG)); \
+ else  \
+   fprintf (STREAM, "\t.ALIGN 2\n");   \
+   }   \
+  else \
+   fprintf (STREAM, "\t.balign %d,3,%d\n", 1 << (LOG), (MAX_SKIP));
\
+}  \
+  while (0)
+
 #define ASM_OUTPUT_ALIGN(STREAM, LOG)  \
   do   \
 {  \
Index: gcc/config/rx/rx-protos.h
===
--- gcc/config/rx/rx-protos.h   (revision 171417)
+++ gcc/config/rx/rx-protos.h   (working copy)
@@ -26,6 +26,7 @@
 #define Fargs  CUMULATIVE_ARGS
 #define Rcode  enum rtx_code
 
+extern int rx_align_for_label (void);
 extern voidrx_expand_prologue (void);
 extern int rx_initial_elimination_offset (int, int);
 
Index: gcc/config/rx/rx.c
===
--- gcc/config/rx/rx.c  (revision 171417)
+++ gcc/config/rx/rx.c  (working copy)
@@ -2350,6 +2350,13 @@
 flag_strict_volatile_bitfields = 1;
 
   rx_override_options_after_change ();
+
+  if (align_jumps == 0 && ! optimize_size)
+align_jumps = 3;
+  if (align_loops == 0 && ! optimize_size)
+align_loops = 3;
+  if (align_labels == 0 && ! optimize_size)
+align_labels = 3;
 }
 
 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
@@ -2740,8 +2747,47 @@
 
   return true;
 }
+
+int
+rx_align_for_label (void)
+{
+  return optimize_size ? 1 : 3;
+}
 
+static int
+rx_max_skip_for_label (rtx lab)
+{
+  int opsize;
+  rtx op;
+
+  if (lab == NULL_RTX)
+return 0;
+
+  op = lab;
+  do
+{
+  op = next_nonnote_nondebug_insn (op);
+}
+  while (op && (LABEL_P (op)
+   || (INSN_P (op) && GET_CODE (PATTERN (op)) == USE)));
+  if (!op)
+return 0;
+
+  opsize = get_attr_length (op);
+  if (opsize >= 0 && opsize < 8)
+return opsize - 1;
+  return 0;
+}
 
+#undef  TARGET_ASM_JUMP_ALIGN_MAX_SKIP
+#define TARGET_ASM_JUMP_ALIGN_MAX_SKIP rx_max_skip_for_label
+#undef  TARGET_ASM_LOOP_ALIGN_MAX_SKIP
+#define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rx_max_skip_for_label
+#undef  TARGET_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
+#define TARGET_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP  rx_max_skip_for_label
+#undef  TARGET_ASM_LABEL_ALIGN_MAX_SKIP
+#define TARGET_ASM_LABEL_ALIGN_MAX_SKIP
rx_max_skip_for_label
+
 #undef  TARGET_FUNCTION_VALUE
 #define TARGET_FUNCTION_VALUE  rx_function_value
 


Re: [toplevel] remove empty cases

2011-03-24 Thread Rainer Orth
"Joseph S. Myers"  writes:

> On Thu, 24 Mar 2011, Paolo Bonzini wrote:
>
>> This enables omit-frame-pointer for i386-solaris.  I honestly haven't
>> bootstrapped it, but I don't expect any problems (and if they appear, it's
>> much better to fix them ;).
>
> How about killing mh-x86omitfp?  The x86 compiler defaults to 
> -fomit-frame-pointer on most platforms now anyway.

I'd prefer that: Solaris 10+/x86 defaults to -fomit-frame-pointer for
improved debuggability (cf. gcc/config/sol2-10.h:
USE_IX86_FRAME_POINTER, USE_X86_64_FRAME_POINTER), so it would be better
leave this to the individual platforms instead.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [toplevel] remove empty cases

2011-03-24 Thread Joseph S. Myers
On Thu, 24 Mar 2011, Paolo Bonzini wrote:

> This enables omit-frame-pointer for i386-solaris.  I honestly haven't
> bootstrapped it, but I don't expect any problems (and if they appear, it's
> much better to fix them ;).

How about killing mh-x86omitfp?  The x86 compiler defaults to 
-fomit-frame-pointer on most platforms now anyway.

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


[toplevel] remove empty cases

2011-03-24 Thread Paolo Bonzini
This enables omit-frame-pointer for i386-solaris.  I honestly haven't 
bootstrapped it, but I don't expect any problems (and if they appear, 
it's much better to fix them ;).


Committed to gcc and (shortly) to src.

Paolo
2011-03-24  Paolo Bonzini  

* configure.ac: Remove empty cases.
* configure: Regenerate.

Index: configure.ac
===
--- configure.ac(revision 171416)
+++ configure.ac(working copy)
@@ -1050,8 +1050,6 @@ case "${host}" in
   *-interix*)
 host_makefile_frag="config/mh-interix"
 ;;
-  *-*-solaris2*)
-;;
   hppa*-hp-hpux10*)
 host_makefile_frag="config/mh-pa-hpux10"
 ;;
@@ -1061,8 +1059,6 @@ case "${host}" in
   hppa*-*) 
 host_makefile_frag="config/mh-pa"
 ;;
-  *-hp-hpux*)
-;;
   *-*-darwin*)
 host_makefile_frag="config/mh-darwin"
 ;;
@@ -1072,8 +1068,6 @@ case "${host}" in
   rs6000-*-aix*)
 host_makefile_frag="config/mh-ppc-aix"
 ;;
-  *-*-lynxos*)
-;;
   # This is placed last to prevent interfering with the cases above.
   i[[3456789]]86-*-*)
 # Build the stage2 and stage3 compilers with -fomit-frame-pointer.
Index: configure
===
--- configure   (revision 171416)
+++ configure   (working copy)
@@ -3623,8 +3623,6 @@ fi
   *-interix*)
 host_makefile_frag="config/mh-interix"
 ;;
-  *-*-solaris2*)
-;;
   hppa*-hp-hpux10*)
 host_makefile_frag="config/mh-pa-hpux10"
 ;;
@@ -3634,8 +3632,6 @@ fi
   hppa*-*)
 host_makefile_frag="config/mh-pa"
 ;;
-  *-hp-hpux*)
-;;
   *-*-darwin*)
 host_makefile_frag="config/mh-darwin"
 ;;
@@ -3645,8 +3641,6 @@ fi
   rs6000-*-aix*)
 host_makefile_frag="config/mh-ppc-aix"
 ;;
-  *-*-lynxos*)
-;;
   # This is placed last to prevent interfering with the cases above.
   i[3456789]86-*-*)
 # Build the stage2 and stage3 compilers with -fomit-frame-pointer.


Re: [PATCH] Better .debug_aranges fix (PR debug/48253)

2011-03-24 Thread Jakub Jelinek
On Thu, Mar 24, 2011 at 06:08:01PM +0100, Jason Merrill wrote:
> This ought to cut down on the number of cases we have to handle in
> all the different places in dwarf2out that deal with this stuff.
> 
> Does that make sense to you?

I'll try to implement it tomorrow, currently don't see why
your idea wouldn't work.  I haven't actually been able to write
a testcase that switches from cold to hot btw., not sure if that
is because I just didn't try very hard or because gcc never emits
it.  -freorder-blocks-and-partition is certainly terribly undertested
(though I wonder if anybody actually uses it, e.g. given that
EH for it has been broken for years).

Jakub


Re: [patch middle-end c c++]: Optimize cost of comp_type_attributes

2011-03-24 Thread Jason Merrill

On 03/24/2011 06:06 PM, Kai Tietz wrote:

+/* Compare two attributes for identity.  Return true if the attributes
+   are known to be equal; otherwise return false.  */
+
+static bool
+attribute_equal (const_tree attr1, const_tree attr2)
+{
+  if (attr1 == attr2)
+return true;
+


Shouldn't this compare the TREE_VALUEs?

This function is also assuming that the TREE_PURPOSEs name the same 
attribute.  I had figured that we would pull out the TREE_VALUE in the 
caller, but doing it in here is fine too as long as the function is 
documented as making that assumption.


Jason


[toplevel] cleanup mh-cygwin

2011-03-24 Thread Paolo Bonzini
The cygwin host fragment is using obsolete variables and constructs, 
modernize it.


Committed to gcc and (shortly) src.

Paolo
2011-03-24  Paolo Bonzini  
 
* Makefile.def: Add dependency from termcap to gdb.
* Makefile.in: Regenerate.

config:
2011-03-24  Paolo Bonzini  

* mh-cygwin: Remove obsolete variables and dependencies.

Index: Makefile.def
===
--- Makefile.def(revision 171416)
+++ Makefile.def(working copy)
@@ -387,6 +387,7 @@ dependencies = { module=all-gdb; on=all-
 dependencies = { module=all-gdb; on=all-build-byacc; };
 dependencies = { module=all-gdb; on=all-sim; };
 dependencies = { module=all-gdb; on=all-libdecnumber; };
+dependencies = { module=all-gdb; on=all-libtermcap; };
 
 dependencies = { module=configure-libgui; on=configure-tcl; };
 dependencies = { module=configure-libgui; on=configure-tk; };
Index: Makefile.in
===
--- Makefile.in (revision 171416)
+++ Makefile.in (working copy)
@@ -60576,6 +60576,7 @@ all-gdb: maybe-all-build-bison
 all-gdb: maybe-all-build-byacc
 all-gdb: maybe-all-sim
 all-gdb: maybe-all-libdecnumber
+all-gdb: maybe-all-libtermcap
 configure-libgui: maybe-configure-tcl
 configure-libgui: maybe-configure-tk
 all-libgui: maybe-all-tcl
Index: config/mh-cygwin
===
--- config/mh-cygwin(revision 171414)
+++ config/mh-cygwin(working copy)
@@ -1,11 +1,4 @@
-EXTRA_TARGET_HOST_ALL_MODULES=maybe-all-libtermcap
-EXTRA_TARGET_HOST_INSTALL_MODULES=maybe-install-libtermcap
-
 # Increase stack limit to a figure based on the Linux default, with 4MB added
 # as GCC turns out to need that much more to pass all the limits-* tests.
 LDFLAGS += -Wl,--stack,12582912
 BOOT_LDFLAGS += -Wl,--stack,12582912
-
-all-gdb: maybe-all-libtermcap
-
-install-gdb: maybe-all-libtermcap


Re: Cleaning up expand optabs code

2011-03-24 Thread Richard Henderson
On 03/24/2011 05:13 AM, Richard Sandiford wrote:
> gcc/
>   PR rtl-optimization/48263
>   * optabs.c (expand_binop_directly): Reinstate convert_modes code
>   and original commutative_p handling.  Use maybe_gen_insn.

Ok.


r~


Re: [PATCH] Better .debug_aranges fix (PR debug/48253)

2011-03-24 Thread Jason Merrill

On 03/23/2011 09:08 PM, Jakub Jelinek wrote:

  const char *dw_fde_begin;
  const char *dw_fde_end;
  const char *dw_fde_hot_section_label;
  const char *dw_fde_hot_section_end_label;
  const char *dw_fde_unlikely_section_label;
  const char *dw_fde_unlikely_section_end_label;
  dw_cfi_ref dw_fde_switch_cfi; /* Last CFI before switching sections.  */
  /* True iff dw_fde_begin label is in text_section or cold_text_section.  */
  unsigned in_std_section : 1;
  /* True iff dw_fde_unlikely_section_label is in text_section or
 cold_text_section.  */
  unsigned cold_in_std_section : 1;
  /* True iff switched sections.  */
  unsigned dw_fde_switched_sections : 1;
  /* True iff switching from cold to hot section.  */
  unsigned dw_fde_switched_cold_to_hot : 1;


Looking at this patch, without having previously paid much attention to 
the hot/cold partitioning code, I find these flags very confusing; it 
took me a while to figure out what they really mean.


It seems that we are sometimes splitting functions into hot and cold, 
and those partitions can either be in standard sections or 
function-specific ones.  So it seems like the information we want is:


Primary start/end label (dw_fde_begin/end)
Primary in standard section (in_std_section or cold_in_std_section)
Secondary section used (dw_fde_switched_sections)
Secondary start/end label (dw_fde_{hot,unlikely}_section_{,end_}label)
Secondary in standard section (in_std_section or cold_in_std_section)

It seems to me that we don't need to have the labels for both hot and 
cold sections in addition to begin/end, and we could replace 
dw_fde_switched_sections with just checking whether the secondary labels 
are NULL.


I think we could drop dw_fde_switched_cold_to_hot in favor of the 
primary/secondary model; for debugging purposes it doesn't matter 
whether the primary section is hot or cold.


This ought to cut down on the number of cases we have to handle in all 
the different places in dwarf2out that deal with this stuff.


Does that make sense to you?

Jason


[toplevel] cleanup X11_FLAGS_TO_PASS

2011-03-24 Thread Paolo Bonzini

Yet another relic of cygnus configure.  Eliminate.

Committed to gcc and (shortly) to src.

Paolo
2011-03-24  Paolo Bonzini  

* configure.ac: Remove all mentions of mh-sysv4 and mh-solaris.
* configure: Regenerate.
* Makefile.def: Remove all mentions of X11_FLAGS_TO_PASS.
* Makefile.tpl: Likewise.
* Makefile.in: Regenerate.

config:
2011-03-24  Paolo Bonzini  

* mh-sysv4: Remove.
* mh-solaris: Remove.

Index: configure.ac
===
--- configure.ac(revision 171415)
+++ configure.ac(working copy)
@@ -1037,9 +1037,6 @@ esac
 host_makefile_frag=/dev/null
 if test -d ${srcdir}/config ; then
 case "${host}" in
-  i[[3456789]]86-*-solaris2*)
-host_makefile_frag="config/mh-sysv4"
-;;
   i[[3456789]]86-*-msdosdjgpp*)
 host_makefile_frag="config/mh-djgpp"
 ;;
@@ -1054,7 +1051,6 @@ case "${host}" in
 host_makefile_frag="config/mh-interix"
 ;;
   *-*-solaris2*)
-host_makefile_frag="config/mh-solaris"
 ;;
   hppa*-hp-hpux10*)
 host_makefile_frag="config/mh-pa-hpux10"
Index: config/mh-solaris
===
--- config/mh-solaris   (revision 171414)
+++ config/mh-solaris   (working copy)
@@ -1,2 +0,0 @@
-# Makefile changes for Suns running Solaris 2
-X11_EXTRA_LIBS = -lnsl -lsocket
 2011-03-24  Joseph Myers  
Index: config/mh-sysv4
===
--- config/mh-sysv4 (revision 171414)
+++ config/mh-sysv4 (working copy)
@@ -1 +0,0 @@
-X11_EXTRA_LIBS = -lnsl
Index: Makefile.def
===
--- Makefile.def(revision 171414)
+++ Makefile.def(working copy)
@@ -134,10 +134,10 @@ host_modules= { module= uudecode; };
 host_modules= { module= wdiff; };
 host_modules= { module= zip; no_check_cross=true; };
 host_modules= { module= zlib; no_install=true; no_check=true; bootstrap=true; 
};
-host_modules= { module= gdb; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
-host_modules= { module= expect; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
-host_modules= { module= guile; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
-host_modules= { module= tk; extra_make_flags="$(X11_FLAGS_TO_PASS)"; };
+host_modules= { module= gdb; };
+host_modules= { module= expect; };
+host_modules= { module= guile; };
+host_modules= { module= tk; };
 host_modules= { module= libtermcap; no_check=true; 
 missing=mostlyclean;
 missing=clean;
Index: Makefile.in
===
--- Makefile.in (revision 169877)
+++ Makefile.in (working copy)
@@ -796,18 +796,6 @@ EXTRA_HOST_FLAGS = \
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
-# Flags that are concerned with the location of the X11 include files
-# and library files
-#
-# NOTE: until the top-level is getting the values via autoconf, it only
-# causes problems to have this top-level Makefile overriding the autoconf-set
-# values in child directories.  Only variables that don't conflict with
-# autoconf'ed ones should be passed by X11_FLAGS_TO_PASS for now.
-#
-X11_FLAGS_TO_PASS = \
-   'X11_EXTRA_CFLAGS=$(X11_EXTRA_CFLAGS)' \
-   'X11_EXTRA_LIBS=$(X11_EXTRA_LIBS)'
-
 # Flags to pass to stage2 and later makes.
 
 POSTSTAGE1_FLAGS_TO_PASS = \
@@ -42263,7 +42251,7 @@ all-gdb: configure-gdb
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS)  \
(cd $(HOST_SUBDIR)/gdb && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) 
$(X11_FLAGS_TO_PASS) \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
$(TARGET-gdb))
 @endif gdb
 
@@ -42281,7 +42269,7 @@ check-gdb:
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/gdb && \
- $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) check)
+ $(MAKE) $(FLAGS_TO_PASS)  check)
 
 @endif gdb
 
@@ -42296,7 +42284,7 @@ install-gdb: installdirs
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/gdb && \
- $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install)
+ $(MAKE) $(FLAGS_TO_PASS)  install)
 
 @endif gdb
 
@@ -42311,7 +42299,7 @@ install-strip-gdb: installdirs
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/gdb && \
- $(MAKE) $(FLAGS_TO_PASS) $(X11_FLAGS_TO_PASS) install-strip)
+ $(MAKE) $(FLAGS_TO_PASS)  install-strip)
 
 @endif gdb
 
@@ -42329,7 +42317,7 @@ info-gdb: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
-   for flag in $(EXTRA_HOST_FLAGS) $(X11_FLAGS_TO_PASS); do \
+   for flag in $(EXTRA_HOST_FLAGS) ; do \
  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\

Re: [patch middle-end c c++]: Optimize cost of comp_type_attributes

2011-03-24 Thread Kai Tietz
2011/3/24 Jason Merrill :
> How about splitting this out into a separate function that can compare
> either list or expression arguments?  That would also be useful for
> merge_attributes and attribute_list_contained.
>
> Jason
>

Ok, here is the patch

ChangeLog gcc/

2011-03-11  Kai Tietz

   * c-typeck.c (comptypes_internal): Replace target
   hook call of comp_type_attributes by version in tree.c file.
   * gimple.c (gimple_types_compatible_p_1): Likewise.
   * tree-ssa.c (useless_type_conversion_p): Likewise.
   * tree.c (build_type_attribute_qual_variant): Likewise.
   (attribute_equal): New static helper function.
   (comp_type_attributes): New function.
   (merge_attributes): Use attribute_equal for comparison.
   (attribute_list_contained): Likewise.
   * tree.h (comp_type_attributes): New prototype.

ChangeLog cp/

2011-03-11  Kai Tietz

   * decl.c (decls_match): Replace target hook
   call of comp_type_attributes by version in tree.c file.
   * search.c (check_final_overrider): Likewise.
   * typeck.c (structural_comptypes): Likewise.

Regards,
Kai
Index: gcc/gcc/c-typeck.c
===
--- gcc.orig/gcc/c-typeck.c 2011-03-24 08:23:42.441173500 +0100
+++ gcc/gcc/c-typeck.c  2011-03-24 09:24:53.445892300 +0100
@@ -1079,7 +1079,7 @@ comptypes_internal (const_tree type1, co
 return 1;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
-  if (!(attrval = targetm.comp_type_attributes (t1, t2)))
+  if (!(attrval = comp_type_attributes (t1, t2)))
  return 0;
 
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
Index: gcc/gcc/cp/decl.c
===
--- gcc.orig/gcc/cp/decl.c  2011-03-24 08:23:42.443173500 +0100
+++ gcc/gcc/cp/decl.c   2011-03-24 09:24:53.573408500 +0100
@@ -1012,8 +1012,8 @@ decls_match (tree newdecl, tree olddecl)
types_match =
  compparms (p1, p2)
  && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
- || targetm.comp_type_attributes (TREE_TYPE (newdecl),
-  TREE_TYPE (olddecl)) != 0);
+ || comp_type_attributes (TREE_TYPE (newdecl),
+  TREE_TYPE (olddecl)) != 0);
}
   else
types_match = 0;
Index: gcc/gcc/cp/search.c
===
--- gcc.orig/gcc/cp/search.c2011-03-24 08:23:42.444173500 +0100
+++ gcc/gcc/cp/search.c 2011-03-24 09:24:53.645417600 +0100
@@ -1897,7 +1897,7 @@ check_final_overrider (tree overrider, t
 }
 
   /* Check for conflicting type attributes.  */
-  if (!targetm.comp_type_attributes (over_type, base_type))
+  if (!comp_type_attributes (over_type, base_type))
 {
   error ("conflicting type attributes specified for %q+#D", overrider);
   error ("  overriding %q+#D", basefn);
Index: gcc/gcc/cp/typeck.c
===
--- gcc.orig/gcc/cp/typeck.c2011-03-24 08:23:42.495173500 +0100
+++ gcc/gcc/cp/typeck.c 2011-03-24 09:24:53.697424200 +0100
@@ -1338,7 +1338,7 @@ structural_comptypes (tree t1, tree t2,
   /* If we get here, we know that from a target independent POV the
  types are the same.  Make sure the target attributes are also
  the same.  */
-  return targetm.comp_type_attributes (t1, t2);
+  return comp_type_attributes (t1, t2);
 }
 
 /* Return true if T1 and T2 are related as allowed by STRICT.  STRICT
Index: gcc/gcc/gimple.c
===
--- gcc.orig/gcc/gimple.c   2011-03-24 08:23:42.496173500 +0100
+++ gcc/gcc/gimple.c2011-03-24 09:24:53.793936500 +0100
@@ -3615,7 +3615,7 @@ gimple_types_compatible_p_1 (tree t1, tr
 state, sccstack, sccstate, sccstate_obstack))
goto different_types;
 
-  if (!targetm.comp_type_attributes (t1, t2))
+  if (!comp_type_attributes (t1, t2))
goto different_types;
 
   if (TYPE_ARG_TYPES (t1) == TYPE_ARG_TYPES (t2))
Index: gcc/gcc/tree-ssa.c
===
--- gcc.orig/gcc/tree-ssa.c 2011-03-24 08:23:42.498173500 +0100
+++ gcc/gcc/tree-ssa.c  2011-03-24 09:24:53.831441200 +0100
@@ -1438,7 +1438,7 @@ useless_type_conversion_p (tree outer_ty
 
   /* Defer to the target if necessary.  */
   if (TYPE_ATTRIBUTES (inner_type) || TYPE_ATTRIBUTES (outer_type))
-   return targetm.comp_type_attributes (outer_type, inner_type) != 0;
+   return comp_type_attributes (outer_type, inner_type) != 0;
 
   return true;
 }
Index: gcc/gcc/tree.c
===
--- gcc.orig/gcc/tree.c 2011-03-24 08:23:42.499173500 +0100
+++ gcc/gcc/tree.c  2011-03-24 18:00:04.39808470

[toplevel] remove tentative_cc

2011-03-24 Thread Paolo Bonzini
As Joseph pointed out in his mail, its time has come.

Paolo

2011-03-24  Paolo Bonzini  

* configure.ac: Remove all mentions of tentative_cc.
* configure: Regenerate.


Index: configure.ac
===
--- configure.ac(revision 171414)
+++ configure.ac(working copy)
@@ -1034,7 +1034,6 @@ case "${noconfigdirs}" in
 esac
 
 # Work in distributions that contain no compiler tools, like Autoconf.
-tentative_cc=""
 host_makefile_frag=/dev/null
 if test -d ${srcdir}/config ; then
 case "${host}" in
@@ -1058,18 +1057,15 @@ case "${host}" in
 host_makefile_frag="config/mh-solaris"
 ;;
   hppa*-hp-hpux10*)
-tentative_cc="cc -Wp,-H256000"
 host_makefile_frag="config/mh-pa-hpux10"
 ;;
   hppa*-hp-hpux*)
-tentative_cc="cc -Wp,-H256000"
 host_makefile_frag="config/mh-pa"
 ;;
   hppa*-*) 
 host_makefile_frag="config/mh-pa"
 ;;
   *-hp-hpux*)
-tentative_cc="cc -Wp,-H256000"
 ;;
   *-*-darwin*)
 host_makefile_frag="config/mh-darwin"
@@ -1081,8 +1077,6 @@ case "${host}" in
 host_makefile_frag="config/mh-ppc-aix"
 ;;
   *-*-lynxos*)
-# /bin/cc is less than useful for our purposes.  Always use GCC
-tentative_cc="/bin/gcc"
 ;;
   # This is placed last to prevent interfering with the cases above.
   i[[3456789]]86-*-*)
@@ -1092,25 +1086,6 @@ case "${host}" in
 esac
 fi
 
-# If we aren't going to be using gcc, see if we can extract a definition
-# of CC from the fragment.
-# Actually, use the 'pre-extracted' version above.
-if test -z "${CC}" && test "${build}" = "${host}" ; then
-  IFS="${IFS=  }"; save_ifs="$IFS"; IFS="${IFS}:"
-  found=
-  for dir in $PATH; do
-test -z "$dir" && dir=.
-if test -f $dir/gcc; then
-  found=yes
-  break
-fi
-  done
-  IFS="$save_ifs"
-  if test -z "${found}" && test -n "${tentative_cc}" ; then
-CC=$tentative_cc
-  fi
-fi
-
 if test "${build}" != "${host}" ; then
   AR_FOR_BUILD=${AR_FOR_BUILD-ar}
   AS_FOR_BUILD=${AS_FOR_BUILD-as}


[v3] Fix negative_binomial_distribution

2011-03-24 Thread Paolo Carlini

Hi,

this does fix a bad thinko of mine in negative_binomial_distribution 
(the fix will certainly go in 4.6.1, unless Jakub wants it now) + I'm 
adding basic statistical tests (adapted from GSL) for all the other 
discrete distributions.


Thanks,
Paolo.

//
2011-03-24  Paolo Carlini  

* include/bits/random.h (negative_binomial_distribution<>::
negative_binomial_distribution(_IntType, double),
negative_binomial_distribution<>::
negative_binomial_distribution(const param_type&)): Fix
construction of _M_gd.
* include/bits/random.tcc (negative_binomial_distribution<>::
operator()): Fix computation, per Leger's algorithm.
* testsuite/util/testsuite_random.h (discrete_pdf,
negative_binomial_pdf, poisson_pdf, uniform_int_pdf): New.
(binomial_pdf): Swap last two parameters.
* testsuite/26_numerics/random/discrete_distribution/
operators/values.cc: New.
* testsuite/26_numerics/random/negative_binomial_distribution/
operators/values.cc: Likewise.
* testsuite/26_numerics/random/poisson_distribution/
operators/values.cc: Likewise.
* testsuite/26_numerics/random/uniform_int_distribution/
operators/values.cc: Likewise.
* testsuite/26_numerics/random/binomial_distribution/
operators/values.cc: Adjust.Index: include/bits/random.tcc
===
--- include/bits/random.tcc (revision 171401)
+++ include/bits/random.tcc (working copy)
@@ -1075,7 +1075,7 @@
   return __is;
 }
 
-
+  // This is Leger's algorithm.
   template
 template
   typename negative_binomial_distribution<_IntType>::result_type
@@ -1085,7 +1085,8 @@
const double __y = _M_gd(__urng);
 
// XXX Is the constructor too slow?
-   std::poisson_distribution __poisson(__y);
+   std::poisson_distribution __poisson(__y * (1.0 - p())
+/ p());
return __poisson(__urng);
   }
 
@@ -1099,10 +1100,10 @@
typedef typename std::gamma_distribution::param_type
  param_type;

-   const double __y =
- _M_gd(__urng, param_type(__p.k(), __p.p() / (1.0 - __p.p(;
+   const double __y = _M_gd(__urng, param_type(__p.k(), 1.0));
 
-   std::poisson_distribution __poisson(__y);
+   std::poisson_distribution __poisson(__y * (1.0 - __p.p())
+/ __p.p() );
return __poisson(__urng);
   }
 
Index: include/bits/random.h
===
--- include/bits/random.h   (revision 171401)
+++ include/bits/random.h   (working copy)
@@ -3611,8 +3611,7 @@
param_type(double __p = 0.5)
: _M_p(__p)
{
- _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0)
-&& (_M_p < 1.0));
+ _GLIBCXX_DEBUG_ASSERT((_M_p > 0.0) && (_M_p < 1.0));
  _M_initialize();
}
 
@@ -3782,7 +3781,9 @@
explicit
param_type(_IntType __k = 1, double __p = 0.5)
: _M_k(__k), _M_p(__p)
-   { }
+   {
+ _GLIBCXX_DEBUG_ASSERT((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
+   }
 
_IntType
k() const
@@ -3803,12 +3804,12 @@
 
   explicit
   negative_binomial_distribution(_IntType __k = 1, double __p = 0.5)
-  : _M_param(__k, __p), _M_gd(__k, __p / (1.0 - __p))
+  : _M_param(__k, __p), _M_gd(__k, 1.0)
   { }
 
   explicit
   negative_binomial_distribution(const param_type& __p)
-  : _M_param(__p), _M_gd(__p.k(), __p.p() / (1.0 - __p.p()))
+  : _M_param(__p), _M_gd(__p.k(), 1.0)
   { }
 
   /**
Index: testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc
===
--- testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc   
(revision 0)
+++ testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc   
(revision 0)
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+//
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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.
+//
+// This library 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 this library; see the file COPYING3.  If not see
+// 

cleanup host fragments more 1/n

2011-03-24 Thread Paolo Bonzini

AR_CFLAGS = cr is already the default.

Committed to gcc and src.

Paolo

2011-03-24  Paolo Bonzini  

* mh-sysv4: Remove AR_CFLAGS.

Index: mh-sysv4
===
--- mh-sysv4(revision 171413)
+++ mh-sysv4(working copy)
@@ -1,4 +1 @@
-# The l flag generates a warning from the SVR4 archiver, remove it.
-AR_FLAGS = cr
-
 X11_EXTRA_LIBS = -lnsl


Re: [PATCH v3] Re: avoid useless if-before-free tests

2011-03-24 Thread Jim Meyering
Janne Blomqvist wrote:
> On Tue, Mar 8, 2011 at 19:53, Jim Meyering  wrote:
>> Relative to v2, I've added libgo/ to the list of exempt directories and added
>> this recently discussed gfc_free patch, at the request of Tobias Burnus.
>> Also, I corrected an error in fortran's ChangeLog and removed all
>> whitespace changes from all ChangeLog files.
>
> The libgfortran changes are Ok for 4.7.
>
> For the gfortran frontend (gcc/fortran/*) I'd prefer if you'd
>
> - Replace all calls to "gfc_free (x)" with "free (x)".
> - Remove the gfc_free() function and prototype.
> - Remove the free() macro which currently prevents calling free() directly.

Following up, I've refreshed the series but hit a minor snag
while converting new uses of gfc_free, removing new tests-before-free
and merging/reordering changes.

Applying this fix first makes my problem go away:

>From 77142dc7da9e1e11ef8b0c554df4ff5c1bbdda39 Mon Sep 17 00:00:00 2001
From: Jim Meyering 
Date: Thu, 24 Mar 2011 17:45:42 +0100
Subject: [PATCH] gfortran: remove unneeded test-before-gfc_free

* trans-openmp.c (gfc_trans_omp_reduction_list): Do not guard
use of gfc_free; it can handle a NULL argument.
---
 gcc/fortran/ChangeLog  |5 +
 gcc/fortran/trans-openmp.c |3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4e0a792..c532986 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-24  Jim Meyering  
+
+   * trans-openmp.c (gfc_trans_omp_reduction_list): Do not guard
+   use of gfc_free; it can handle a NULL argument.
+
 2010-03-21  Thomas Koenig  

PR fortran/22572
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 53eb999..77ed3bb 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -714,8 +714,7 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol *sym, 
locus where)
   gfc_free (symtree1);
   gfc_free (symtree2);
   gfc_free (symtree3);
-  if (symtree4)
-gfc_free (symtree4);
+  gfc_free (symtree4);
   gfc_free_array_spec (outer_sym.as);
 }

--
1.7.4.1.686.g46300


Re: [PATCH] reload: Avoid superfluous reloads after find_reloads_subreg_address

2011-03-24 Thread Ulrich Weigand
Andreas Krebbel wrote:

> 2011-03-23  Andreas Krebbel  
> 
>   * reload.c (find_reloads_subreg_address): Add address_reloaded
>   parameter and return true there if the full address has been
>   reloaded.
>   (find_reloads_toplev): Pass address_reloaded flag.
>   (find_reloads_address_1): Don't use address_reloaded parameter.

This is OK.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


Re: Tighten ARM's CANNOT_CHANGE_MODE_CLASS

2011-03-24 Thread Richard Earnshaw

On Thu, 2011-03-24 at 15:40 +, Richard Sandiford wrote:
> We currently generate very poor code for tests like:
> 
> #include 
> 
> void
> foo (uint32_t *a, uint32_t *b, uint32_t *c)
> {
>   uint32x4x3_t x, y;
> 
>   x = vld3q_u32 (a);
>   y = vld3q_u32 (b);
>   x.val[0] = vaddq_u32 (x.val[0], y.val[0]);
>   x.val[1] = vaddq_u32 (x.val[1], y.val[1]);
>   x.val[2] = vaddq_u32 (x.val[2], y.val[2]);
>   vst3q_u32 (a, x);
> }
> 
> This is because we force the uint32x4x3_t values to the stack and
> then load and store the individual vectors.
> 
> What we actually want is for the uint32x4x3_t values to be stored
> in registers, and for the individual vectors to be accessed as
> subregs of those registers.  The first part involves some middle-end
> mode changes (see recent gcc@ thread), while the second part requires
> a change to ARM's CANNOT_CHANGE_MODE_CLASS.
> 
> CANNOT_CHANGE_MODE_CLASS is defined as:
> 
> /* FPA registers can't do subreg as all values are reformatted to internal
>precision.  VFP registers may only be accessed in the mode they
>were set.  */
> #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
>   (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
>? reg_classes_intersect_p (FPA_REGS, (CLASS))  \
>  || reg_classes_intersect_p (VFP_REGS, (CLASS))   \
>: 0)
> 
> But this VFP restriction appears to apply only to VFPv1; thanks to
> Peter Maydell for the archaeology.
> 
> Tested on arm-linux-gnueabi.  OK to install?
> 
> This doesn't have any direct benefit without the middle-end mode change,
> but it needs to go in first in order for that change not to regress.
> 
> Richard
> 
> 
> gcc/
>   * config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Restrict FPA_REGS
>   case to VFPv1.
> 

GCC doesn't support VFPv1 (see the all_fpus table), and I don't think
many chips based on that ever escaped into the wild world, so I'm not
worried about trying to add that now.

So it's probably safe to just kill that check for VFP entirely.

R.





[libgo] Support Solaris 8/9

2011-03-24 Thread Rainer Orth
When I tried to build libgo on Solaris 9/x86 with native tools, I ran
into a couple of issues:

* To correctly build sysinfo.go, one needs a different set of flags to
  compile sysinfo.c that conflict with the onces needed on Solaris 10+.
  Since there seems to be no easy way to autoconf this knowledge, I'm
  hardcoding it in configure.ac (OSCFLAGS) and pass it to mksysinfo.sh.

* As documented in the Autoconf manual, the native grep cannot handle
  \|.  One needs to use egrep for that instead.  I've only updated the
  affected invocations, but one may want (or need) to either do this
  wholesale and/or replace the hardcoded egrep by autoconfed $EGREP.

* Similarly, native sed cannot handle \?, so I'm substituting both
  alternatives in sequence.

* For native TLS to work, libgo needs to be linked with -pthread, so
  libthread.so is included in the link.  On Solaris 8, -pthread takes
  care of even more contortions necessary to get the proper thread
  library.  In order for that to happen, I've introduced
  libgo_la_LDFLAGS.

With those changes (and the strerror_r replacement since Solaris 8 and 9
also lack that function), I could successfully build and test libgo,
with relatively decent results:

FAIL: fmt
Can't open -n
grep: can't open -n
grep: can't open -n
mallocs per Sprintf(""): 1
mallocs per Sprintf("xxx"): 1
mallocs per Sprintf("%x"): 3
mallocs per Sprintf("%x %x"): 4
/vol/gcc/src/hg/trunk/local/libgo/testsuite/gotest[325]: 22734 Segmentation 
Fault
make: *** [fmt/check] Error 1

FAIL: archive/zip
Can't open -n
grep: can't open -n
grep: can't open -n
--- FAIL: zip.TestReader (0.0 seconds)
error=open testdata/dd.zip: No such file or directory, want 
FAIL
make: *** [archive/zip/check] Error 1

FAIL: crypto/rand
Can't open -n
grep: can't open -n
grep: can't open -n
--- FAIL: rand.TestRead (0.0 seconds)
Read(buf) = 1040, %!s()
FAIL
make: *** [crypto/rand/check] Error 1

FAIL: image/png
Can't open -n
grep: can't open -n
grep: can't open -n
--- FAIL: png.TestReader (1.0 seconds)
basn0g01-30 open testdata/pngsuite/basn0g01-30.png: No such file or 
directory
basn0g02-29 open testdata/pngsuite/basn0g02-29.png: No such file or 
directory
basn0g04-31 open testdata/pngsuite/basn0g04-31.png: No such file or 
directory
--- FAIL: png.TestWriter (0.2 seconds)
basn0g01-30 open testdata/pngsuite/basn0g01-30.png: No such file or 
directory
basn0g02-29 open testdata/pngsuite/basn0g02-29.png: No such file or 
directory
basn0g04-31 open testdata/pngsuite/basn0g04-31.png: No such file or 
directory
FAIL
make: *** [image/png/check] Error 1

I'll be running make check-go shortly.

Rainer


2011-03-24  Rainer Orth  

* configure.ac (OSCFLAGS): Define.
* Makefile.am (s-sysinfo): Use it.
(libgo_la_LDFLAGS): Define.
* mksysinfo.sh (sysinfo.c) [__sun__ && __svr4__]: Remove.
Replace \| in grep REs with egrep and |.
Replace \? in sed REs with two variants.
* Makefile.in: Regenerate.
* configure: Regenerate.

diff -r 75d0e839ffe1 libgo/Makefile.am
--- a/libgo/Makefile.am Thu Mar 24 13:22:54 2011 +0100
+++ b/libgo/Makefile.am Thu Mar 24 16:45:53 2011 +0100
@@ -1459,6 +1459,8 @@
 
 libgo_la_SOURCES = $(runtime_files)
 
+libgo_la_LDFLAGS = $(PTHREAD_CFLAGS)
+
 libgo_la_LIBADD = \
$(libgo_go_objs) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
 
@@ -2512,7 +2514,7 @@
 
 sysinfo.go: s-sysinfo; @true
 s-sysinfo: $(srcdir)/mksysinfo.sh config.h
-   CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) 
$(CPPFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh
+   CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) 
$(CPPFLAGS) $(OSCFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh
$(SHELL) $(srcdir)/../move-if-change tmp-sysinfo.go sysinfo.go
$(STAMP) $@
 
diff -r 75d0e839ffe1 libgo/configure.ac
--- a/libgo/configure.acThu Mar 24 13:22:54 2011 +0100
+++ b/libgo/configure.acThu Mar 24 16:45:53 2011 +0100
@@ -229,6 +229,22 @@
 fi
 AC_SUBST(GO_DEBUG_PROC_REGS_OS_ARCH_FILE)
 
+dnl Some targets need special flags to build sysinfo.go.
+case "$target" in
+*-*-solaris2.[[89]])
+   # Solaris 8/9 need this so struct msghdr gets the msg_control
+   # etc. fields in  (_XPG4_2).
+   OSCFLAGS='-D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D__EXTENSIONS__'
+   ;;
+*-*-solaris2.1[[01]])
+   # Solaris 10+ needs this so struct msghdr gets the msg_control
+   # etc. fields in  (_XPG4_2).  _XOPEN_SOURCE=500 as
+   # above doesn't work with C99.
+   OSCFLAGS='-D_XOPEN_SOURCE=600 -D__EXTENSIONS__'
+   ;;
+esac
+AC_SUBST(OSCFLAGS)
+
 dnl Use -fsplit-stack when compiling C code if available.
 AC_CACHE_CHECK([whether -fsplit-stack is supported],
 [libgo_cv_c_split_stack_supported],
diff -r 75d0e839ffe1 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.shThu Mar 24 13:22:54 2011 +0100
+++ b/libgo/mksysinfo.shThu Mar 24 16:45:53

Re: Remove old host cases from toplevel configure

2011-03-24 Thread Paolo Bonzini

On 03/24/2011 03:11 PM, Joseph S. Myers wrote:

Furthermore, the whole idea of the toplevel configure tentative_cc
setting code is dubious since this is an autoconf-generated script and
it's autoconf's job to deal with finding a working compiler, putting
it in ANSI C mode, etc. - so if someone did wish to resupport one of
these hosts (and in the unlikely event that building current tools
using the old system compiler is at all possible) it would be better
to put system-specific pieces in autoconf and make toolchain configure
code work using features not host triplet tests as far as possible.


100% agreed, I've meant to clean this up for a long time.


OK to commit?


Yes, thank you very much.

Paolo


[PATCH] S/390: Fix reject malformed symbolic addresses in preferred_reload_class

2011-03-24 Thread Andreas Krebbel
Hi,

reloads of symbolic addresses are done using larl (if possible) which
allows to load a symbol_ref or label_ref plus an even addend.  Since
these addresses are constants special care has to be taken in
preferred_reload class.  We have to return NO_REGS in case of a
malformed address like symref + odd addend.  Otherwise reload assumes
that these can be directly reloaded into a register.

Fixed with the attached patch.

Bootstrapped an regtested on s390, s390x with mainline and 4.6.

Committed to mainline.
Ok for 4.6?

Bye,

-Andreas-


2011-03-24  Andreas Krebbel  

* config/s390/s390.c (s390_preferred_reload_class): Return NO_REGS
for invalid symbolic addresses.
(s390_secondary_reload): Don't use s390_check_symref_alignment for
larl operands.


Index: gcc/config/s390/s390.c
===
*** gcc/config/s390/s390.c.orig
--- gcc/config/s390/s390.c
*** s390_preferred_reload_class (rtx op, reg
*** 3003,3014 
 it is most likely being used as an address, so
 prefer ADDR_REGS.  If 'class' is not a superset
 of ADDR_REGS, e.g. FP_REGS, reject this reload.  */
-   case PLUS:
case LABEL_REF:
case SYMBOL_REF:
case CONST:
if (reg_class_subset_p (ADDR_REGS, rclass))
!   return ADDR_REGS;
else
  return NO_REGS;
  
--- 3003,3018 
 it is most likely being used as an address, so
 prefer ADDR_REGS.  If 'class' is not a superset
 of ADDR_REGS, e.g. FP_REGS, reject this reload.  */
case LABEL_REF:
case SYMBOL_REF:
case CONST:
+   if (!legitimate_reload_constant_p (op))
+   return NO_REGS;
+   /* fallthrough */
+   case PLUS:
+   /* load address will be used.  */
if (reg_class_subset_p (ADDR_REGS, rclass))
! return ADDR_REGS;
else
  return NO_REGS;
  
*** s390_secondary_reload (bool in_p, rtx x,
*** 3126,3137 
  
if (TARGET_Z10)
  {
/* On z10 several optimizer steps may generate larl operands with
 an odd addend.  */
if (in_p
! && s390_symref_operand_p (x, NULL, NULL)
  && mode == Pmode
! && !s390_check_symref_alignment (x, 2))
sri->icode = ((mode == DImode) ? CODE_FOR_reloaddi_larl_odd_addend_z10
  : CODE_FOR_reloadsi_larl_odd_addend_z10);
  
--- 3130,3145 
  
if (TARGET_Z10)
  {
+   HOST_WIDE_INT offset;
+   rtx symref;
+ 
/* On z10 several optimizer steps may generate larl operands with
 an odd addend.  */
if (in_p
! && s390_symref_operand_p (x, &symref, &offset)
  && mode == Pmode
! && !SYMBOL_REF_ALIGN1_P (symref)
! && (offset & 1) == 1)
sri->icode = ((mode == DImode) ? CODE_FOR_reloaddi_larl_odd_addend_z10
  : CODE_FOR_reloadsi_larl_odd_addend_z10);
  


[libgo] Improve Solaris 2/SPARC support

2011-03-24 Thread Rainer Orth
In order to improve Go test results on Solaris 2/SPARC, I need the
following patch.

* go-test.exp wasn't updated for the change from sparcv9 to sparc64.
  While I still don't agree with the new name, at least the two should
  be consistent.

* env.go needs to accept sparc and sparc64.

* Just like 32-bit Solaris 2/x86, 32-bit Solaris 2/SPARC needs to use
  the largefile variants of several functions.  I've not introduced a
  new LIBGO_IS_SOLARIS32 conditional for that, but perhaps one should?

With this patch, results are considerably improved, though still not
good:  the rpc and websocket tests hang indefinitely, as reported in PR
go/48242, so one cannot include Go in a default bootstrap.  I'll
investigate those shortly.  Apart from that, many tests fail, cf. PR
go/48243.

I'll have a look at them in the future, but wanted the get the
low-hanging fruit out of the door.

Rainer


2011-03-24  Rainer Orth  

go:
* go.test/go-test.exp (go-set-goarch): Use sparc64 for 64-bit SPARC.
* go.test/test/env.go (main): Handle sparc, sparc64.

libgo:
* Makefile.am (go_os_dir_file) [LIBGO_IS_SPARC]: Use
go/os/dir_largefile.go.
(syscall_filesize_file) [LIBGO_IS_SPARC]: Use
syscalls/sysfile_largefile.go.
(syscall_stat_file) [LIBGO_IS_SPARC]: Use
syscalls/sysfile_stat_largefile.go.
* Makefile.in: Regenerate.

diff -r de1b3baf021b gcc/testsuite/go.test/go-test.exp
--- a/gcc/testsuite/go.test/go-test.exp Thu Mar 24 13:19:30 2011 +0100
+++ b/gcc/testsuite/go.test/go-test.exp Thu Mar 24 13:22:43 2011 +0100
@@ -129,7 +129,7 @@
if [check_effective_target_ilp32] {
set goarch "sparc"
} else {
-   set goarch "sparcv9"
+   set goarch "sparc64"
}
}
default {
diff -r de1b3baf021b gcc/testsuite/go.test/test/env.go
--- a/gcc/testsuite/go.test/test/env.go Thu Mar 24 13:19:30 2011 +0100
+++ b/gcc/testsuite/go.test/test/env.go Thu Mar 24 13:22:43 2011 +0100
@@ -1,7 +1,7 @@
 // [ $GOOS != nacl ] || exit 0  # NaCl runner does not expose environment
 // $G $F.go && $L $F.$A && ./$A.out
 
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 2011 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
@@ -15,7 +15,8 @@
print("$GOARCH: ", e0.String(), "\n")
os.Exit(1)
}
-   if ga != "amd64" && ga != "386" && ga != "arm" {
+   if ga != "386" && ga != "amd64" && ga != "arm" && ga != "sparc" &&
+  ga != "sparc64" {
print("$GOARCH=", ga, "\n")
os.Exit(1)
}
diff -r de1b3baf021b libgo/Makefile.am
--- a/libgo/Makefile.am Thu Mar 24 13:19:30 2011 +0100
+++ b/libgo/Makefile.am Thu Mar 24 13:22:43 2011 +0100
@@ -676,8 +676,12 @@
 if LIBGO_IS_386
 go_os_dir_file = go/os/dir_largefile.go
 else
+if LIBGO_IS_SPARC
+go_os_dir_file = go/os/dir_largefile.go
+else
 go_os_dir_file = go/os/dir_regfile.go
 endif
+endif
 else
 if LIBGO_IS_LINUX
 go_os_dir_file = go/os/dir_largefile.go
@@ -1188,16 +1192,21 @@
 syscall_stat_file = syscalls/sysfile_stat_largefile.go
 else # !LIBGO_IS_LINUX
 if LIBGO_IS_SOLARIS
-# FIXME: Same for sparc vs. sparc64.  Introduce new/additional conditional?
 if LIBGO_IS_386
-# Use lseek64 on 386 Solaris.
+# Use lseek64 on 32-bit Solaris/x86.
 syscall_filesize_file = syscalls/sysfile_largefile.go
 syscall_stat_file = syscalls/sysfile_stat_largefile.go
-else # !LIBGO_IS_LINUX && LIBGO_IS_SOLARIS && !LIBGO_IS_386
-# Use lseek on amd64 Solaris.
+else # !LIBGO_IS_386
+if LIBGO_IS_SPARC
+# Use lseek64 on 32-bit Solaris/SPARC.
+syscall_filesize_file = syscalls/sysfile_largefile.go
+syscall_stat_file = syscalls/sysfile_stat_largefile.go
+else # !LIBGO_IS_386 && !LIBGO_IS_SPARC
+# Use lseek on 64-bit Solaris.
 syscall_filesize_file = syscalls/sysfile_regfile.go
 syscall_stat_file = syscalls/sysfile_stat_regfile.go
-endif # !LIBGO_IS_386
+endif # !LIBGO_IS_386 && !LIBGO_IS_SPARC
+endif # !LIBGO_IS_SOLARIS
 else # !LIBGO_IS_LINUX && !LIBGO_IS_SOLARIS
 # Use lseek by default.
 syscall_filesize_file = syscalls/sysfile_regfile.go

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


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

2011-03-24 Thread Richard Earnshaw

On Thu, 2011-03-03 at 11:35 +, Yufeng Zhang wrote:
> 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.
> 

OK.

R.





[debug] dwarf2out emits unnecessary null byte in empty .debug_abbrev section

2011-03-24 Thread Mark Wielaard
Hi,

Detected by the elfutils dwarflint tool.

Example:
$ echo > empty.c 
$ gcc -g -c empty.c 
$ readelf -x .debug_abbrev empty.o
Hex dump of section '.debug_abbrev':
  0x 00  .

Although harmless it might add up if a project has a lot of objects without any
real debuginfo in them. There might not actually be many such projects though.

2011-03-24  Mark Wielaard  

PR debug/48041
* dwarf2out.c (output_abbrev_section): Only terminate table when
abbrev_die_table_in_use > 1.

Bootstraps fine on x86_64-gnu-linux and no regressions seen with make check -k

OK, to commit?

Thanks,

Mark

--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11084,7 +11084,8 @@ output_abbrev_section (void)
 }
 
   /* Terminate the table.  */
-  dw2_asm_output_data (1, 0, NULL);
+  if (abbrev_die_table_in_use > 1)
+dw2_asm_output_data (1, 0, NULL);
 }
 
 /* Output a symbol we can use to refer to this DIE from another CU.  */




[Ada] Change return mechanism for variable-sized constrained array types

2011-03-24 Thread Eric Botcazou
This changes the return mechanism for variable-sized constrained array types.
They used to be returned on the secondary stack, they are now returned on the
primary stack.  This is generally more efficient and, in particular, makes it
possible for the back-end to elide copies.

Tested on i586-suse-linux, applied on the mainline.


2011-03-24  Eric Botcazou  

* einfo.ads (Size_Depends_On_Discriminant): Adjust description.
* layout.adb (Compute_Size_Depends_On_Discriminant): New procedure
to compute Set_Size_Depends_On_Discriminant.
(Layout_Type): Call it on array types in back-end layout mode.
* sem_util.adb (Requires_Transient_Scope): Return true for array
types only if the size depends on the value of discriminants.
* gcc-interface/utils2.c (build_binary_op) : Use the RHS
type if the RHS is a call to a function that returns an unconstrained
type with default discriminant.


2011-03-24  Eric Botcazou  

* gnat.dg/array16.ad[sb]: New test.
* gnat.dg/array16.ads: New helper.


-- 
Eric Botcazou
Index: layout.adb
===
--- layout.adb	(revision 171345)
+++ layout.adb	(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2001-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 2001-2011, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -109,6 +109,12 @@ package body Layout is
--  are of an enumeration type (so that the subtraction cannot be
--  done directly) by applying the Pos operator to Hi/Lo first.
 
+   procedure Compute_Size_Depends_On_Discriminant (E : Entity_Id);
+   --  Given an array type or an array subtype E, compute whether its size
+   --  depends on the value of one or more discriminants and set the flag
+   --  Size_Depends_On_Discriminant accordingly. This need not be called
+   --  in front end layout mode since it does the computation on its own.
+
function Expr_From_SO_Ref
  (Loc  : Source_Ptr;
   D: SO_Ref;
@@ -1289,6 +1295,49 @@ package body Layout is
   end if;
end Layout_Array_Type;
 
+   --
+   -- Compute_Size_Depends_On_Discriminant --
+   --
+
+   procedure Compute_Size_Depends_On_Discriminant (E : Entity_Id) is
+  Indx : Node_Id;
+  Ityp : Entity_Id;
+  Lo   : Node_Id;
+  Hi   : Node_Id;
+  Res  : Boolean := False;
+   begin
+  --  Loop to process array indexes
+
+  Indx := First_Index (E);
+  while Present (Indx) loop
+ Ityp := Etype (Indx);
+
+ --  If an index of the array is a generic formal type then there is
+ --  no point in determining a size for the array type.
+
+ if Is_Generic_Type (Ityp) then
+return;
+ end if;
+
+ Lo := Type_Low_Bound (Ityp);
+ Hi := Type_High_Bound (Ityp);
+
+ if (Nkind (Lo) = N_Identifier
+   and then Ekind (Entity (Lo)) = E_Discriminant)
+   or else (Nkind (Hi) = N_Identifier
+  and then Ekind (Entity (Hi)) = E_Discriminant)
+ then
+Res := True;
+ end if;
+
+ Next_Index (Indx);
+  end loop;
+
+  if Res then
+ Set_Size_Depends_On_Discriminant (E);
+  end if;
+   end Compute_Size_Depends_On_Discriminant;
+
---
-- Layout_Object --
---
@@ -2631,6 +2680,15 @@ package body Layout is
   Set_Alignment (E, Uint_1);
end if;
 end if;
+
+--  We need to know whether the size depends on the value of one
+--  or more discriminants to select the return mechanism. Skip if
+--  errors are present, to prevent cascaded messages.
+
+if Serious_Errors_Detected = 0 then
+   Compute_Size_Depends_On_Discriminant (E);
+end if;
+
  end if;
   end if;
 
Index: einfo.ads
===
--- einfo.ads	(revision 171345)
+++ einfo.ads	(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-20

Tweak ARM vld3q and vld4q patterns

2011-03-24 Thread Richard Sandiford
The ARM vld3q and vld4q .md patterns expand into two individual vld3/vld4
instructions.  Each instruction loads half of the total elements.
The problem is that this is implemented as:

  array = vld3a (array, mem1)
  array = vld3b (array, mem2)

with "array" being an input to the _first_ load as well as the second.
This input is dead, but results in unnecessary loads from the stack.
E.g. for:

#include 

void
foo (uint32_t *a, uint32_t *b, uint32_t *c)
{
  uint32x4x3_t x, y;

  x = vld3q_u32 (a);
  y = vld3q_u32 (b);
  x.val[0] = vaddq_u32 (x.val[0], y.val[0]);
  x.val[1] = vaddq_u32 (x.val[1], y.val[1]);
  x.val[2] = vaddq_u32 (x.val[2], y.val[2]);
  vst3q_u32 (a, x);
}

we get:

stmfd   sp!, {r3, fp}
ldr r2, .L2
add fp, sp, #4
vldmia  r2, {d16-d21}
sub sp, sp, #112
vmovq11, q8  @ ti
vmovq12, q9  @ ti
vmovq13, q10  @ ti
...

where the vldmia is loading the x and y "inputs" to the two vld3q_u32s
from the corresponding stack slots.

It's true that vld?a doesn't _change_ the whole of the array,
but that doesn't matter; we no longer care what values the
other elements have.

Tested on arm-linux-gnueabi.  OK to install?

Richard


gcc/
* config/arm/neon.md (neon_vld3qa, neon_vld4qa): Remove
operand 1 and reshuffle the operands to match.
(neon_vld3, neon_vld4): Update accordingly.

Index: gcc/config/arm/neon.md
===
--- gcc/config/arm/neon.md  2011-03-24 13:47:13.0 +
+++ gcc/config/arm/neon.md  2011-03-24 15:51:59.0 +
@@ -4605,8 +4605,7 @@ (define_expand "neon_vld3"
(unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
   "TARGET_NEON"
 {
-  emit_insn (gen_neon_vld3qa (operands[0], operands[0],
-operands[1], operands[1]));
+  emit_insn (gen_neon_vld3qa (operands[0], operands[1], operands[1]));
   emit_insn (gen_neon_vld3qb (operands[0], operands[0],
 operands[1], operands[1]));
   DONE;
@@ -4614,12 +4613,11 @@ (define_expand "neon_vld3"
 
 (define_insn "neon_vld3qa"
   [(set (match_operand:CI 0 "s_register_operand" "=w")
-(unspec:CI [(mem:CI (match_operand:SI 3 "s_register_operand" "2"))
-(match_operand:CI 1 "s_register_operand" "0")
+(unspec:CI [(mem:CI (match_operand:SI 2 "s_register_operand" "1"))
 (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
UNSPEC_VLD3A))
-   (set (match_operand:SI 2 "s_register_operand" "=r")
-(plus:SI (match_dup 3)
+   (set (match_operand:SI 1 "s_register_operand" "=r")
+(plus:SI (match_dup 2)
 (const_int 24)))]
   "TARGET_NEON"
 {
@@ -4628,7 +4626,7 @@ (define_insn "neon_vld3qa"
   ops[0] = gen_rtx_REG (DImode, regno);
   ops[1] = gen_rtx_REG (DImode, regno + 4);
   ops[2] = gen_rtx_REG (DImode, regno + 8);
-  ops[3] = operands[2];
+  ops[3] = operands[1];
   output_asm_insn ("vld3.\t{%P0, %P1, %P2}, [%3]!", ops);
   return "";
 }
@@ -4897,8 +4895,7 @@ (define_expand "neon_vld4"
(unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
   "TARGET_NEON"
 {
-  emit_insn (gen_neon_vld4qa (operands[0], operands[0],
-operands[1], operands[1]));
+  emit_insn (gen_neon_vld4qa (operands[0], operands[1], operands[1]));
   emit_insn (gen_neon_vld4qb (operands[0], operands[0],
 operands[1], operands[1]));
   DONE;
@@ -4906,12 +4903,11 @@ (define_expand "neon_vld4"
 
 (define_insn "neon_vld4qa"
   [(set (match_operand:XI 0 "s_register_operand" "=w")
-(unspec:XI [(mem:XI (match_operand:SI 3 "s_register_operand" "2"))
-(match_operand:XI 1 "s_register_operand" "0")
+(unspec:XI [(mem:XI (match_operand:SI 2 "s_register_operand" "1"))
 (unspec:VQ [(const_int 0)] UNSPEC_VSTRUCTDUMMY)]
UNSPEC_VLD4A))
-   (set (match_operand:SI 2 "s_register_operand" "=r")
-(plus:SI (match_dup 3)
+   (set (match_operand:SI 1 "s_register_operand" "=r")
+(plus:SI (match_dup 2)
 (const_int 32)))]
   "TARGET_NEON"
 {
@@ -4921,7 +4917,7 @@ (define_insn "neon_vld4qa"
   ops[1] = gen_rtx_REG (DImode, regno + 4);
   ops[2] = gen_rtx_REG (DImode, regno + 8);
   ops[3] = gen_rtx_REG (DImode, regno + 12);
-  ops[4] = operands[2];
+  ops[4] = operands[1];
   output_asm_insn ("vld4.\t{%P0, %P1, %P2, %P3}, [%4]!", ops);
   return "";
 }


Re: [x32] PATCH: PR middle-end/47725: [x32] error: unable to find a register to spill in class DIREG

2011-03-24 Thread Eric Botcazou
> Pointer is promoted to Pmode from ptr_mode.

Indeed.  However the problem is the 2 in assign_parm_setup_reg:

  /* Store the parm in a pseudoregister during the function, but we may
 need to do it in a wider mode.  Using 2 here makes the result
 consistent with promote_decl_mode and thus expand_expr_real_1.  */
 promoted_nominal_mode
   = promote_function_mode (data->nominal_type, data->nominal_mode, &unsignedp,
 TREE_TYPE (current_function_decl), 2);

which is supposed to match the 2 in promote_decl_mode:

  if (TREE_CODE (decl) == RESULT_DECL
  || TREE_CODE (decl) == PARM_DECL)
pmode = promote_function_mode (type, mode, &unsignedp,
   TREE_TYPE (current_function_decl), 2);
  else
pmode = promote_mode (type, mode, &unsignedp);

but doesn't match the 0 in assign_parm_find_data_types:

  promoted_mode = promote_function_mode (passed_type, passed_mode, &unsignedp,
 TREE_TYPE (current_function_decl), 0);

so you get the redundant extension in the callee.  The solution is to define 
the promote_function_mode hook for x86 to something like:

static enum machine_mode
ix86_promote_function_mode (const_tree type,
enum machine_mode mode,
int *punsignedp,
const_tree fntype ATTRIBUTE_UNUSED,
int for_return ATTRIBUTE_UNUSED)
{
  if (POINTER_TYPE_P (type))
{
  *punsignedp = POINTERS_EXTEND_UNSIGNED;
  return Pmode;
}

  return mode;
}

-- 
Eric Botcazou


*ping* Re: [Patch, Fortran, 4.7] PR 18918 - Add initial support for a coarray communication library

2011-03-24 Thread Tobias Burnus

*ping*

http://gcc.gnu.org/ml/fortran/2011-03/msg00162.html
(RFC patch: http://gcc.gnu.org/ml/fortran/2011-03/msg3.html)

Tobias

PS: I will come back to the other emails of this week tomorrow; I am 
still recovering from a cold, which started with fever last Sunday :-(


On 19.03.2011 17:23, Tobias Burnus wrote:

Build and regtested on x86-64-linux.
(a) Is the patch OK for the 4.7 trunk?
(b) Are the libgfortrancaf.h, libgfortrancaf_mpi.c and 
libgfortrancaf_single.c OK for inclusion at libgfortran/caf?




Tighten ARM's CANNOT_CHANGE_MODE_CLASS

2011-03-24 Thread Richard Sandiford
We currently generate very poor code for tests like:

#include 

void
foo (uint32_t *a, uint32_t *b, uint32_t *c)
{
  uint32x4x3_t x, y;

  x = vld3q_u32 (a);
  y = vld3q_u32 (b);
  x.val[0] = vaddq_u32 (x.val[0], y.val[0]);
  x.val[1] = vaddq_u32 (x.val[1], y.val[1]);
  x.val[2] = vaddq_u32 (x.val[2], y.val[2]);
  vst3q_u32 (a, x);
}

This is because we force the uint32x4x3_t values to the stack and
then load and store the individual vectors.

What we actually want is for the uint32x4x3_t values to be stored
in registers, and for the individual vectors to be accessed as
subregs of those registers.  The first part involves some middle-end
mode changes (see recent gcc@ thread), while the second part requires
a change to ARM's CANNOT_CHANGE_MODE_CLASS.

CANNOT_CHANGE_MODE_CLASS is defined as:

/* FPA registers can't do subreg as all values are reformatted to internal
   precision.  VFP registers may only be accessed in the mode they
   were set.  */
#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)   \
  (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)   \
   ? reg_classes_intersect_p (FPA_REGS, (CLASS))\
 || reg_classes_intersect_p (VFP_REGS, (CLASS)) \
   : 0)

But this VFP restriction appears to apply only to VFPv1; thanks to
Peter Maydell for the archaeology.

Tested on arm-linux-gnueabi.  OK to install?

This doesn't have any direct benefit without the middle-end mode change,
but it needs to go in first in order for that change not to regress.

Richard


gcc/
* config/arm/arm.h (CANNOT_CHANGE_MODE_CLASS): Restrict FPA_REGS
case to VFPv1.

Index: gcc/config/arm/arm.h
===
--- gcc/config/arm/arm.h2011-03-24 13:47:14.0 +
+++ gcc/config/arm/arm.h2011-03-24 15:26:19.0 +
@@ -1167,12 +1167,14 @@ #define IRA_COVER_CLASSES   
 \
 }
 
 /* FPA registers can't do subreg as all values are reformatted to internal
-   precision.  VFP registers may only be accessed in the mode they
+   precision.  VFPv1 registers may only be accessed in the mode they
were set.  */
-#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)  \
-  (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)  \
-   ? reg_classes_intersect_p (FPA_REGS, (CLASS))   \
- || reg_classes_intersect_p (VFP_REGS, (CLASS))\
+#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS)  \
+  (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)  \
+   ? (reg_classes_intersect_p (FPA_REGS, (CLASS))  \
+  || (TARGET_VFP   \
+ && arm_fpu_desc->rev == 1 \
+ && reg_classes_intersect_p (VFP_REGS, (CLASS  \
: 0)
 
 /* The class value for index registers, and the one for base regs.  */


[debug] Remove deprecated DW_FORM_sig8 define

2011-03-24 Thread Mark Wielaard
Hi,

While reading through the unit type support I noticed some parts were
still using the old DW_FORM_sig8 while others used the actual
DW_FORM_ref_sig8 as used in the dwarf spec. I missed some things in a
first scan because of this, so I thought I just clean it up.

2010-03-24  Mark Wielaard  

* dwarf2.h (dwarf_form): Remove deprecated DW_FORM_sig8 define.

2011-03-24  Mark Wielaard  

* dwarf2out.c (size_of_die): Modify comment to say DW_FORM_ref_sig8.
(value_format): Use DW_FORM_ref_sig8, not DW_FORM_sig8.

binutils already only uses the new definition.
I have a similar cleanup patch for gdb.

OK, to commit?

Thanks,

Mark
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9dec3e4..41d55bf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-24  Mark Wielaard  
+
+	* dwarf2out.c (size_of_die): Modify comment to say DW_FORM_ref_sig8.
+	(value_format): Use DW_FORM_ref_sig8, not DW_FORM_sig8.
+
 2011-03-24  Richard Guenther  
 
 	PR tree-optimization/46562
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index aa6f6b6..bc05982 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10729,7 +10729,7 @@ size_of_die (dw_die_ref die)
 	case dw_val_class_die_ref:
 	  if (AT_ref_external (a))
 	{
-	  /* In DWARF4, we use DW_FORM_sig8; for earlier versions
+	  /* In DWARF4, we use DW_FORM_ref_sig8; for earlier versions
 		 we use DW_FORM_ref_addr.  In DWARF2, DW_FORM_ref_addr
 		 is sized by target address length, whereas in DWARF3
 		 it's always sized as an offset.  */
@@ -11005,7 +11005,7 @@ value_format (dw_attr_ref a)
   return DW_FORM_flag;
 case dw_val_class_die_ref:
   if (AT_ref_external (a))
-	return dwarf_version >= 4 ? DW_FORM_sig8 : DW_FORM_ref_addr;
+	return dwarf_version >= 4 ? DW_FORM_ref_sig8 : DW_FORM_ref_addr;
   else
 	return DW_FORM_ref;
 case dw_val_class_fde_ref:
diff --git a/include/ChangeLog b/include/ChangeLog
index a0585b0..4a09ab6 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-24  Mark Wielaard  
+
+	* dwarf2.h (dwarf_form): Remove deprecated DW_FORM_sig8 define.
+
 2010-03-23  Rafael Ávila de Espíndola 
 
 	* plugin-api.h (ld_plugin_get_view): New.
diff --git a/include/dwarf2.h b/include/dwarf2.h
index 46f2291..ef0fa5f 100644
--- a/include/dwarf2.h
+++ b/include/dwarf2.h
@@ -189,7 +189,6 @@ enum dwarf_form
 DW_FORM_exprloc = 0x18,
 DW_FORM_flag_present = 0x19,
 DW_FORM_ref_sig8 = 0x20
-#define DW_FORM_sig8  DW_FORM_ref_sig8  /* Note: The use of DW_FORM_sig8 is deprecated.  */
   };
 
 /* Attribute names and codes.  */


Re: [PATCH PING] fortran-specific bits of tree-slimming patches

2011-03-24 Thread Jerry DeLisle

On 03/24/2011 06:10 AM, Nathan Froyd wrote:

The Fortran-specific bits of these patches:

   [PATCH 02/18] enforce TREE_CHAIN and TREE_TYPE accesses
   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00565.html

   [PATCH 07/18] generalize build_case_label to the rest of the compiler
   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00557.html

   [PATCH 17/18] introduce block_chainon and use BLOCK_CHAIN more
   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00566.html

are still pending review.

-Nathan



gfortran parts OK.

Jerry


[Ada] Fix bogus CE raised on call to overloaded function

2011-03-24 Thread Eric Botcazou
The attached code (derived from ACATS c34006d) raises a bogus Constraint_Error 
since at least GCC 3.4:

raised CONSTRAINT_ERROR : p.adb:33 discriminant check failed

This is related to the overloading of function Create.

Tested on i586-suse-linux, applied on the mainline.


2011-03-24  Eric Botcazou  

* gcc-interface/trans.c (gnat_to_gnu): Remove obsolete case of
non-conversion to the nominal result type at the end.


2011-03-24  Eric Botcazou  

* gnat.dg/derived_type2.adb: New test.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 171345)
+++ gcc-interface/trans.c	(working copy)
@@ -5879,15 +5879,11 @@ gnat_to_gnu (Node_Id gnat_node)
 	  since we need to ignore those conversions (for 'Valid).
 
2. If we have a label (which doesn't have any well-defined type), a
-	  field or an error, return the result almost unmodified.  Also don't
-	  do the conversion if the result type involves a PLACEHOLDER_EXPR in
-	  its size since those are the cases where the front end may have the
-	  type wrong due to "instantiating" the unconstrained record with
-	  discriminant values.  Similarly, if the two types are record types
-	  with the same name don't convert.  This will be the case when we are
-	  converting from a packable version of a type to its original type and
-	  we need those conversions to be NOPs in order for assignments into
-	  these types to work properly.
+	  field or an error, return the result almost unmodified.  Similarly,
+	  if the two types are record types with the same name, don't convert.
+	  This will be the case when we are converting from a packable version
+	  of a type to its original type and we need those conversions to be
+	  NOPs in order for assignments into these types to work properly.
 
3. If the type is void or if we have no result, return error_mark_node
 	  to show we have no result.
@@ -5933,12 +5929,8 @@ gnat_to_gnu (Node_Id gnat_node)
   else if (TREE_CODE (gnu_result) == LABEL_DECL
 	   || TREE_CODE (gnu_result) == FIELD_DECL
 	   || TREE_CODE (gnu_result) == ERROR_MARK
-	   || (TYPE_SIZE (gnu_result_type)
-	   && TREE_CODE (TYPE_SIZE (gnu_result_type)) != INTEGER_CST
-	   && TREE_CODE (gnu_result) != INDIRECT_REF
-	   && CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_result_type)))
-	   || ((TYPE_NAME (gnu_result_type)
-		== TYPE_NAME (TREE_TYPE (gnu_result)))
+	   || (TYPE_NAME (gnu_result_type)
+	   == TYPE_NAME (TREE_TYPE (gnu_result))
 	   && TREE_CODE (gnu_result_type) == RECORD_TYPE
 	   && TREE_CODE (TREE_TYPE (gnu_result)) == RECORD_TYPE))
 {
-- { dg-do run }
-- { dg-options "-gnatws" }

procedure Derived_Type2 is

   package Pkg is

  type Parent (B : Boolean := True) is record
 case B is
when True => S : String (1 .. 5);
when False => F : Float;
 end case;
  end record;

  function Create (X : Parent) return Parent;

   end Pkg;

   package body Pkg is

  function Create (X : Parent) return Parent is
  begin
 return (True, "12345");
  end;

   end Pkg;

   use Pkg;

   type T is new Parent (True);

   X : T;

begin

   if Create (X).B /= True then
  raise Program_Error;
   end if;

end;


Re: Cleaning up expand optabs code

2011-03-24 Thread Richard Sandiford
This showed up as a warning during the h8300 build I did this morning.
I've no idea why it wasn't caught during the x86_64, ARM and MIPS testing.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Installed as obvious.

Richard


gcc/
* builtins.c (expand_movstr): Fix endp == 1 adjustment after
last commit.

Index: gcc/builtins.c
===
--- gcc/builtins.c  2011-03-23 09:30:17.0 +
+++ gcc/builtins.c  2011-03-24 09:08:05.0 +
@@ -3655,7 +3655,6 @@ expand_builtin_mempcpy_args (tree dest, 
 expand_movstr (tree dest, tree src, rtx target, int endp)
 {
   struct expand_operand ops[3];
-  rtx end;
   rtx dest_mem;
   rtx src_mem;
 
@@ -3683,7 +3682,7 @@ expand_movstr (tree dest, tree src, rtx 
 adjust it.  */
   if (endp == 1)
{
- rtx tem = plus_constant (gen_lowpart (GET_MODE (target), end), 1);
+ rtx tem = plus_constant (gen_lowpart (GET_MODE (target), target), 1);
  emit_move_insn (target, force_operand (tem, NULL_RTX));
}
 }


Re: [Patch ARM] PR47930 Fix documentation for marm / mthumb

2011-03-24 Thread Richard Earnshaw

On Sun, 2011-03-20 at 15:19 +, Ramana Radhakrishnan wrote:
> Hi,
> 
>   This fixes up documentation for the -marm option and changes the 
> behaviour of mthumb to reject the negative options to bring this to 
> behave similar to the marm option. The option needs to be documented 
> since we now have situations where toolchains default to Thumb state and 
> folks need a way of overriding this. I would like a review of this 
> before committing it since this is a change to the command line options.
> 
> Tested by building a cross toolchain to arm-linux-gnueabi and verified 
> that -mno-thumb is rejected and looking up the documentation after it 
> was rebuilt.
> 
> Ok ?
> 
> cheers
> Ramana
> 
> 
> 2011-03-20  Ramana Radhakrishnan  
> 
>   PR target/47930
>   * config/arm/arm.opt (marm): Document it.
>   (mthumb): Reject negative variant.

+@item -marm
+@opindex marm
+Generate code for the 32 bit ARM instruction set. This is used to 
+override and generate code in ARM state if the compiler has been 
+configured to be built in Thumb state.  This option is not passed to
the
+assembler. 

I'd suggest

@item -mthumb
@itemx -marm
@opindex marm
@opindex mthumb

Select between generating code that executes in ARM and Thumb
states.  The default for most configurations is to generate code
that executes in ARM state, but the default can be changed by
configuring GCC with the @option{--with-mode=}@var{state}
configure option.

I don't see any need to talk about the Thumb1/Thumb2 behaviour here any
more than we do about other ISA variants in ARM state.  Nor do I think
it's relevant to talk about this option in relation to the assembler.

The arm.opt change is OK, but 'Report' should stay; and it should also
be added to the -marm case.

R.




Re: Cleaning up expand optabs code

2011-03-24 Thread Richard Sandiford
Richard Sandiford  writes:
> Andreas Krebbel  writes:
>> On 03/22/2011 06:48 PM, Richard Henderson wrote:
>>
>>> Ok.  Watch out for other target problems this week.
>>
>> This unfortunately broke bootstrap on s390.
>
> This is PR 48263.  Since it seems to be affecting several targets,
> and since my bootstrap seems to be taking a looong time, I'll post
> the patch here before testing has finished.

Bootstrap & regression-test on x86_64-linux-gnu now finished.  OK to install?

>> Just copying the pre-patch behaviour fixes the problem for me:
>
> I think we need to undo more of the patch, and leave the conversion
> outside of the new interface.
>
> Sorry for the breakage.
>
> Richard
>
>
> gcc/
>   PR rtl-optimization/48263
>   * optabs.c (expand_binop_directly): Reinstate convert_modes code
>   and original commutative_p handling.  Use maybe_gen_insn.
>
> Index: gcc/optabs.c
> ===
> --- gcc/optabs.c  2011-03-24 09:18:00.0 +
> +++ gcc/optabs.c  2011-03-24 09:36:46.0 +
> @@ -1269,6 +1269,38 @@ expand_binop_directly (enum machine_mode
>if (!shift_optab_p (binoptab))
>  xop1 = avoid_expensive_constant (mode1, binoptab, xop1, unsignedp);
>  
> +  /* In case the insn wants input operands in modes different from
> + those of the actual operands, convert the operands.  It would
> + seem that we don't need to convert CONST_INTs, but we do, so
> + that they're properly zero-extended, sign-extended or truncated
> + for their mode.  */
> +
> +  if (GET_MODE (xop0) != mode0 && mode0 != VOIDmode)
> +xop0 = convert_modes (mode0,
> +   GET_MODE (xop0) != VOIDmode
> +   ? GET_MODE (xop0)
> +   : mode,
> +   xop0, unsignedp);
> +
> +  if (GET_MODE (xop1) != mode1 && mode1 != VOIDmode)
> +xop1 = convert_modes (mode1,
> +   GET_MODE (xop1) != VOIDmode
> +   ? GET_MODE (xop1)
> +   : mode,
> +   xop1, unsignedp);
> +
> +  /* If operation is commutative,
> + try to make the first operand a register.
> + Even better, try to make it the same as the target.
> + Also try to make the last operand a constant.  */
> +  if (commutative_p
> +  && swap_commutative_operands_with_target (target, xop0, xop1))
> +{
> +  swap = xop1;
> +  xop1 = xop0;
> +  xop0 = swap;
> +}
> +
>/* Now, if insn's predicates don't allow our operands, put them into
>   pseudo regs.  */
>  
> @@ -1291,41 +1323,25 @@ expand_binop_directly (enum machine_mode
>  tmp_mode = mode;
>  
>create_output_operand (&ops[0], target, tmp_mode);
> -  create_convert_operand_from (&ops[1], xop0, mode, unsignedp);
> -  create_convert_operand_from (&ops[2], xop1, mode, unsignedp);
> -  if (maybe_legitimize_operands (icode, 0, 3, ops))
> -{
> -  /* If operation is commutative,
> -  try to make the first operand a register.
> -  Even better, try to make it the same as the target.
> -  Also try to make the last operand a constant.  */
> -  if (commutative_p
> -   && swap_commutative_operands_with_target (ops[0].value, ops[1].value,
> - ops[2].value))
> - {
> -   swap = ops[2].value;
> -   ops[2].value = ops[1].value;
> -   ops[1].value = swap;
> - }
> -
> -  pat = GEN_FCN (icode) (ops[0].value, ops[1].value, ops[2].value);
> -  if (pat)
> +  create_input_operand (&ops[1], xop0, mode0);
> +  create_input_operand (&ops[2], xop1, mode1);
> +  pat = maybe_gen_insn (icode, 3, ops);
> +  if (pat)
> +{
> +  /* If PAT is composed of more than one insn, try to add an appropriate
> +  REG_EQUAL note to it.  If we can't because TEMP conflicts with an
> +  operand, call expand_binop again, this time without a target.  */
> +  if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
> +   && ! add_equal_note (pat, ops[0].value, binoptab->code,
> +ops[1].value, ops[2].value))
>   {
> -   /* If PAT is composed of more than one insn, try to add an appropriate
> -  REG_EQUAL note to it.  If we can't because TEMP conflicts with an
> -  operand, call expand_binop again, this time without a target.  */
> -   if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX
> -   && ! add_equal_note (pat, ops[0].value, binoptab->code,
> -ops[1].value, ops[2].value))
> - {
> -   delete_insns_since (last);
> -   return expand_binop (mode, binoptab, op0, op1, NULL_RTX,
> -unsignedp, methods);
> - }
> -
> -   emit_insn (pat);
> -   return ops[0].value;
> +   delete_insns_since (last);
> +   return expand_binop (mode, binoptab, op0, op1, NULL_RTX,
> +unsignedp, meth

[rs6000] Fix thinko in output_profile_hook

2011-03-24 Thread Eric Botcazou
Hi,

the problematic line is:

label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));

On AIX, rs6000_xcoff_strip_name_encoding can return NAME + 1:

static const char *
rs6000_xcoff_strip_name_encoding (const char *name)
{
  size_t len;
  if (*name == '*')
name++;
  len = strlen (name);
  if (name[len - 1] == ']')
return ggc_alloc_string (name, len - 4);
  else
return name;
}

which means that you can have (ADDR + 1) in some GC tree and gt_ggc_m_S choke:

  if (offset)
{
  /* Here we've seen a char* which does not point to the beginning
 of an allocated object.  We assume it points to the middle of
 a STRING_CST.  */
  gcc_assert (offset == offsetof (struct tree_string, str));
  p = ((const char *) p) - offset;
  gt_ggc_mx_lang_tree_node (CONST_CAST (void *, p));
  return;
}

Tested on AIX, OK for the mainline?


2011-03-24  Eric Botcazou  

* config/rs6000/rs6000.c (output_profile_hook): Fix thinko.


-- 
Eric Botcazou
Index: config/rs6000/rs6000.c
===
--- config/rs6000/rs6000.c	(revision 171345)
+++ config/rs6000/rs6000.c	(working copy)
@@ -23002,7 +23002,7 @@ output_profile_hook (int labelno ATTRIBU
 	  rtx fun;
 
 	  ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
-	  label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf));
+	  label_name = ggc_strdup ((*targetm.strip_name_encoding) (buf));
 	  fun = gen_rtx_SYMBOL_REF (Pmode, label_name);
 
 	  emit_library_call (init_one_libfunc (RS6000_MCOUNT),


Re: [PATCH] fix memory accounting for copying nodes

2011-03-24 Thread Richard Guenther
On Thu, Mar 24, 2011 at 3:46 PM, Nathan Froyd  wrote:
> tree.c can gather optionally statistics--counts and total bytes
> allocated--when tree nodes are created.  Due to an oversight, however,
> this accounting is not performed when nodes are copied.  The patch below
> corrects this oversight and moves things around so the accounting is
> done in (almost) only one place.  (The "almost" is due to special
> decrementing when we reuse types, which is arguably bogus, since we've
> created a node already, so we shouldn't be playing games to pretend we
> didn't touch memory.)
>
> Tested on x86_64-unknown-linux-gnu, with and without
> --enable-gather-detailed-mem-stats.  OK to commit?

Ok.

Thanks,
Richard.

> -Nathan
>
>        * tree.c (record_node_allocation_statistics): New function.
>        (make_node_stat, copy_node_stat, build_string): Call it.
>        (make_tree_binfo_stat, make_tree_vec_stat, tree_cons_stat): Likewise.
>        (build1_stat, build_omp_clause): Likewise.
>
> diff --git a/gcc/tree.c b/gcc/tree.c
> index efa51bd..2066c84 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -769,20 +769,15 @@ tree_size (const_tree node)
>     }
>  }
>
> -/* Return a newly allocated node of code CODE.  For decl and type
> -   nodes, some other fields are initialized.  The rest of the node is
> -   initialized to zero.  This function cannot be used for TREE_VEC or
> -   OMP_CLAUSE nodes, which is enforced by asserts in tree_code_size.
> +/* Record interesting allocation statistics for a tree node with CODE
> +   and LENGTH.  */
>
> -   Achoo!  I got a code in the node.  */
> -
> -tree
> -make_node_stat (enum tree_code code MEM_STAT_DECL)
> +static void
> +record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED,
> +                                  size_t length ATTRIBUTE_UNUSED)
>  {
> -  tree t;
> -  enum tree_code_class type = TREE_CODE_CLASS (code);
> -  size_t length = tree_code_size (code);
>  #ifdef GATHER_STATISTICS
> +  enum tree_code_class type = TREE_CODE_CLASS (code);
>   tree_node_kind kind;
>
>   switch (type)
> @@ -841,12 +836,20 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
>          kind = constr_kind;
>          break;
>
> +       case OMP_CLAUSE:
> +         kind = omp_clause_kind;
> +         break;
> +
>        default:
>          kind = x_kind;
>          break;
>        }
>       break;
>
> +    case tcc_vl_exp:
> +      kind = e_kind;
> +      break;
> +
>     default:
>       gcc_unreachable ();
>     }
> @@ -854,6 +857,23 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
>   tree_node_counts[(int) kind]++;
>   tree_node_sizes[(int) kind] += length;
>  #endif
> +}
> +
> +/* Return a newly allocated node of code CODE.  For decl and type
> +   nodes, some other fields are initialized.  The rest of the node is
> +   initialized to zero.  This function cannot be used for TREE_VEC or
> +   OMP_CLAUSE nodes, which is enforced by asserts in tree_code_size.
> +
> +   Achoo!  I got a code in the node.  */
> +
> +tree
> +make_node_stat (enum tree_code code MEM_STAT_DECL)
> +{
> +  tree t;
> +  enum tree_code_class type = TREE_CODE_CLASS (code);
> +  size_t length = tree_code_size (code);
> +
> +  record_node_allocation_statistics (code, length);
>
>   t = ggc_alloc_zone_cleared_tree_node_stat (
>                (code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone,
> @@ -950,6 +970,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
>   gcc_assert (code != STATEMENT_LIST);
>
>   length = tree_size (node);
> +  record_node_allocation_statistics (code, length);
>   t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
>   memcpy (t, node, length);
>
> @@ -1540,10 +1561,7 @@ build_string (int len, const char *str)
>   /* Do not waste bytes provided by padding of struct tree_string.  */
>   length = len + offsetof (struct tree_string, str) + 1;
>
> -#ifdef GATHER_STATISTICS
> -  tree_node_counts[(int) c_kind]++;
> -  tree_node_sizes[(int) c_kind] += length;
> -#endif
> +  record_node_allocation_statistics (STRING_CST, length);
>
>   s = ggc_alloc_tree_node (length);
>
> @@ -1663,10 +1681,7 @@ make_tree_binfo_stat (unsigned base_binfos 
> MEM_STAT_DECL)
>   size_t length = (offsetof (struct tree_binfo, base_binfos)
>                   + VEC_embedded_size (tree, base_binfos));
>
> -#ifdef GATHER_STATISTICS
> -  tree_node_counts[(int) binfo_kind]++;
> -  tree_node_sizes[(int) binfo_kind] += length;
> -#endif
> +  record_node_allocation_statistics (TREE_BINFO, length);
>
>   t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
>
> @@ -1688,10 +1703,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
>   tree t;
>   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
>
> -#ifdef GATHER_STATISTICS
> -  tree_node_counts[(int) vec_kind]++;
> -  tree_node_sizes[(int) vec_kind] += length;
> -#endif
> +  record_node_allocation_statistics (TREE_VEC, length);
>
>   t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length 
> PASS_MEM_STAT);
>

Re: [patch] Preserve source location in folder

2011-03-24 Thread Richard Guenther
On Thu, Mar 24, 2011 at 3:38 PM, Eric Botcazou  wrote:
> Hi,
>
> when fold_ternary_loc is attempting to make the tree prettier, e.g. by 
> swapping
> the arguments of a COND_EXPR, it does:
>
>  tem = fold_truth_not_expr (loc, arg0);
>
> Now LOC is the location that will be put on the whole expression and there is
> no reason it should override the location of ARG0, if any, when inverting it.
> The attached patch only ensures that - this gives more precise coverage info.
>
> Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?

Ok.

(I shortly thought about a PREFER_OVER_UNKNOWN_LOCATION
(maybe_unknown, loc) macro, but well ...)

Thanks,
Richard.

>
> 2011-03-24  Eric Botcazou  
>
>        * fold-const.c (fold_ternary_loc): Preserve the location (if any) of
>        the argument in calls to fold_truth_not_expr.
>
>
> --
> Eric Botcazou
>


Re: Fix more minor issues from static checkers

2011-03-24 Thread Diego Novillo
On Thu, Mar 24, 2011 at 10:37, Jeff Law  wrote:

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

OK.


Diego.


[PATCH] fix memory accounting for copying nodes

2011-03-24 Thread Nathan Froyd
tree.c can gather optionally statistics--counts and total bytes
allocated--when tree nodes are created.  Due to an oversight, however,
this accounting is not performed when nodes are copied.  The patch below
corrects this oversight and moves things around so the accounting is
done in (almost) only one place.  (The "almost" is due to special
decrementing when we reuse types, which is arguably bogus, since we've
created a node already, so we shouldn't be playing games to pretend we
didn't touch memory.)

Tested on x86_64-unknown-linux-gnu, with and without
--enable-gather-detailed-mem-stats.  OK to commit?

-Nathan

* tree.c (record_node_allocation_statistics): New function.
(make_node_stat, copy_node_stat, build_string): Call it.
(make_tree_binfo_stat, make_tree_vec_stat, tree_cons_stat): Likewise.
(build1_stat, build_omp_clause): Likewise.

diff --git a/gcc/tree.c b/gcc/tree.c
index efa51bd..2066c84 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -769,20 +769,15 @@ tree_size (const_tree node)
 }
 }
 
-/* Return a newly allocated node of code CODE.  For decl and type
-   nodes, some other fields are initialized.  The rest of the node is
-   initialized to zero.  This function cannot be used for TREE_VEC or
-   OMP_CLAUSE nodes, which is enforced by asserts in tree_code_size.
+/* Record interesting allocation statistics for a tree node with CODE
+   and LENGTH.  */
 
-   Achoo!  I got a code in the node.  */
-
-tree
-make_node_stat (enum tree_code code MEM_STAT_DECL)
+static void
+record_node_allocation_statistics (enum tree_code code ATTRIBUTE_UNUSED,
+  size_t length ATTRIBUTE_UNUSED)
 {
-  tree t;
-  enum tree_code_class type = TREE_CODE_CLASS (code);
-  size_t length = tree_code_size (code);
 #ifdef GATHER_STATISTICS
+  enum tree_code_class type = TREE_CODE_CLASS (code);
   tree_node_kind kind;
 
   switch (type)
@@ -841,12 +836,20 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
  kind = constr_kind;
  break;
 
+   case OMP_CLAUSE:
+ kind = omp_clause_kind;
+ break;
+
default:
  kind = x_kind;
  break;
}
   break;
 
+case tcc_vl_exp:
+  kind = e_kind;
+  break;
+
 default:
   gcc_unreachable ();
 }
@@ -854,6 +857,23 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
   tree_node_counts[(int) kind]++;
   tree_node_sizes[(int) kind] += length;
 #endif
+}
+
+/* Return a newly allocated node of code CODE.  For decl and type
+   nodes, some other fields are initialized.  The rest of the node is
+   initialized to zero.  This function cannot be used for TREE_VEC or
+   OMP_CLAUSE nodes, which is enforced by asserts in tree_code_size.
+
+   Achoo!  I got a code in the node.  */
+
+tree
+make_node_stat (enum tree_code code MEM_STAT_DECL)
+{
+  tree t;
+  enum tree_code_class type = TREE_CODE_CLASS (code);
+  size_t length = tree_code_size (code);
+
+  record_node_allocation_statistics (code, length);
 
   t = ggc_alloc_zone_cleared_tree_node_stat (
(code == IDENTIFIER_NODE) ? &tree_id_zone : &tree_zone,
@@ -950,6 +970,7 @@ copy_node_stat (tree node MEM_STAT_DECL)
   gcc_assert (code != STATEMENT_LIST);
 
   length = tree_size (node);
+  record_node_allocation_statistics (code, length);
   t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
   memcpy (t, node, length);
 
@@ -1540,10 +1561,7 @@ build_string (int len, const char *str)
   /* Do not waste bytes provided by padding of struct tree_string.  */
   length = len + offsetof (struct tree_string, str) + 1;
 
-#ifdef GATHER_STATISTICS
-  tree_node_counts[(int) c_kind]++;
-  tree_node_sizes[(int) c_kind] += length;
-#endif
+  record_node_allocation_statistics (STRING_CST, length);
 
   s = ggc_alloc_tree_node (length);
 
@@ -1663,10 +1681,7 @@ make_tree_binfo_stat (unsigned base_binfos MEM_STAT_DECL)
   size_t length = (offsetof (struct tree_binfo, base_binfos)
   + VEC_embedded_size (tree, base_binfos));
 
-#ifdef GATHER_STATISTICS
-  tree_node_counts[(int) binfo_kind]++;
-  tree_node_sizes[(int) binfo_kind] += length;
-#endif
+  record_node_allocation_statistics (TREE_BINFO, length);
 
   t = ggc_alloc_zone_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
@@ -1688,10 +1703,7 @@ make_tree_vec_stat (int len MEM_STAT_DECL)
   tree t;
   int length = (len - 1) * sizeof (tree) + sizeof (struct tree_vec);
 
-#ifdef GATHER_STATISTICS
-  tree_node_counts[(int) vec_kind]++;
-  tree_node_sizes[(int) vec_kind] += length;
-#endif
+  record_node_allocation_statistics (TREE_VEC, length);
 
   t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
 
@@ -2229,10 +2241,7 @@ tree_cons_stat (tree purpose, tree value, tree chain 
MEM_STAT_DECL)
 PASS_MEM_STAT);
   memset (node, 0, sizeof (struct tree_common));
 
-#ifdef GATHER_STATISTICS
-  tree_node_counts[(int) x_kind]++;
-  tree_node_sizes[(int)

[patch] Do not generate useless branches for multi-word comparison

2011-03-24 Thread Eric Botcazou
Hi,

this improves the RTL generated for multi-word comparison to avoid generating 
useless branches.  In do_jump_by_parts_greater_rtx:
  1) do not generate the last cond jump,
  2) do not generate the uncond branch to the drop-through label, if any,
  3) generate only one comparison for the special (0 > x) case.

Tested on i586-suse-linux, OK for the mainline?


2011-03-24  Eric Botcazou  

* dojump.c (do_jump_by_parts_greater_rtx): Optimize in specific cases.


-- 
Eric Botcazou
Index: dojump.c
===
--- dojump.c	(revision 171345)
+++ dojump.c	(working copy)
@@ -637,14 +637,32 @@ do_jump_by_parts_greater_rtx (enum machi
 {
   int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD);
   rtx drop_through_label = 0;
+  bool drop_through_if_true = false, drop_through_if_false = false;
+  enum rtx_code code = GT;
   int i;
 
   if (! if_true_label || ! if_false_label)
 drop_through_label = gen_label_rtx ();
   if (! if_true_label)
-if_true_label = drop_through_label;
+{
+  if_true_label = drop_through_label;
+  drop_through_if_true = true;
+}
   if (! if_false_label)
-if_false_label = drop_through_label;
+{
+  if_false_label = drop_through_label;
+  drop_through_if_false = true;
+}
+
+  /* Deal with the special case 0 > x: only one comparison is necessary and
+ we reverse it to avoid jumping to the drop-through label.  */
+  if (op0 == const0_rtx && drop_through_if_true && !drop_through_if_false)
+{
+  code = LE;
+  if_true_label = if_false_label;
+  if_false_label = drop_through_label;
+  drop_through_if_false = true;
+}
 
   /* Compare a word at a time, high order first.  */
   for (i = 0; i < nwords; i++)
@@ -663,17 +681,20 @@ do_jump_by_parts_greater_rtx (enum machi
 }
 
   /* All but high-order word must be compared as unsigned.  */
-  do_compare_rtx_and_jump (op0_word, op1_word, GT,
-   (unsignedp || i > 0), word_mode, NULL_RTX,
-			   NULL_RTX, if_true_label, prob);
+  do_compare_rtx_and_jump (op0_word, op1_word, code, (unsignedp || i > 0),
+			   word_mode, NULL_RTX, NULL_RTX, if_true_label,
+			   prob);
+
+  /* Emit only one comparison for 0.  Do not emit the last cond jump.  */
+  if (op0 == const0_rtx || i == nwords - 1)
+	break;
 
   /* Consider lower words only if these are equal.  */
   do_compare_rtx_and_jump (op0_word, op1_word, NE, unsignedp, word_mode,
-			   NULL_RTX, NULL_RTX, if_false_label,
-			   inv (prob));
+			   NULL_RTX, NULL_RTX, if_false_label, inv (prob));
 }
 
-  if (if_false_label)
+  if (!drop_through_if_false)
 emit_jump (if_false_label);
   if (drop_through_label)
 emit_label (drop_through_label);


[patch] Preserve source location in folder

2011-03-24 Thread Eric Botcazou
Hi,

when fold_ternary_loc is attempting to make the tree prettier, e.g. by swapping 
the arguments of a COND_EXPR, it does:

  tem = fold_truth_not_expr (loc, arg0);

Now LOC is the location that will be put on the whole expression and there is 
no reason it should override the location of ARG0, if any, when inverting it.
The attached patch only ensures that - this gives more precise coverage info.

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


2011-03-24  Eric Botcazou  

* fold-const.c (fold_ternary_loc): Preserve the location (if any) of
the argument in calls to fold_truth_not_expr.


-- 
Eric Botcazou
Index: fold-const.c
===
--- fold-const.c	(revision 171345)
+++ fold-const.c	(working copy)
@@ -13327,7 +13327,10 @@ fold_ternary_loc (location_t loc, enum t
 	 TREE_OPERAND (arg0, 1))
 	  && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op2
 	{
-	  tem = fold_truth_not_expr (loc, arg0);
+	  location_t loc0 = EXPR_LOCATION (arg0);
+	  if (loc0 == UNKNOWN_LOCATION)
+	loc0 = loc;
+	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem && COMPARISON_CLASS_P (tem))
 	{
 	  tem = fold_cond_expr_with_comparison (loc, type, tem, op2, op1);
@@ -13341,10 +13344,13 @@ fold_ternary_loc (location_t loc, enum t
   if (truth_value_p (TREE_CODE (arg0))
 	  && tree_swap_operands_p (op1, op2, false))
 	{
+	  location_t loc0 = EXPR_LOCATION (arg0);
+	  if (loc0 == UNKNOWN_LOCATION)
+	loc0 = loc;
 	  /* See if this can be inverted.  If it can't, possibly because
 	 it was a floating-point inequality comparison, don't do
 	 anything.  */
-	  tem = fold_truth_not_expr (loc, arg0);
+	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)
 	return fold_build3_loc (loc, code, type, tem, op2, op1);
 	}
@@ -13489,8 +13495,11 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (arg1)))
 	{
+	  location_t loc0 = EXPR_LOCATION (arg0);
+	  if (loc0 == UNKNOWN_LOCATION)
+	loc0 = loc;
 	  /* Only perform transformation if ARG0 is easily inverted.  */
-	  tem = fold_truth_not_expr (loc, arg0);
+	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)
 	return fold_build2_loc (loc, TRUTH_ORIF_EXPR, type,
 fold_convert_loc (loc, type, tem),
@@ -13502,8 +13511,11 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (op2)))
 	{
+	  location_t loc0 = EXPR_LOCATION (arg0);
+	  if (loc0 == UNKNOWN_LOCATION)
+	loc0 = loc;
 	  /* Only perform transformation if ARG0 is easily inverted.  */
-	  tem = fold_truth_not_expr (loc, arg0);
+	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)
 	return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
 fold_convert_loc (loc, type, tem),


[PATCH] Paper over(?) PR48271

2011-03-24 Thread Richard Guenther

This maybe papers over PR48271, we're modifying the CFG and yet
marking some BBs for cleanup.  Well, at least the jump-threading
case is supposed to work this way.  DOM doesn't deserve too much
love, so ...

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-03-24  Richard Guenther  

PR tree-optimization/48271
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Only cleanup
blocks that still exist.

* g++.dg/torture/pr48271.C: New testcase.

Index: gcc/tree-ssa-dom.c
===
*** gcc/tree-ssa-dom.c  (revision 171387)
--- gcc/tree-ssa-dom.c  (working copy)
*** tree_ssa_dominator_optimize (void)
*** 701,707 
  gimple_stmt_iterator gsi;
  basic_block bb;
  FOR_EACH_BB (bb)
!   {for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  update_stmt_if_modified (gsi_stmt (gsi));
}
}
--- 701,708 
  gimple_stmt_iterator gsi;
  basic_block bb;
  FOR_EACH_BB (bb)
!   {
!   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
  update_stmt_if_modified (gsi_stmt (gsi));
}
}
*** tree_ssa_dominator_optimize (void)
*** 734,740 
EXECUTE_IF_SET_IN_BITMAP (need_eh_cleanup, 0, i, bi)
{
  basic_block bb = BASIC_BLOCK (i);
! if (single_succ_p (bb) == 1
  && (single_succ_edge (bb)->flags & EDGE_EH) == 0)
{
  bitmap_clear_bit (need_eh_cleanup, i);
--- 735,742 
EXECUTE_IF_SET_IN_BITMAP (need_eh_cleanup, 0, i, bi)
{
  basic_block bb = BASIC_BLOCK (i);
! if (bb
! && single_succ_p (bb)
  && (single_succ_edge (bb)->flags & EDGE_EH) == 0)
{
  bitmap_clear_bit (need_eh_cleanup, i);
Index: gcc/testsuite/g++.dg/torture/pr48271.C
===
*** gcc/testsuite/g++.dg/torture/pr48271.C  (revision 0)
--- gcc/testsuite/g++.dg/torture/pr48271.C  (revision 0)
***
*** 0 
--- 1,119 
+ // { dg-do compile }
+ // { dg-options "-ftree-vrp -fno-guess-branch-probability 
-fnon-call-exceptions" }
+ 
+ void *xalloc ();
+ void xfree (void *);
+ void error ();
+ 
+ static inline void *
+ MallocT ()
+ {
+   void *p = xalloc ();
+   if (!p)
+ error ();
+   return p;
+ }
+ 
+ 
+ struct ByteBlob
+ {
+   int *header;
+ 
+   ByteBlob();
+ 
+   ~ByteBlob ()
+   {
+ Free ();
+   }
+ 
+   int RawFree (int * p)
+   {
+ if (!p)
+   error ();
+ xfree (p);
+   }
+ 
+   int *LengthRef ();
+ 
+   void Free ()
+   {
+ if (*header)
+   RawFree (header);
+   }
+ 
+   int Append (int num_ints)
+   {
+ if (*header)
+   MallocT ();
+ *LengthRef () += num_ints;
+   }
+ };
+ 
+ struct CBlobT:ByteBlob
+ {
+   ~CBlobT ()
+   {
+ Free ();
+   }
+ };
+ 
+ template < class T > struct FixedSizeArray
+ {
+   int HeaderSize;
+   T *data;
+   FixedSizeArray ();
+   int RefCnt ()
+   {
+ return *(int *) MallocT ();
+   }
+~FixedSizeArray ()
+   {
+ if (RefCnt ())
+   for (T * pItem = data + Length (); pItem != data; pItem--)
+   T ();
+   }
+   int Length ();
+ };
+ 
+ class SmallArray
+ {
+   typedef FixedSizeArray < int > SubArray;
+   typedef FixedSizeArray < SubArray > SuperArray;
+   SuperArray data;
+ };
+ 
+ struct CHashTableT
+ {
+   int *m_slots;
+   ~CHashTableT ()
+   {
+ delete m_slots;
+   }
+ };
+ 
+ struct CYapfBaseT
+ {
+   int *PfGetSettings ();
+   SmallArray m_arr;
+   CHashTableT m_closed;
+   CYapfBaseT ()
+   {
+ MallocT ();
+   }
+ };
+ 
+ struct CYapfCostRailT:CYapfBaseT
+ {
+   CBlobT m_sig_look_ahead_costs;
+   CYapfCostRailT ()
+   {
+ m_sig_look_ahead_costs.Append (*Yapf ()->PfGetSettings ());
+ Yapf ()->PfGetSettings ();
+   }
+   CYapfBaseT *Yapf ();
+ };
+ 
+ void stCheckReverseTrain ()
+ {
+   CYapfCostRailT pf1;
+ }


[PATCH] Fix PR48270

2011-03-24 Thread Richard Guenther

Bootstrapped and tested on x86_64-unknonw-linux-gnu, applied.

Richard.

2011-03-24  Richard Guenther  

PR tree-optimization/48270
* tree-ssa-phiopt.c (cond_if_else_store_replacement): Do
not free datarefs before ddrs.

Index: gcc/tree-ssa-phiopt.c
===
--- gcc/tree-ssa-phiopt.c   (revision 171388)
+++ gcc/tree-ssa-phiopt.c   (working copy)
@@ -1494,8 +1494,6 @@ cond_if_else_store_replacement (basic_bl
   else_ddrs = VEC_alloc (ddr_p, heap, 1);
   compute_all_dependences (then_datarefs, &then_ddrs, NULL, false);
   compute_all_dependences (else_datarefs, &else_ddrs, NULL, false);
-  free_data_refs (then_datarefs);
-  free_data_refs (else_datarefs);
   blocks[0] = then_bb;
   blocks[1] = else_bb;
   blocks[2] = join_bb;
@@ -1517,6 +1515,8 @@ cond_if_else_store_replacement (basic_bl
 {
   free_dependence_relations (then_ddrs);
   free_dependence_relations (else_ddrs);
+ free_data_refs (then_datarefs);
+ free_data_refs (else_datarefs);
   VEC_free (gimple, heap, then_stores);
   VEC_free (gimple, heap, else_stores);
   return false;
@@ -1539,6 +1539,8 @@ cond_if_else_store_replacement (basic_bl
 {
   free_dependence_relations (then_ddrs);
   free_dependence_relations (else_ddrs);
+ free_data_refs (then_datarefs);
+ free_data_refs (else_datarefs);
   VEC_free (gimple, heap, then_stores);
   VEC_free (gimple, heap, else_stores);
   return false;
@@ -1556,6 +1558,8 @@ cond_if_else_store_replacement (basic_bl
 
   free_dependence_relations (then_ddrs);
   free_dependence_relations (else_ddrs);
+  free_data_refs (then_datarefs);
+  free_data_refs (else_datarefs);
   VEC_free (gimple, heap, then_stores);
   VEC_free (gimple, heap, else_stores);
 


Fix more minor issues from static checkers

2011-03-24 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


First in tree-ssa-live.c, "ann" is set, but never used in a couple places.

Second, in tree-ssa-copy.c we set "stmt" in
propagate_tree_value_into_stmt, but never use it.  Removing the
assignment is obviously trivial.

Finally, in cfglayout force_nonfallthru may delete its argument (E_FALL)
which we then use.  The fix is to save E_FALL->src prior to the call to
force_nonfallthru.

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

Thanks,
Jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNi1dDAAoJEBRtltQi2kC7b8kIAIsiwpn3FieHNWhn5RGFdn85
mXoknFh9Ybc71XOKU80UAWCxX61iCImJoqKJNdAEi1S4KLRboKIzEv2OrNjNbt4r
c8EO8K8Q42NJ3IcinbHuqWK9KxhRuWso2w4VEMVS8gOHgSl12PA2C2LYMWLXa0l5
EgNNta6HWCD1uC8EL7Zt+3vMLRY7Ru+bVbR1T58miRe9CatK5Iz85T3FZ0qfPr4z
Lp8aHCPcRQlabqgk2Thr/cexK3ZdTFXdHP+F3e60GlPEB7Y0nbwrZIvHW+RWj2z0
Et4wEEUnrCXbqJMaZgrHaOl5lierXKMy2FPc/tMSrUO6kw920Y8PzNMQweP4QSE=
=cYgV
-END PGP SIGNATURE-
* tree-ssa-live.c (remove_unused_scope_block_p): Remove set but
unused variable "ann".
(remove_unused_locals): Likewise.

* tree-ssa-copy.c (propagate_tree_value_into_stmt): Remove useless
statement.

* cfglayout.c (fixup_reorder_chain): Do not dereference E_FALL
after it is freed.

Index: tree-ssa-live.c
===
*** tree-ssa-live.c (revision 171351)
--- tree-ssa-live.c (working copy)
*** remove_unused_scope_block_p (tree scope)
*** 427,433 
  {
tree *t, *next;
bool unused = !TREE_USED (scope);
-   var_ann_t ann;
int nsubblocks = 0;
  
for (t = &BLOCK_VARS (scope); *t; t = next)
--- 427,432 
*** remove_unused_scope_block_p (tree scope)
*** 467,474 
 info about optimized-out variables in the scope blocks.
 Exception are the scope blocks not containing any instructions
 at all so user can't get into the scopes at first place.  */
!   else if ((ann = var_ann (*t)) != NULL
!  && is_used_p (*t))
unused = false;
else if (TREE_CODE (*t) == LABEL_DECL && TREE_USED (*t))
/* For labels that are still used in the IL, the decision to
--- 466,472 
 info about optimized-out variables in the scope blocks.
 Exception are the scope blocks not containing any instructions
 at all so user can't get into the scopes at first place.  */
!   else if (var_ann (*t) != NULL && is_used_p (*t))
unused = false;
else if (TREE_CODE (*t) == LABEL_DECL && TREE_USED (*t))
/* For labels that are still used in the IL, the decision to
*** remove_unused_locals (void)
*** 690,696 
basic_block bb;
tree var, t;
referenced_var_iterator rvi;
-   var_ann_t ann;
bitmap global_unused_vars = NULL;
unsigned srcidx, dstidx, num;
  
--- 688,693 
*** remove_unused_locals (void)
*** 766,772 
  {
var = VEC_index (tree, cfun->local_decls, srcidx);
if (TREE_CODE (var) != FUNCTION_DECL
! && (!(ann = var_ann (var))
  || !is_used_p (var)))
{
  if (is_global_var (var))
--- 763,769 
  {
var = VEC_index (tree, cfun->local_decls, srcidx);
if (TREE_CODE (var) != FUNCTION_DECL
! && (!var_ann (var)
  || !is_used_p (var)))
{
  if (is_global_var (var))
*** remove_unused_locals (void)
*** 798,804 
FOR_EACH_LOCAL_DECL (cfun, ix, var)
if (TREE_CODE (var) == VAR_DECL
&& is_global_var (var)
!   && (ann = var_ann (var)) != NULL
&& is_used_p (var))
  mark_all_vars_used (&DECL_INITIAL (var), global_unused_vars);
  
--- 795,801 
FOR_EACH_LOCAL_DECL (cfun, ix, var)
if (TREE_CODE (var) == VAR_DECL
&& is_global_var (var)
!   && var_ann (var) != NULL
&& is_used_p (var))
  mark_all_vars_used (&DECL_INITIAL (var), global_unused_vars);
  
Index: tree-ssa-copy.c
===
*** tree-ssa-copy.c (revision 171351)
--- tree-ssa-copy.c (working copy)
*** propagate_tree_value_into_stmt (gimple_s
*** 244,250 
  expr = gimple_assign_rhs1 (stmt);
propagate_tree_value (&expr, val);
gimple_assign_set_rhs_from_tree (gsi, expr);
-   stmt = gsi_stmt (*gsi);
  }
else if (gimple_code (stmt) == GIMPLE_COND)
  {
--- 244,249 
Index: cfglayout.c
===
*** cfglayout.c (revision 171351)
--- cfglayout.c (working copy)
*** fixup_reorder_chain (void)
*** 766,772 
  {
edge e_fall, e_taken, e;
rtx bb_end_insn;
!   basic_block nb;
edge_iterato

Re: Problem with ARM longcalls

2011-03-24 Thread Bernd Schmidt
On 03/24/2011 03:24 PM, Richard Earnshaw wrote:
> 
> On Wed, 2011-03-23 at 16:46 +0100, Bernd Schmidt wrote:
>> I've discovered a problem with -mlong-calls on ARM. The bug was first
>> reported against a new target, but I'd copied the relevant code from the
>> ARM backend.
>>
>> We use current_function_section in arm_is_long_call_p to decide whether
>> we're calling something that goes into the same section. The problem
>> with this is that current_function_section can only be used during
>> final, since it relies on the global variable in_cold_section_p which is
>> set up only in assemble_start_function. On ARM, this problem manifests
>> as short-calls when a long-call would be required; in the other port it
>> was an "insn doesn't satisfy its constraints" error.
>>
>> The following patch is against 4.5, since the problem appears hidden in
>> mainline (the initialization of first_function_block_is_cold has
>> changed). Ok for trunk and branches after arm-linux tests complete?
>>
>>
>> Bernd
> 
> The ARM port currently doesn't support hot/cold partitioning of code
> (and can't until the constant pool code is rewritten to deal with it),
> so how is this a problem?

Different functions can still go into different sections. When we start
expanding a function, in_cold_section_p still contains the value that
was correct for the previous one. It will change at the start of final,
which means that current_function_section can return different values
while compiling a function. See the included testcase.


Bernd


Re: Problem with ARM longcalls

2011-03-24 Thread Richard Earnshaw

On Wed, 2011-03-23 at 16:46 +0100, Bernd Schmidt wrote:
> I've discovered a problem with -mlong-calls on ARM. The bug was first
> reported against a new target, but I'd copied the relevant code from the
> ARM backend.
> 
> We use current_function_section in arm_is_long_call_p to decide whether
> we're calling something that goes into the same section. The problem
> with this is that current_function_section can only be used during
> final, since it relies on the global variable in_cold_section_p which is
> set up only in assemble_start_function. On ARM, this problem manifests
> as short-calls when a long-call would be required; in the other port it
> was an "insn doesn't satisfy its constraints" error.
> 
> The following patch is against 4.5, since the problem appears hidden in
> mainline (the initialization of first_function_block_is_cold has
> changed). Ok for trunk and branches after arm-linux tests complete?
> 
> 
> Bernd

The ARM port currently doesn't support hot/cold partitioning of code
(and can't until the constant pool code is rewritten to deal with it),
so how is this a problem?

R.




Remove old host cases from toplevel configure

2011-03-24 Thread Joseph S. Myers
This patch removes cases for a range of old hosts from the toplevel
configure.ac, as I think those cases are no longer useful.  All the
removed code comes from Cygnus configure before the toplevel configure
was converted to be an autoconf-generated script.

In general those hosts, if ever supported as targets by GCC at all,
had their GCC target support obsoleted in GCC 4.3 or earlier.  It is
of course theoretically possible to build cross tools hosted on a
system not supported as a target by GCC, using a non-GCC compiler, but
it's much more of a niche than building native tools there and these
targets all became unsupported for native tools a long time ago for
lack of interest in maintaining support for them.  Thus I don't think
it's useful any more to maintain cases for these hosts in toplevel
configure.

Furthermore, the whole idea of the toplevel configure tentative_cc
setting code is dubious since this is an autoconf-generated script and
it's autoconf's job to deal with finding a working compiler, putting
it in ANSI C mode, etc. - so if someone did wish to resupport one of
these hosts (and in the unlikely event that building current tools
using the old system compiler is at all possible) it would be better
to put system-specific pieces in autoconf and make toolchain configure
code work using features not host triplet tests as far as possible.

OK to commit?

2011-03-24  Joseph Myers  

* configure.ac (i[[3456789]]86-*-vsta, i[[3456789]]86-*-go32*,
i[[3456789]]86-*-beos*, powerpc-*-beos*, m68k-hp-hpux*,
m68k-apollo-sysv*, m68k-apollo-bsd*, m88k-dg-dgux*,
m88k-harris-cxux*, m88k-motorola-sysv*, mips*-dec-ultrix*,
mips*-nec-sysv4*, mips*-sgi-irix4*, mips*-*-sysv4*, mips*-*-sysv*,
i370-ibm-opened*, i[[3456789]]86-*-sysv5*, i[[3456789]]86-*-dgux*,
i[[3456789]]86-ncr-sysv4.3*, i[[3456789]]86-ncr-sysv4*,
i[[3456789]]86-*-sco3.2v5*, i[[3456789]]86-*-sco*,
i[[3456789]]86-*-udk*, vax-*-ultrix2*, m68k-sun-sunos*,
hppa*-*-hiux*, *-*-hiux*, rs6000-*-lynxos*, *-*-sysv4*,
*-*-rhapsody*): Remove host cases.
* configure: Regenerate.

config:
2011-03-24  Joseph Myers  

* mh-cxux, mh-decstation, mh-dgux386, mh-lynxrs6k, mh-ncr3000,
mh-necv4, mh-sco, mh-sysv5: Remove.

Index: configure.ac
===
--- configure.ac(revision 171390)
+++ configure.ac(working copy)
@@ -429,10 +429,7 @@
   hppa*64*-*-*)
 noconfigdirs="$noconfigdirs byacc"
 ;;
-  i[[3456789]]86-*-vsta)
-noconfigdirs="$noconfigdirs tcl expect dejagnu make texinfo bison patch 
flex byacc send-pr gprof uudecode dejagnu diff guile perl itcl gnuserv gettext"
-;;
-  i[[3456789]]86-*-go32* | i[[3456789]]86-*-msdosdjgpp*)
+  i[[3456789]]86-*-msdosdjgpp*)
 noconfigdirs="$noconfigdirs tcl tk expect dejagnu send-pr uudecode guile 
itcl gnuserv libffi"
 ;;
   x86_64-*-mingw*)
@@ -442,18 +439,12 @@
 # noconfigdirs="tcl tk expect dejagnu make texinfo bison patch flex byacc 
send-pr uudecode dejagnu diff guile perl itcl gnuserv"
 noconfigdirs="$noconfigdirs expect dejagnu autoconf automake send-pr rcs 
guile perl texinfo libtool newlib"
 ;;
-  i[[3456789]]86-*-beos*)
-noconfigdirs="$noconfigdirs tk itcl libgui gdb"
-;;
   *-*-cygwin*)
 noconfigdirs="$noconfigdirs autoconf automake send-pr rcs guile perl"
 ;;
   *-*-netbsd*)
 noconfigdirs="$noconfigdirs rcs"
 ;;
-  powerpc-*-beos*)
-noconfigdirs="$noconfigdirs tk itcl libgui gdb dejagnu readline"
-;;
 esac
 
 
@@ -966,8 +957,6 @@
 ;;
   sh-*-* | sh64-*-*)
 case "${host}" in
-  i[[3456789]]86-*-vsta) ;; # don't add gprof back in
-  i[[3456789]]86-*-go32*) ;; # don't add gprof back in
   i[[3456789]]86-*-msdosdjgpp*) ;; # don't add gprof back in
   *) skipdirs=`echo " ${skipdirs} " | sed -e 's/ gprof / /'` ;;
 esac
@@ -1049,104 +1038,6 @@
 host_makefile_frag=/dev/null
 if test -d ${srcdir}/config ; then
 case "${host}" in
-  m68k-hp-hpux*)
-# Avoid "too much defining" errors from HPUX compiler.
-tentative_cc="cc -Wp,-H256000"
-# If "ar" in $PATH is GNU ar, the symbol table may need rebuilding.
-# If it's HP/UX ar, this should be harmless.
-RANLIB="ar ts"
-;;
-  m68k-apollo-sysv*)
-tentative_cc="cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DUSG"
-;;
-  m68k-apollo-bsd*)
-#None of the Apollo compilers can compile gas or binutils.  The 
preprocessor
-# chokes on bfd, the compiler won't let you assign integers to enums, and
-# other problems.  Defining CC to gcc is a questionable way to say "don't 
use
-# the apollo compiler" (the preferred version of GCC could be called cc,
-# or whatever), but I'm not sure leaving CC as cc is any better...
-#CC=cc -A ansi -A runtype,any -A systype,any -U__STDC__ -DNO_STDARG
-# Used to have BISON=yacc.
-tentative_cc=gcc
-;;
-  m88k-dg-dgux*)
-  

Re: [patch] Fix PR48183, NEON ICE in emit-rtl.c:immed_double_const() under -g

2011-03-24 Thread Julian Brown
On Thu, 24 Mar 2011 10:57:06 +
Richard Sandiford  wrote:

> Chung-Lin Tang  writes:
> > PR48183 is a case where ARM NEON instrinsics, under -O -g, produce
> > debug insns that tries to expand OImode (32-byte integer) zero
> > constants, much too large to represent as two HOST_WIDE_INTs; as
> > the internals manual indicates, such large constants are not
> > supported in general, and ICEs on the GET_MODE_BITSIZE(mode) ==
> > 2*HOST_BITS_PER_WIDE_INT assertion.
> >
> > This patch allows the cases where the large integer constant is
> > still representable using a single CONST_INT, such as zero(0).
> > Bootstrapped and tested on i686 and x86_64, cross-tested on ARM,
> > all without regressions. Okay for trunk?
> >
> > Thanks,
> > Chung-Lin
> >
> > 2011-03-20  Chung-Lin Tang  
> >
> > * emit-rtl.c (immed_double_const): Allow wider than
> > 2*HOST_BITS_PER_WIDE_INT mode constants when they are
> > representable as a single const_int RTX.
> 
> I realise this might be seen as a good expedient fix, but it makes
> me a bit uneasy.  Not a very constructive rationale, sorry.

FWIW I also had a "fix" for this issue, which is equivalent to
Chung-Lin's patch apart from only allowing constant-zero (attached).
That's not really a vote from me for this approach, but maybe limiting
the extent to which we pretend to support wide-integer constants like
this is sensible, if we do go that way.

Julian--- gcc/expr.c	(revision 314639)
+++ gcc/expr.c	(working copy)
@@ -8458,6 +8458,18 @@ expand_expr_real_1 (tree exp, rtx target
   return decl_rtl;
 
 case INTEGER_CST:
+  if (GET_MODE_BITSIZE (mode) > 2 * HOST_BITS_PER_WIDE_INT)
+	{
+	  /* FIXME: We can't generally represent wide integer constants,
+	 but GCC sometimes tries to initialise wide integer values (such
+	 as used by the ARM NEON support) with zero.  Handle that as a
+	 special case here.  */
+	  if (initializer_zerop (exp))
+	return CONST0_RTX (mode);
+
+	  gcc_unreachable ();
+	}
+
   temp = immed_double_const (TREE_INT_CST_LOW (exp),
  TREE_INT_CST_HIGH (exp), mode);
 


Re: [RFC] Add a new argument to SELECT_CC_MODE

2011-03-24 Thread Richard Earnshaw
On Tue, 2011-03-22 at 21:00 +0100, Eric Botcazou wrote:
> > Like in the attached patch.
> 
> Sandra expressed an interest for it so I've installed it on the mainline 
> after 
> bootstrapping and regtesting on x86_64-suse-linux.
> 
> 
> 2011-03-22  Eric Botcazou  
> 
> * combine.c (simplify_set): Try harder to find the best CC mode when
> simplifying a nested COMPARE on the RHS.
> 
> 

So I've always suspected that the way the ARM port handles this is
broken.  I think this now confirms that suspicion.   

Taking a look at the x86 backend the code there looks far more sensible
and more in-line with what I think ARM should be doing.  For a floating
point operation the code is:

  TARGET_IEEE_FP ? CCFPUmode : CCFPmode;

That is, if generating IEEE compliant code, then use non-excepting
comparisions, otherwise use exception raising ones.

R.





Re: [PATCH][ARM] Discourage use of NEON on Cortex-A8

2011-03-24 Thread Richard Earnshaw

On Tue, 2011-03-22 at 14:08 +, Andrew Stubbs wrote:
> And again, with the patch ...
> 
> On 22/03/11 14:05, Andrew Stubbs wrote:
> > On 14/03/11 18:17, Richard Earnshaw wrote:
> >  > I think the order should be: not-a8, core-regs, core-regs, only-a8.
> >
> > Ok, how about this?
> >
> > I've tested that it still builds spec2k crafty.
> >
> > Andrew

OK




Scheduler cleanups, 5/5

2011-03-24 Thread Bernd Schmidt
We can currently select an insn to be scheduled, only to find out that
it's not actually valid at the current time, either due to state
conflicts or being an asm with something else already scheduled in the
same cycle. Not only is this pointless, it causes problem with the
sched_reorder logic in the TI C6X port (which will be submitted later).
The solution is to prune the ready list earlier. More code is moved out
of the schedule_block main loop, which is IMO always a good thing.

Bootstrapped and tested (a slightly earlier version with an unused
variable) on i686-linux; I also verified that there are no changes in
code generation on any of my testcases.


Bernd
* haifa-sched.c (prune_ready_list): New function, broken out of
schedule_block.
(schedule_block): Use it.

Index: gcc/haifa-sched.c
===
--- gcc/haifa-sched.c.orig
+++ gcc/haifa-sched.c
@@ -2614,8 +2614,8 @@ max_issue (struct ready_list *ready, int
{
  if (state_dead_lock_p (state)
  || insn_finishes_cycle_p (insn))
-   /* We won't issue any more instructions in the next
-  choice_state.  */
+   /* We won't issue any more instructions in the next
+  choice_state.  */
top->rest = 0;
  else
top->rest--;
@@ -2863,6 +2863,52 @@ commit_schedule (rtx prev_head, rtx tail
   VEC_truncate (rtx, scheduled_insns, 0);
 }
 
+/* Examine all insns on the ready list and queue those which can't be
+   issued in this cycle.  TEMP_STATE is temporary scheduler state we
+   can use as scratch space.  If FIRST_CYCLE_INSN_P is true, no insns
+   have been issued for the current cycle, which means it is valid to
+   issue an asm statement.  */
+
+static void
+prune_ready_list (state_t temp_state, bool first_cycle_insn_p)
+{
+  int i;
+
+ restart:
+  for (i = 0; i < ready.n_ready; i++)
+{
+  rtx insn = ready_element (&ready, i);
+  int cost = 0;
+  const char *reason = "resource conflict";
+
+  if (recog_memoized (insn) < 0)
+   {
+ if (!first_cycle_insn_p
+ && (GET_CODE (PATTERN (insn)) == ASM_INPUT
+ || asm_noperands (PATTERN (insn)) >= 0))
+   cost = 1;
+ reason = "asm";
+   }
+  else if (flag_sched_pressure)
+   cost = 0;
+  else
+   {
+ memcpy (temp_state, curr_state, dfa_state_size);
+ cost = state_transition (temp_state, insn);
+ if (cost < 0)
+   cost = 0;
+ else if (cost == 0)
+   cost = 1;
+   }
+  if (cost >= 1)
+   {
+ ready_remove (&ready, i);
+ queue_insn (insn, cost, reason);
+ goto restart;
+   }
+}
+}
+
 /* Use forward list scheduling to rearrange insns of block pointed to by
TARGET_BB, possibly bringing insns from subsequent blocks in the same
region.  */
@@ -3014,6 +3060,10 @@ schedule_block (basic_block *target_bb)
}
   while (advance > 0);
 
+  prune_ready_list (temp_state, true);
+  if (ready.n_ready == 0)
+continue;
+
   if (sort_p)
{
  /* Sort the ready list based on priority.  */
@@ -3144,44 +3194,6 @@ schedule_block (basic_block *target_bb)
}
 
  sort_p = TRUE;
- memcpy (temp_state, curr_state, dfa_state_size);
- if (recog_memoized (insn) < 0)
-   {
- asm_p = (GET_CODE (PATTERN (insn)) == ASM_INPUT
-  || asm_noperands (PATTERN (insn)) >= 0);
- if (!first_cycle_insn_p && asm_p)
-   /* This is asm insn which is tried to be issued on the
-  cycle not first.  Issue it on the next cycle.  */
-   cost = 1;
- else
-   /* A USE insn, or something else we don't need to
-  understand.  We can't pass these directly to
-  state_transition because it will trigger a
-  fatal error for unrecognizable insns.  */
-   cost = 0;
-   }
- else if (sched_pressure_p)
-   cost = 0;
- else
-   {
- cost = state_transition (temp_state, insn);
- if (cost < 0)
-   cost = 0;
- else if (cost == 0)
-   cost = 1;
-   }
-
- if (cost >= 1)
-   {
- queue_insn (insn, cost, "resource conflict");
- if (SCHED_GROUP_P (insn))
-   {
- advance = cost;
- break;
-   }
-
- continue;
-   }
 
  if (current_sched_info->can_schedule_ready_p
  && ! (*current_sched_info->can_schedule_ready_p) (insn))
@@ -3202,14 +3214,20 @@ schedule_block (basic_block *target_bb)
 
  /* Update counters, etc in the scheduler's front end.  */
  (*current_sched_info->begin_schedule_ready) (ins

  1   2   >