[PING^3] Nios II port

2013-06-24 Thread Chung-Lin Tang
Ping x 3.

On 13/6/18 下午4:38, Chung-Lin Tang wrote:
> On 13/6/18 上午3:05, Sandra Loosemore wrote:
>> > Ping?  I think these are the most recent versions of the unreviewed
>> > patches in the series:
>> > 
>> > http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00287.html
>> > http://gcc.gnu.org/ml/gcc-patches/2013-05/msg00760.html
>> > http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01085.html



Re: [google/gcc-4_8] Port -Wreal-conversion warning

2013-06-24 Thread Xinliang David Li
ok.

David

On Mon, Jun 24, 2013 at 10:03 PM, Sharad Singhai  wrote:
> On Mon, Jun 24, 2013 at 9:14 PM, Xinliang David Li  wrote:
>> To avoid printing twice, can you just do
>>
>> opt_type = (warn_conversion ? OPT_Wconversion : OPT_Wreal_conversion);
>> warning_at (loc, opt_type, ...);
>
> Thanks for the suggestion. I have updated the enclosed patch and
> retested. Okay for google/gcc-4_8?
>
> Thanks,
> Sharad
>
> 2013-06-24
>
> * doc/invoke.texi: Document new option -Wreal-conversion.
> * c-family/c.opt: Handle new option.
> * c-family/c-opts.c (c_common_post_options): Ditto.
> * c-family/c-common.c (conversion_warning): Ditto.
>
> testsuite/ChangeLog:
>
> * testsuite/gcc.dg/Wreal-conversion-1.c: New test.
> * testsuite/g++.dg/warn/Wreal-conversion-1.C: Ditto.
>
> Index: doc/invoke.texi
> ===
> --- doc/invoke.texi (revision 200359)
> +++ doc/invoke.texi (working copy)
> @@ -237,7 +237,7 @@ Objective-C and Objective-C++ Dialects}.
>  -Wno-attributes -Wno-builtin-macro-redefined @gol
>  -Wc++-compat -Wc++11-compat -Wcast-align  -Wcast-qual  @gol
>  -Wchar-subscripts -Wclobbered  -Wcomment @gol
> --Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
> +-Wconversion -Wreal-conversion -Wcoverage-mismatch  -Wno-cpp
> -Wno-deprecated  @gol
>  -Wno-deprecated-declarations -Wdisabled-optimization  @gol
>  -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
>  -Wno-endif-labels -Werror  -Werror=* @gol
> @@ -4452,6 +4452,12 @@ reference to them. Warnings about conversions betw
>  unsigned integers are disabled by default in C++ unless
>  @option{-Wsign-conversion} is explicitly enabled.
>
> +@item -Wreal-conversion
> +@opindex Wreal-conversion
> +@opindex Wno-real-conversion
> +Warn for implicit type conversions from real (@code{double} or @code{float})
> +to integral values.
> +
>  @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
>  @opindex Wconversion-null
>  @opindex Wno-conversion-null
> Index: testsuite/gcc.dg/Wreal-conversion-1.c
> ===
> --- testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
> +++ testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
> @@ -0,0 +1,23 @@
> +// { dg-do compile }
> +// { dg-options "-Wreal-conversion" }
> +
> +#include 
> +
> +int func1(int a) {
> +  double f = a;
> +  return f;   // { dg-warning "conversion to" }
> +}
> +
> +double func3();
> +
> +void func2() {
> +  double g = 3.2;
> +  float f;
> +  int t = g;  // { dg-warning "conversion to" }
> +  int p;
> +  p = f;  // { dg-warning "conversion to" }
> +  func1(g);   // { dg-warning "conversion to" }
> +  char c = f; // { dg-warning "conversion to" }
> +  int q;
> +  q = func3();// { dg-warning "conversion to" }
> +}
> Index: testsuite/g++.dg/warn/Wreal-conversion-1.C
> ===
> --- testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
> +++ testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
> @@ -0,0 +1,24 @@
> +// { dg-do compile }
> +// { dg-options "-Wreal-conversion" }
> +
> +#include 
> +
> +int func1(int a) {
> +  double f = a;
> +  return f;   // { dg-warning "conversion to" }
> +}
> +
> +double func3();
> +
> +void func2() {
> +  double g = 3.2;
> +  float f;
> +  int t = g;  // { dg-warning "conversion to" }
> +  bool b = g;
> +  int p;
> +  p = f;  // { dg-warning "conversion to" }
> +  func1(g);   // { dg-warning "conversion to" }
> +  char c = f; // { dg-warning "conversion to" }
> +  int q;
> +  q = func3();// { dg-warning "conversion to" }
> +}
> Index: c-family/c.opt
> ===
> --- c-family/c.opt (revision 200359)
> +++ c-family/c.opt (working copy)
> @@ -677,6 +677,10 @@ Wsign-compare
>  C ObjC C++ ObjC++ EnabledBy(Wextra)
>  ;
>
> +Wreal-conversion
> +C ObjC C++ ObjC++ Var(warn_real_conversion) Init(-1) Warning
> +Warn for implicit type conversions from real to integral values
> +
>  Wsign-conversion
>  C ObjC C++ ObjC++ Var(warn_sign_conversion) LangEnabledBy(C ObjC,Wconversion)
>  Warn for implicit type conversions between signed and unsigned integers
> Index: c-family/c-opts.c
> ===
> --- c-family/c-opts.c (revision 200359)
> +++ c-family/c-opts.c (working copy)
> @@ -876,6 +876,12 @@ c_common_post_options (const char **pfilename)
>if (warn_packed_bitfield_compat == -1)
>  warn_packed_bitfield_compat = 1;
>
> +  /* Enable warning for converting real values to integral values
> + when -Wconversion is specified (unless disabled through
> + -Wno-real-conversion).  */
> +  if (warn_real_conversion == -1)
> +warn_real_conversion = warn_conversion;
> +
>/* Special format checking

Re: [google/gcc-4_8] Port -Wreal-conversion warning

2013-06-24 Thread Sharad Singhai
On Mon, Jun 24, 2013 at 9:14 PM, Xinliang David Li  wrote:
> To avoid printing twice, can you just do
>
> opt_type = (warn_conversion ? OPT_Wconversion : OPT_Wreal_conversion);
> warning_at (loc, opt_type, ...);

Thanks for the suggestion. I have updated the enclosed patch and
retested. Okay for google/gcc-4_8?

Thanks,
Sharad

2013-06-24

* doc/invoke.texi: Document new option -Wreal-conversion.
* c-family/c.opt: Handle new option.
* c-family/c-opts.c (c_common_post_options): Ditto.
* c-family/c-common.c (conversion_warning): Ditto.

testsuite/ChangeLog:

* testsuite/gcc.dg/Wreal-conversion-1.c: New test.
* testsuite/g++.dg/warn/Wreal-conversion-1.C: Ditto.

Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 200359)
+++ doc/invoke.texi (working copy)
@@ -237,7 +237,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wno-attributes -Wno-builtin-macro-redefined @gol
 -Wc++-compat -Wc++11-compat -Wcast-align  -Wcast-qual  @gol
 -Wchar-subscripts -Wclobbered  -Wcomment @gol
--Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
+-Wconversion -Wreal-conversion -Wcoverage-mismatch  -Wno-cpp
-Wno-deprecated  @gol
 -Wno-deprecated-declarations -Wdisabled-optimization  @gol
 -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
 -Wno-endif-labels -Werror  -Werror=* @gol
@@ -4452,6 +4452,12 @@ reference to them. Warnings about conversions betw
 unsigned integers are disabled by default in C++ unless
 @option{-Wsign-conversion} is explicitly enabled.

+@item -Wreal-conversion
+@opindex Wreal-conversion
+@opindex Wno-real-conversion
+Warn for implicit type conversions from real (@code{double} or @code{float})
+to integral values.
+
 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
 @opindex Wconversion-null
 @opindex Wno-conversion-null
Index: testsuite/gcc.dg/Wreal-conversion-1.c
===
--- testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
+++ testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-Wreal-conversion" }
+
+#include 
+
+int func1(int a) {
+  double f = a;
+  return f;   // { dg-warning "conversion to" }
+}
+
+double func3();
+
+void func2() {
+  double g = 3.2;
+  float f;
+  int t = g;  // { dg-warning "conversion to" }
+  int p;
+  p = f;  // { dg-warning "conversion to" }
+  func1(g);   // { dg-warning "conversion to" }
+  char c = f; // { dg-warning "conversion to" }
+  int q;
+  q = func3();// { dg-warning "conversion to" }
+}
Index: testsuite/g++.dg/warn/Wreal-conversion-1.C
===
--- testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
+++ testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-Wreal-conversion" }
+
+#include 
+
+int func1(int a) {
+  double f = a;
+  return f;   // { dg-warning "conversion to" }
+}
+
+double func3();
+
+void func2() {
+  double g = 3.2;
+  float f;
+  int t = g;  // { dg-warning "conversion to" }
+  bool b = g;
+  int p;
+  p = f;  // { dg-warning "conversion to" }
+  func1(g);   // { dg-warning "conversion to" }
+  char c = f; // { dg-warning "conversion to" }
+  int q;
+  q = func3();// { dg-warning "conversion to" }
+}
Index: c-family/c.opt
===
--- c-family/c.opt (revision 200359)
+++ c-family/c.opt (working copy)
@@ -677,6 +677,10 @@ Wsign-compare
 C ObjC C++ ObjC++ EnabledBy(Wextra)
 ;

+Wreal-conversion
+C ObjC C++ ObjC++ Var(warn_real_conversion) Init(-1) Warning
+Warn for implicit type conversions from real to integral values
+
 Wsign-conversion
 C ObjC C++ ObjC++ Var(warn_sign_conversion) LangEnabledBy(C ObjC,Wconversion)
 Warn for implicit type conversions between signed and unsigned integers
Index: c-family/c-opts.c
===
--- c-family/c-opts.c (revision 200359)
+++ c-family/c-opts.c (working copy)
@@ -876,6 +876,12 @@ c_common_post_options (const char **pfilename)
   if (warn_packed_bitfield_compat == -1)
 warn_packed_bitfield_compat = 1;

+  /* Enable warning for converting real values to integral values
+ when -Wconversion is specified (unless disabled through
+ -Wno-real-conversion).  */
+  if (warn_real_conversion == -1)
+warn_real_conversion = warn_conversion;
+
   /* Special format checking options don't work without -Wformat; warn if
  they are used.  */
   if (!warn_format)
Index: c-family/c-common.c
===
--- c-family/c-common.c (revision 200359)
+++ c-family/c-common.c (working copy)
@@ -2668,7 +2668,7 @@ conversion_warning (tree type, tree expr)

Re: [wwwdocs] Release note for x86 intrinsics usability

2013-06-24 Thread Xinliang David Li
Perhaps provide a tiny example showing the change (user level) before and after?

David

On Mon, Jun 24, 2013 at 2:55 PM, Gerald Pfeifer  wrote:
> On Mon, 24 Jun 2013, Sriraman Tallam wrote:
>> IA-32/x86-64
> ^
> Ahem, no. :-)  Please use id="x86" instead.
>
>>   
>>  It is now possible to call x86 intrinsics from select functions in
>>   a file that are marked with the appropriate target attribute without
>>   having to compile the entire file with the -mxxx option.
>
> -mxxx
>
> Do you want to explicit mention the appropirate target attribute?
>
> Fine with these changes.
>
> Gerald


Re: [google/gcc-4_8] Port -Wreal-conversion warning

2013-06-24 Thread Xinliang David Li
To avoid printing twice, can you just do

opt_type = (warn_conversion ? OPT_Wconversion : OPT_Wreal_conversion);
warning_at (loc, opt_type, ...);

David

On Mon, Jun 24, 2013 at 6:08 PM, Sharad Singhai  wrote:
> Hi,
>
> This patch forward ports the -Wreal-conversion warning to
> google/gcc-4_8 branch (google ref 39133-p2). I tweaked the patch a
> little bit to avoid printing duplicate warnings when both -Wconversion
> and -Wreal-conversion are specified. Also, I trimmed the test case to
> avoid testing for integer-to-integer narrowing conversions as this
> warning is about real conversions.
>
> Bootstrapped and tested on x86_64. Okay for google/gcc-4_8?
>
> Thanks,
> Sharad
>
> 2013-06-24
>
> * doc/invoke.texi: Document new option -Wreal-conversion.
> * c-family/c.opt: Handle new option.
> * c-family/c-opts.c (c_common_post_options): Ditto.
> * c-family/c-common.c (conversion_warning): Ditto.
>
> testsuite/ChangeLog:
>
> * testsuite/gcc.dg/Wreal-conversion-1.c: New test.
> * testsuite/g++.dg/warn/Wreal-conversion-1.C: Ditto.
>
> Index: testsuite/gcc.dg/Wreal-conversion-1.c
> ===
> --- testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
> +++ testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
> @@ -0,0 +1,23 @@
> +// { dg-do compile }
> +// { dg-options "-Wreal-conversion" }
> +
> +#include 
> +
> +int func1(int a) {
> +  double f = a;
> +  return f;   // { dg-warning "conversion to" }
> +}
> +
> +double func3();
> +
> +void func2() {
> +  double g = 3.2;
> +  float f;
> +  int t = g;  // { dg-warning "conversion to" }
> +  int p;
> +  p = f;  // { dg-warning "conversion to" }
> +  func1(g);   // { dg-warning "conversion to" }
> +  char c = f; // { dg-warning "conversion to" }
> +  int q;
> +  q = func3();// { dg-warning "conversion to" }
> +}
> Index: testsuite/g++.dg/warn/Wreal-conversion-1.C
> ===
> --- testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
> +++ testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
> @@ -0,0 +1,24 @@
> +// { dg-do compile }
> +// { dg-options "-Wreal-conversion" }
> +
> +#include 
> +
> +int func1(int a) {
> +  double f = a;
> +  return f;   // { dg-warning "conversion to" }
> +}
> +
> +double func3();
> +
> +void func2() {
> +  double g = 3.2;
> +  float f;
> +  int t = g;  // { dg-warning "conversion to" }
> +  bool b = g;
> +  int p;
> +  p = f;  // { dg-warning "conversion to" }
> +  func1(g);   // { dg-warning "conversion to" }
> +  char c = f; // { dg-warning "conversion to" }
> +  int q;
> +  q = func3();// { dg-warning "conversion to" }
> +}
> Index: doc/invoke.texi
> ===
> --- doc/invoke.texi (revision 200359)
> +++ doc/invoke.texi (working copy)
> @@ -193,7 +193,7 @@ in the following sections.
>  -fno-default-inline  -fvisibility-inlines-hidden @gol
>  -fvisibility-ms-compat @gol
>  -fext-numeric-literals @gol
> --Wabi  -Wconversion-null  -Wctor-dtor-privacy @gol
> +-Wabi  -Wconversion-null -Wctor-dtor-privacy @gol
>  -Wdelete-non-virtual-dtor -Wliteral-suffix -Wnarrowing @gol
>  -Wnoexcept -Wnon-virtual-dtor  -Wreorder @gol
>  -Weffc++  -Wstrict-null-sentinel @gol
> @@ -237,7 +237,7 @@ Objective-C and Objective-C++ Dialects}.
>  -Wno-attributes -Wno-builtin-macro-redefined @gol
>  -Wc++-compat -Wc++11-compat -Wcast-align  -Wcast-qual  @gol
>  -Wchar-subscripts -Wclobbered  -Wcomment @gol
> --Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
> +-Wconversion -Wreal-conversion -Wcoverage-mismatch  -Wno-cpp
> -Wno-deprecated  @gol
>  -Wno-deprecated-declarations -Wdisabled-optimization  @gol
>  -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
>  -Wno-endif-labels -Werror  -Werror=* @gol
> @@ -4452,6 +4452,12 @@ reference to them. Warnings about conversions betw
>  unsigned integers are disabled by default in C++ unless
>  @option{-Wsign-conversion} is explicitly enabled.
>
> +@item -Wreal-conversion
> +@opindex Wreal-conversion
> +@opindex Wno-real-conversion
> +Warn for implicit type conversions from real (@code{double} or @code{float})
> +to integral values.
> +
>  @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
>  @opindex Wconversion-null
>  @opindex Wno-conversion-null
> Index: c-family/c.opt
> ===
> --- c-family/c.opt (revision 200359)
> +++ c-family/c.opt (working copy)
> @@ -677,6 +677,10 @@ Wsign-compare
>  C ObjC C++ ObjC++ EnabledBy(Wextra)
>  ;
>
> +Wreal-conversion
> +C ObjC C++ ObjC++ Var(warn_real_conversion) Init(-1) Warning
> +Warn for implicit type conversions from real to integral values
> +
>  Wsign-conversion
>  C ObjC C++ ObjC++ Var(warn_sign_conversion) LangEnabledBy(C ObjC,Wconversion)
>  Warn for implicit type conversions between s

Re: [PATCH, PR 57670] Do not turn member pointers to builtin_unreachable

2013-06-24 Thread Jan Hubicka
> Hi,
> 
> I have made a mistake when I decided to redirect member-pointer calls
> to builtin_unreachable because I wrongly thought there are two calls,
> one for the VMT lookup and other for non-virtual members and thought
> only the second got redirected.  However, even though there are two
> different lookups, there is only one call and thus we must refrain
> from killing it when the value coming from a caller is not an address
> of a function.  I have pondered about overloading the polymorphic flag
> for marking member pointer calls but eventually decided to introduce a
> new one, as there are plenty bits still available in indirect info and
> the added complexity of overloading the flag quickly turned ugly.
> 
> Bootstrapped and tested on x86_64-linux.  OK for trunk?
> 
> Thanks and sorry for the confusion,
> 
> Martin
> 
> 
> 2013-06-21  Martin Jambor  
> 
>   PR middle-end/57670
>   * cgraph.h (cgraph_indirect_call_info): New flag member_ptr.
>   * ipa-prop.c (ipa_print_node_jump_functions): Mark member pointer
>   calls in the dump.
>   (ipa_note_param_call): Initialize member_ptr flag.
>   (ipa_analyze_indirect_call_uses): Set member_ptr flag.
>   (ipa_make_edge_direct_to_target): Bail out if member_ptr is set.
>   (ipa_write_indirect_edge_info): Stream member_ptr flag.
>   (ipa_read_indirect_edge_info): Likewise.
> 
> testsuite/
>   * g++.dg/ipa/pr57670.C (H): New test.

OK,
thanks!
Honza


[google/gcc-4_8] Port -Wreal-conversion warning

2013-06-24 Thread Sharad Singhai
Hi,

This patch forward ports the -Wreal-conversion warning to
google/gcc-4_8 branch (google ref 39133-p2). I tweaked the patch a
little bit to avoid printing duplicate warnings when both -Wconversion
and -Wreal-conversion are specified. Also, I trimmed the test case to
avoid testing for integer-to-integer narrowing conversions as this
warning is about real conversions.

Bootstrapped and tested on x86_64. Okay for google/gcc-4_8?

Thanks,
Sharad

2013-06-24

* doc/invoke.texi: Document new option -Wreal-conversion.
* c-family/c.opt: Handle new option.
* c-family/c-opts.c (c_common_post_options): Ditto.
* c-family/c-common.c (conversion_warning): Ditto.

testsuite/ChangeLog:

* testsuite/gcc.dg/Wreal-conversion-1.c: New test.
* testsuite/g++.dg/warn/Wreal-conversion-1.C: Ditto.

Index: testsuite/gcc.dg/Wreal-conversion-1.c
===
--- testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
+++ testsuite/gcc.dg/Wreal-conversion-1.c (revision 0)
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-Wreal-conversion" }
+
+#include 
+
+int func1(int a) {
+  double f = a;
+  return f;   // { dg-warning "conversion to" }
+}
+
+double func3();
+
+void func2() {
+  double g = 3.2;
+  float f;
+  int t = g;  // { dg-warning "conversion to" }
+  int p;
+  p = f;  // { dg-warning "conversion to" }
+  func1(g);   // { dg-warning "conversion to" }
+  char c = f; // { dg-warning "conversion to" }
+  int q;
+  q = func3();// { dg-warning "conversion to" }
+}
Index: testsuite/g++.dg/warn/Wreal-conversion-1.C
===
--- testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
+++ testsuite/g++.dg/warn/Wreal-conversion-1.C (revision 0)
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-Wreal-conversion" }
+
+#include 
+
+int func1(int a) {
+  double f = a;
+  return f;   // { dg-warning "conversion to" }
+}
+
+double func3();
+
+void func2() {
+  double g = 3.2;
+  float f;
+  int t = g;  // { dg-warning "conversion to" }
+  bool b = g;
+  int p;
+  p = f;  // { dg-warning "conversion to" }
+  func1(g);   // { dg-warning "conversion to" }
+  char c = f; // { dg-warning "conversion to" }
+  int q;
+  q = func3();// { dg-warning "conversion to" }
+}
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 200359)
+++ doc/invoke.texi (working copy)
@@ -193,7 +193,7 @@ in the following sections.
 -fno-default-inline  -fvisibility-inlines-hidden @gol
 -fvisibility-ms-compat @gol
 -fext-numeric-literals @gol
--Wabi  -Wconversion-null  -Wctor-dtor-privacy @gol
+-Wabi  -Wconversion-null -Wctor-dtor-privacy @gol
 -Wdelete-non-virtual-dtor -Wliteral-suffix -Wnarrowing @gol
 -Wnoexcept -Wnon-virtual-dtor  -Wreorder @gol
 -Weffc++  -Wstrict-null-sentinel @gol
@@ -237,7 +237,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wno-attributes -Wno-builtin-macro-redefined @gol
 -Wc++-compat -Wc++11-compat -Wcast-align  -Wcast-qual  @gol
 -Wchar-subscripts -Wclobbered  -Wcomment @gol
--Wconversion  -Wcoverage-mismatch  -Wno-cpp  -Wno-deprecated  @gol
+-Wconversion -Wreal-conversion -Wcoverage-mismatch  -Wno-cpp
-Wno-deprecated  @gol
 -Wno-deprecated-declarations -Wdisabled-optimization  @gol
 -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
 -Wno-endif-labels -Werror  -Werror=* @gol
@@ -4452,6 +4452,12 @@ reference to them. Warnings about conversions betw
 unsigned integers are disabled by default in C++ unless
 @option{-Wsign-conversion} is explicitly enabled.

+@item -Wreal-conversion
+@opindex Wreal-conversion
+@opindex Wno-real-conversion
+Warn for implicit type conversions from real (@code{double} or @code{float})
+to integral values.
+
 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
 @opindex Wconversion-null
 @opindex Wno-conversion-null
Index: c-family/c.opt
===
--- c-family/c.opt (revision 200359)
+++ c-family/c.opt (working copy)
@@ -677,6 +677,10 @@ Wsign-compare
 C ObjC C++ ObjC++ EnabledBy(Wextra)
 ;

+Wreal-conversion
+C ObjC C++ ObjC++ Var(warn_real_conversion) Init(-1) Warning
+Warn for implicit type conversions from real to integral values
+
 Wsign-conversion
 C ObjC C++ ObjC++ Var(warn_sign_conversion) LangEnabledBy(C ObjC,Wconversion)
 Warn for implicit type conversions between signed and unsigned integers
Index: c-family/c-opts.c
===
--- c-family/c-opts.c (revision 200359)
+++ c-family/c-opts.c (working copy)
@@ -876,6 +876,12 @@ c_common_post_options (const char **pfilename)
   if (warn_packed_bitfield_compat == -1)
 warn_packed_bitfield_compat = 1;

+  /* Enable warning for converting real values to integral values
+ when -Wconversion is specified (unless disabled 

Re: [RS6000] libffi little-endian

2013-06-24 Thread Alan Modra
On Mon, Jun 24, 2013 at 11:12:03AM -0400, Anthony Green wrote:
> It's fine with me.  Please commit it directly to GCC and I'll put it in the 
> upstream.

Thanks!  Committed revision 200383.  (and 200384 to 4.8 branch.)

-- 
Alan Modra
Australia Development Lab, IBM


[v3] libstdc++/57704

2013-06-24 Thread Paolo Carlini

Hi,

this is the LWG 467 bit about char_traits::lt: since the member is 
not used elsewhere in the library as an implementation detail and the 
symbol is not exported, I think we can just unconditionally apply the 
tweak and be done.


Tested x86_64-linux.

Thanks,
Paolo.

/
2013-06-24  Paolo Carlini  

PR libstdc++/57704
* include/bits/char_traits.h (char_traits::lt): Implement
LWG 467.
* testsuite/21_strings/char_traits/requirements/char/57704.cc: New.
Index: include/bits/char_traits.h
===
--- include/bits/char_traits.h  (revision 200380)
+++ include/bits/char_traits.h  (working copy)
@@ -248,7 +248,11 @@
 
   static _GLIBCXX_CONSTEXPR bool
   lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
-  { return __c1 < __c2; }
+  {
+   // LWG 467.
+   return (static_cast(__c1)
+   < static_cast(__c2));
+  }
 
   static int
   compare(const char_type* __s1, const char_type* __s2, size_t __n)
Index: testsuite/21_strings/char_traits/requirements/char/57704.cc
===
--- testsuite/21_strings/char_traits/requirements/char/57704.cc (revision 0)
+++ testsuite/21_strings/char_traits/requirements/char/57704.cc (working copy)
@@ -0,0 +1,37 @@
+// Copyright (C) 2013 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
+// .
+
+#include 
+#include 
+
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  char a = '\x7f';
+  char b = '\x80';
+
+  VERIFY( (std::char_traits::lt(a, b)
+  == (static_cast(a)
+  < static_cast(b))) );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}


Go patch committed: Check _ constant declarations

2013-06-24 Thread Ian Lance Taylor
This patch to the Go frontend, from Rémy Oudompheng, checks the
constants named _ are valid.  Such constants are discarded but the
values should still be checked.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.8 branch.

Ian

diff -r 49a130a849da go/gogo-tree.cc
--- a/go/gogo-tree.cc	Mon Jun 24 15:07:14 2013 -0700
+++ b/go/gogo-tree.cc	Mon Jun 24 15:55:28 2013 -0700
@@ -814,6 +814,15 @@
 	  continue;
 	}
 
+  // Skip blank named functions and constants.
+  if ((no->is_function() && no->func_value()->is_sink())
+	  || (no->is_const() && no->const_value()->is_sink()))
+{
+  --i;
+  --count;
+  continue;
+}
+
   // There is nothing useful we can output for constants which
   // have ideal or non-integral type.
   if (no->is_const())
@@ -829,14 +838,6 @@
 	}
 	}
 
-  // Skip blank named functions.
-  if (no->is_function() && no->func_value()->is_sink())
-{
-  --i;
-  --count;
-  continue;
-}
-
   if (!no->is_variable())
 	{
 	  vec[i] = no->get_tree(this, NULL);
diff -r 49a130a849da go/gogo.h
--- a/go/gogo.h	Mon Jun 24 15:07:14 2013 -0700
+++ b/go/gogo.h	Mon Jun 24 15:55:28 2013 -0700
@@ -1687,7 +1687,7 @@
   Named_constant(Type* type, Expression* expr, int iota_value,
 		 Location location)
 : type_(type), expr_(expr), iota_value_(iota_value), location_(location),
-  lowering_(false)
+  lowering_(false), is_sink_(false)
   { }
 
   Type*
@@ -1721,6 +1721,14 @@
   clear_lowering()
   { this->lowering_ = false; }
 
+  bool
+  is_sink() const
+  { return this->is_sink_; }
+
+  void
+  set_is_sink()
+  { this->is_sink_ = true; }
+
   // Traverse the expression.
   int
   traverse_expression(Traverse*);
@@ -1756,6 +1764,8 @@
   Location location_;
   // Whether we are currently lowering this constant.
   bool lowering_;
+  // Whether this constant is blank named and needs only type checking.
+  bool is_sink_;
 };
 
 // A type declaration.
diff -r 49a130a849da go/parse.cc
--- a/go/parse.cc	Mon Jun 24 15:07:14 2013 -0700
+++ b/go/parse.cc	Mon Jun 24 15:55:28 2013 -0700
@@ -1457,6 +1457,16 @@
 
   if (!Gogo::is_sink_name(pi->name()))
 	this->gogo_->add_constant(*pi, *pe, this->iota_value());
+  else
+	{
+	  static int count;
+	  char buf[30];
+	  snprintf(buf, sizeof buf, ".$sinkconst%d", count);
+	  ++count;
+	  Typed_identifier ti(std::string(buf), type, pi->location());
+	  Named_object* no = this->gogo_->add_constant(ti, *pe, this->iota_value());
+	  no->const_value()->set_is_sink();
+	}
 }
   if (pe != expr_list->end())
 error_at(this->location(), "too many initializers");


Re: [PATCH] Change the badness computation to ensure no integer-underflow

2013-06-24 Thread Dehao Chen
The original patch has some flaw. The new patch is attached.
Bootstrapped and passed regression tests.

Thanks,
Dehao

On Mon, Jun 24, 2013 at 9:44 AM, Dehao Chen  wrote:
> Hi, Richard,
>
> I've updated the patch (as attached) to use sreal to compute badness.
>
> Thanks,
> Dehao
>
> On Mon, Jun 24, 2013 at 5:41 AM, Richard Biener
>  wrote:
>> On Sat, Jun 22, 2013 at 2:59 AM, Dehao Chen  wrote:
>>> This patch prevents integer-underflow of badness computation in ipa-inline.
>>>
>>> Bootstrapped and passed regression tests.
>>>
>>> OK for trunk?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> gcc/ChangeLog:
>>> 2013-06-21  Dehao Chen  
>>>
>>> * ipa-inline.c (edge_badness): Fix integer underflow.
>>>
>>> Index: gcc/ipa-inline.c
>>> ===
>>> --- gcc/ipa-inline.c (revision 200326)
>>> +++ gcc/ipa-inline.c (working copy)
>>> @@ -888,11 +888,9 @@ edge_badness (struct cgraph_edge *edge, bool dump)
>>>else if (max_count)
>>>  {
>>>int relbenefit = relative_time_benefit (callee_info, edge, 
>>> edge_time);
>>> -  badness =
>>> - ((int)
>>> - ((double) edge->count * INT_MIN / 2 / max_count /
>>> RELATIVE_TIME_BENEFIT_RANGE) *
>>> - relbenefit) / growth;
>>> -
>>> +  badness = ((int)((double) edge->count / max_count
>>> +  * relbenefit / RELATIVE_TIME_BENEFIT_RANGE * INT_MIN / 2)) / growth;
>>> +
>>
>> FP operations on the host are frowned upon if code generation depends
>> on their outcome.  They all should use sreal_* as predict already does.
>> Other than that I wonder why the final division is int (so we get truncation
>> and not rounding)?  That increases the effect of doing the multiply by
>> relbenefit in double.
>>
>> Richard.
>>
>>>/* Be sure that insanity of the profile won't lead to increasing 
>>> counts
>>>   in the scalling and thus to overflow in the computation above.  */
>>>gcc_assert (max_count >= edge->count);
Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 200375)
+++ gcc/ChangeLog   (working copy)
@@ -1,3 +1,7 @@
+2013-06-21  Dehao Chen  
+
+   * ipa-inline.c (edge_badness): Fix integer underflow.
+
 2013-06-24  Martin Jambor  
 
PR tree-optimization/57358
Index: gcc/Makefile.in
===
--- gcc/Makefile.in (revision 200375)
+++ gcc/Makefile.in (working copy)
@@ -2947,7 +2947,7 @@ ipa-inline.o : ipa-inline.c $(CONFIG_H) $(SYSTEM_H
$(DIAGNOSTIC_H) $(FIBHEAP_H) $(PARAMS_H) $(TREE_PASS_H) \
$(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(RTL_H) $(IPA_PROP_H) \
$(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(TARGET_H) \
-   $(IPA_UTILS_H)
+   $(IPA_UTILS_H) sreal.h
 ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) 
coretypes.h $(TM_H) \
$(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
$(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) $(CFGLOOP_H) \
Index: gcc/ipa-inline.c
===
--- gcc/ipa-inline.c(revision 200375)
+++ gcc/ipa-inline.c(working copy)
@@ -113,10 +113,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "ipa-inline.h"
 #include "ipa-utils.h"
+#include "sreal.h"
 
 /* Statistics we collect about inlining algorithm.  */
 static int overall_size;
 static gcov_type max_count;
+static sreal max_count_real, max_relbenefit_real, half_int_min_real;
 
 /* Return false when inlining edge E would lead to violating
limits on function unit growth or stack usage growth.  
@@ -887,12 +889,26 @@ edge_badness (struct cgraph_edge *edge, bool dump)
 
   else if (max_count)
 {
+  sreal tmp, relbenefit_real, growth_real;
   int relbenefit = relative_time_benefit (callee_info, edge, edge_time);
-  badness =
-   ((int)
-((double) edge->count * INT_MIN / 2 / max_count / 
RELATIVE_TIME_BENEFIT_RANGE) *
-relbenefit) / growth;
-  
+
+  sreal_init(&relbenefit_real, relbenefit, 0);
+  sreal_init(&growth_real, growth, 0);
+
+  /* relative_edge_count.  */
+  sreal_init (&tmp, edge->count, 0);
+  sreal_div (&tmp, &tmp, &max_count_real);
+
+  /* relative_time_benefit.  */
+  sreal_mul (&tmp, &tmp, &relbenefit_real);
+  sreal_div (&tmp, &tmp, &max_relbenefit_real);
+
+  /* growth_f_caller.  */
+  sreal_mul (&tmp, &tmp, &half_int_min_real);
+  sreal_div (&tmp, &tmp, &growth_real);
+
+  badness = -1 * sreal_to_int (&tmp);
+ 
   /* Be sure that insanity of the profile won't lead to increasing counts
 in the scalling and thus to overflow in the computation above.  */
   gcc_assert (max_count >= edge->count);
@@ -1448,6 +1464,9 @@ inline_small_functions (void)
  if (max_count < edge->count)
max_count = edge->count;
   }
+  sreal_init (&max_count_real, max_count, 0);
+  sreal_init (&max_rel

Go patch committed: Implement method values

2013-06-24 Thread Ian Lance Taylor
Go 1.1 introduced a new language concept: method values.  If a value v
is of some type that implements method M, you can now write v.M and get
a function f.  Calling f with some arguments is exactly like calling v.M
with those same arguments.  In other words, v.M keeps a copy of v and
uses in later uses of f.  This patch adds method values to gccgo.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.8 branch.

Ian

diff -r 281fd093661c go/expressions.cc
--- a/go/expressions.cc	Fri Jun 21 10:53:50 2013 -0700
+++ b/go/expressions.cc	Mon Jun 24 15:02:23 2013 -0700
@@ -1090,6 +1090,15 @@
   return this->statement_->type();
 }
 
+// Determine the type of the expression.
+
+void
+Set_and_use_temporary_expression::do_determine_type(
+const Type_context* context)
+{
+  this->expr_->determine_type(context);
+}
+
 // Take the address.
 
 void
@@ -6626,20 +6635,49 @@
   return Expression::traverse(&this->expr_, traverse);
 }
 
+// Lower the expression.  If this is a method value rather than being
+// called, and the method is accessed via a pointer, we may need to
+// add nil checks.  Introduce a temporary variable so that those nil
+// checks do not cause multiple evaluation.
+
+Expression*
+Bound_method_expression::do_lower(Gogo*, Named_object*,
+  Statement_inserter* inserter, int)
+{
+  // For simplicity we use a temporary for every call to an embedded
+  // method, even though some of them might be pure value methods and
+  // not require a temporary.
+  if (this->expr_->var_expression() == NULL
+  && this->expr_->temporary_reference_expression() == NULL
+  && this->expr_->set_and_use_temporary_expression() == NULL
+  && (this->method_->field_indexes() != NULL
+	  || (this->method_->is_value_method()
+	  && this->expr_->type()->points_to() != NULL)))
+{
+  Temporary_statement* temp =
+	Statement::make_temporary(this->expr_->type(), NULL, this->location());
+  inserter->insert(temp);
+  this->expr_ = Expression::make_set_and_use_temporary(temp, this->expr_,
+			   this->location());
+}
+  return this;
+}
+
 // Return the type of a bound method expression.  The type of this
-// object is really the type of the method with no receiver.  We
-// should be able to get away with just returning the type of the
-// method.
+// object is simply the type of the method with no receiver.
 
 Type*
 Bound_method_expression::do_type()
 {
-  if (this->method_->is_function())
-return this->method_->func_value()->type();
-  else if (this->method_->is_function_declaration())
-return this->method_->func_declaration_value()->type();
+  Named_object* fn = this->method_->named_object();
+  Function_type* fntype;
+  if (fn->is_function())
+fntype = fn->func_value()->type();
+  else if (fn->is_function_declaration())
+fntype = fn->func_declaration_value()->type();
   else
 return Type::make_error_type();
+  return fntype->copy_without_receiver();
 }
 
 // Determine the types of a method expression.
@@ -6647,7 +6685,14 @@
 void
 Bound_method_expression::do_determine_type(const Type_context*)
 {
-  Function_type* fntype = this->type()->function_type();
+  Named_object* fn = this->method_->named_object();
+  Function_type* fntype;
+  if (fn->is_function())
+fntype = fn->func_value()->type();
+  else if (fn->is_function_declaration())
+fntype = fn->func_declaration_value()->type();
+  else
+fntype = NULL;
   if (fntype == NULL || !fntype->is_method())
 this->expr_->determine_type_no_context();
   else
@@ -6662,31 +6707,278 @@
 void
 Bound_method_expression::do_check_types(Gogo*)
 {
-  if (!this->method_->is_function()
-  && !this->method_->is_function_declaration())
-this->report_error(_("object is not a method"));
-  else
-{
-  Type* rtype = this->type()->function_type()->receiver()->type()->deref();
-  Type* etype = (this->expr_type_ != NULL
-		 ? this->expr_type_
-		 : this->expr_->type());
-  etype = etype->deref();
-  if (!Type::are_identical(rtype, etype, true, NULL))
-	this->report_error(_("method type does not match object type"));
-}
-}
-
-// Get the tree for a method expression.  There is no standard tree
-// representation for this.  The only places it may currently be used
-// are in a Call_expression or a Go_statement, which will take it
-// apart directly.  So this has nothing to do at present.
+  Named_object* fn = this->method_->named_object();
+  if (!fn->is_function() && !fn->is_function_declaration())
+{
+  this->report_error(_("object is not a method"));
+  return;
+}
+
+  Function_type* fntype;
+  if (fn->is_function())
+fntype = fn->func_value()->type();
+  else if (fn->is_function_declaration())
+fntype = fn->func_declaration_value()->type();
+  else
+go_unreachable();
+  Type* rtype = fntype->receiver()->type()->deref();
+  Type* etype = (this->expr_type_ != NULL
+		 ? this->expr_type_
+		 : this->expr_->type());
+  etype = etype

Re: [PATCH] Redirect calls to non-functions to builtin_unreachable

2013-06-24 Thread Martin Jambor
Hi,

On Thu, Jun 20, 2013 at 05:46:28PM +0200, Martin Jambor wrote:
> On Thu, Jun 20, 2013 at 03:47:11PM +0100, Marcus Shawcroft wrote:
> > Hi,  I've been looking at an issue in mysql compilation which appears
> > to be due to this patch.
> > 
> > On 10 May 2013 18:27, Martin Jambor  wrote:
> > > Hi,
> > >
> > > as we discover targets of previously indirect calls in ipa-inline and
> > > ipa-cp, we sometimes figure out that the targets are not a function.
> > > One typical example is when NULL is passed as a function pointer
> > 
> > OK, this part makes sense to me.
> > 
> > > parameter, another is when C++ member-pointer points to a virtual
> > > function and the overloaded field of the structure which can also hold
> > > pointers to non-virtual methods contains odd integer constants.
> > 
> > I'm struggling to understand why such a member-pointer call would be
> > illegal in a well formed program.
> > 
> > Attached is a fragment of code that demonstrates the issue I've been
> > looking at.  When compiled at -O3 the 047i.inline dump tells me that:
> > 
> > ipa-prop: Discovered direct call to non-function in unsigned int
> > A::foo(unsigned int (H::*)() const) const/11, making it unreachable.
> >   not inlinable: unsigned int A::foo(unsigned int (H::*)() const)
> > const/11 -> void __builtin_unreachable()/12, function body not
> > available
> > 
> > This behavior appears to be the explicit intent of the original patch,
> > the call to the member function pointer has been replaced with
> > __builtin_unreachable, but that looks like a legitimate  call to me.
> > What am I missing?
> 
> Hm, the reason why I did this was that I misremembered that each
> branch, the one for virtual calls and the one for direct calls.  But
> when I checked dumps, I realized it was not so, there is only one call
> when the branches join.  I'll fix this promptly.
> 
> Thanks for the report,

For the record, this is PR 57670.

Martin


[PATCH, PR 57670] Do not turn member pointers to builtin_unreachable

2013-06-24 Thread Martin Jambor
Hi,

I have made a mistake when I decided to redirect member-pointer calls
to builtin_unreachable because I wrongly thought there are two calls,
one for the VMT lookup and other for non-virtual members and thought
only the second got redirected.  However, even though there are two
different lookups, there is only one call and thus we must refrain
from killing it when the value coming from a caller is not an address
of a function.  I have pondered about overloading the polymorphic flag
for marking member pointer calls but eventually decided to introduce a
new one, as there are plenty bits still available in indirect info and
the added complexity of overloading the flag quickly turned ugly.

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

Thanks and sorry for the confusion,

Martin


2013-06-21  Martin Jambor  

PR middle-end/57670
* cgraph.h (cgraph_indirect_call_info): New flag member_ptr.
* ipa-prop.c (ipa_print_node_jump_functions): Mark member pointer
calls in the dump.
(ipa_note_param_call): Initialize member_ptr flag.
(ipa_analyze_indirect_call_uses): Set member_ptr flag.
(ipa_make_edge_direct_to_target): Bail out if member_ptr is set.
(ipa_write_indirect_edge_info): Stream member_ptr flag.
(ipa_read_indirect_edge_info): Likewise.

testsuite/
* g++.dg/ipa/pr57670.C (H): New test.

Index: src/gcc/cgraph.h
===
--- src.orig/gcc/cgraph.h
+++ src/gcc/cgraph.h
@@ -440,6 +440,8 @@ struct GTY(()) cgraph_indirect_call_info
   /* Set when the call is a call of a pointer loaded from contents of an
  aggregate at offset.  */
   unsigned agg_contents : 1;
+  /* Set when this is a call through a member pointer.  */
+  unsigned member_ptr : 1;
   /* When the previous bit is set, this one determines whether the destination
  is loaded from a parameter passed by reference. */
   unsigned by_ref : 1;
Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -288,8 +288,9 @@ ipa_print_node_jump_functions (FILE *f,
 
   ii = cs->indirect_info;
   if (ii->agg_contents)
-   fprintf (f, "indirect aggregate callsite, calling param %i, "
+   fprintf (f, "indirect %s callsite, calling param %i, "
 "offset " HOST_WIDE_INT_PRINT_DEC ", %s",
+ii->member_ptr ? "member ptr" : "aggregate",
 ii->param_index, ii->offset,
 ii->by_ref ? "by reference" : "by_value");
   else
@@ -1608,6 +1609,7 @@ ipa_note_param_call (struct cgraph_node
   cs->indirect_info->offset = 0;
   cs->indirect_info->polymorphic = 0;
   cs->indirect_info->agg_contents = 0;
+  cs->indirect_info->member_ptr = 0;
   return cs;
 }
 
@@ -1801,6 +1803,7 @@ ipa_analyze_indirect_call_uses (struct c
   struct cgraph_edge *cs = ipa_note_param_call (node, index, call);
   cs->indirect_info->offset = offset;
   cs->indirect_info->agg_contents = 1;
+  cs->indirect_info->member_ptr = 1;
 }
 
   return;
@@ -2212,6 +2215,10 @@ ipa_make_edge_direct_to_target (struct c
   target = canonicalize_constructor_val (target, NULL);
   if (!target || TREE_CODE (target) != FUNCTION_DECL)
{
+ if (ie->indirect_info->member_ptr)
+   /* Member pointer call that goes through a VMT lookup.  */
+   return NULL;
+
  if (dump_file)
fprintf (dump_file, "ipa-prop: Discovered direct call to 
non-function"
" in %s/%i, making it unreachable.\n",
@@ -3765,6 +3772,7 @@ ipa_write_indirect_edge_info (struct out
   bp = bitpack_create (ob->main_stream);
   bp_pack_value (&bp, ii->polymorphic, 1);
   bp_pack_value (&bp, ii->agg_contents, 1);
+  bp_pack_value (&bp, ii->member_ptr, 1);
   bp_pack_value (&bp, ii->by_ref, 1);
   streamer_write_bitpack (&bp);
 
@@ -3791,6 +3799,7 @@ ipa_read_indirect_edge_info (struct lto_
   bp = streamer_read_bitpack (ib);
   ii->polymorphic = bp_unpack_value (&bp, 1);
   ii->agg_contents = bp_unpack_value (&bp, 1);
+  ii->member_ptr = bp_unpack_value (&bp, 1);
   ii->by_ref = bp_unpack_value (&bp, 1);
   if (ii->polymorphic)
 {
Index: src/gcc/testsuite/g++.dg/ipa/pr57670.C
===
--- /dev/null
+++ src/gcc/testsuite/g++.dg/ipa/pr57670.C
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-early-inlining" } */
+
+class H
+{
+public:
+  virtual unsigned bar() const { return 16; }
+};
+
+class A : public H
+{
+  unsigned foo(unsigned (H::*func)(void) const) const;
+public:
+  H *h;
+  virtual unsigned bar() const;
+};
+
+unsigned A::foo(unsigned (H::*func)(void) const) const
+{
+  return  (h->*func)();
+}
+
+unsigned A::bar() const
+{
+  return foo(&H::bar);
+}
+
+int main (int argc, char **argv)
+{
+  H h;
+  A a;
+  a.h = &h;
+
+  if (a.bar() != 16)
+__bu

Re: [wwwdocs] Release note for x86 intrinsics usability

2013-06-24 Thread Sriraman Tallam
On Mon, Jun 24, 2013 at 2:55 PM, Gerald Pfeifer  wrote:
> On Mon, 24 Jun 2013, Sriraman Tallam wrote:
>> IA-32/x86-64
> ^
> Ahem, no. :-)  Please use id="x86" instead.
>
>>   
>>  It is now possible to call x86 intrinsics from select functions in
>>   a file that are marked with the appropriate target attribute without
>>   having to compile the entire file with the -mxxx option.
>
> -mxxx
>
> Do you want to explicit mention the appropirate target attribute?

That depends on the intrinsic used. Maybe I should replace
"appropriate" with "corresponding"?.

>
> Fine with these changes.
>
> Gerald


Re: [wwwdocs] Release note for x86 intrinsics usability

2013-06-24 Thread Gerald Pfeifer
On Mon, 24 Jun 2013, Sriraman Tallam wrote:
> IA-32/x86-64
^
Ahem, no. :-)  Please use id="x86" instead.

>   
>  It is now possible to call x86 intrinsics from select functions in
>   a file that are marked with the appropriate target attribute without
>   having to compile the entire file with the -mxxx option.

-mxxx

Do you want to explicit mention the appropirate target attribute?

Fine with these changes.

Gerald


[wwwdocs] Release note for x86 intrinsics usability

2013-06-24 Thread Sriraman Tallam
Hi,

   I recently committed a patch:
http://gcc.gnu.org/ml/gcc-patches/2013-06/msg01349.html  to allow x86
intrinsics to be called from functions with appropriate target
attributes without having to compile the entire file with -mxxx.  I
have added a release note for this. Please see if this is ok to
commit.

Thanks
Sri
? .changes.html.swp
? x86_intrinsics_release_notes.txt
cvs diff: Diffing .
Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.9/changes.html,v
retrieving revision 1.17
diff -r1.17 changes.html
177a178,187
> IA-32/x86-64
>   
>  It is now possible to call x86 intrinsics from select functions in
>   a file that are marked with the appropriate target attribute without
>   having to compile the entire file with the -mxxx option.  This improves
>   the usability of x86 intrinsics and is particularly useful when doinghref="http://gcc.gnu.org/onlinedocs/gcc/Function-Multiversioning.html";
>   >Function Multiversioning.
> 
>   


Re: [Patch, Fortran] Print floating-point exception status after STOP/ERROR STOP

2013-06-24 Thread Gerald Pfeifer

On Mon, 24 Jun 2013, Tobias Burnus wrote:
I have now committed (Rev. 200360) the attached patch. (Compared to the 
draft patch, with a missing "," added in AC_CHECK_TYPES).


Eric, Gerald: Can you confirm that it now works on both FreeBSD and Solaris?


I can confirm FreeBSD 8.x and 10.x.  Thanks, Tobias!

Gerald


Re: [PATCH, rs6000] power8 patches, patch #8, power8 load fusion + misc.

2013-06-24 Thread David Edelsohn
On Mon, Jun 24, 2013 at 12:31 PM, Michael Meissner
 wrote:

>> This really should have been a separate patch.
>
> Yes, you are right.  I can separate it to be a separate patch if desired.  The
> last I checked, there were still problems in moving to use LRA.  It would be
> nice if we could get the switch for better testing, rather than continuing to
> use a branch.  Right now my focus as been getting the initial power8 changes
> in, so it was added more because it was in the sandbox, I was working from.

We'll continue as is, but this set of patches should have been split
into more pieces with more descriptive ChangeLog entries to ease the
review process.

>
>> +  /* 32-bit is not done yet.  */
>> +  if (TARGET_ELF && !TARGET_POWERPC64)
>> +return 0;
>>
>> What does "32-bit is not done yet." mean? This means PPC32 Linux is
>> not supported but PPC32 AIX is supported?
>
> I don't believe AIX and Linux 64-bit small code model will work with fusion
> loading the GPRs, except in the case where you have more than 64K in the 
> static
> area that the section anchors point to.  It would work with the VSX fusion 
> that
> loads a small constant plus doing hte load.  I tend to feel that restructuring
> the code to allow more general addresses before reload, and have secondary
> reload, generate the appropriate instructions will work better, but that may
> take a longer period to get correct (I'm starting work on it now).
>
> I hadn't gotten around to to looking at 32-bit ELF/Linux.  In theory, 32-bit
> Linux should work well with fusion for non-pic code.

My question is what will break, not what will remain unoptimized. The
comment is not clear and the code addresses only avoids one very
specific target.


>> +  if (TARGET_ELF && !TARGET_POWERPC64)
>> +return 0;
>>
>> Please return "true" and "false" from new predicates, not "1" and "0".
>
> Ok, I was just being constant with the existing code.

Some code uses 0/1 and some uses true/false. Newer code uses true/false.

>
>> +
>> +case DImode:
>> +  if (TARGET_POWERPC64)
>> +{
>> +  mode_name = "long";
>> +  load_str = "ld";
>> +}
>> +  break;
>>
>> What happens for DImode when not TARGET_POWERPC64?  This should be
>> gcc_unreachable()?
>
> There is a gcc_unreachable () at the end of the switch that is reached by
> either an unknown mode (default case), or by DImode on 32-bit.  But I can put
> in two separate gcc_unreachable ()'s.

The current implementation seems like a rather obtuse error path. If
PPC32 DImode is not supported, it would be clearer to fail there, as
opposed to the function called with a garbage or illegal mode.

Thanks, David


Re: [gomp4] Some progress on #pragma omp simd

2013-06-24 Thread Jakub Jelinek
On Tue, Jun 18, 2013 at 02:15:55PM -0500, Aldy Hernandez wrote:
> >Please move simduid after force_vect, so that it is better packed.
> 
> Fixed.
> 
> I also rewrote the builtins to use the internal function doo-dah as
> previously suggested.
> 
> Let me know if this is fine with y'all and you (Jakub) can keep this
> patch and apply it on top of your pending patchset for clauses.

Thanks.  Here is the latest version of the patch, including your fixes.
I've started to add runtime testcases, but already the first one fails
due to issue 1) below.  The lastprivate case is hopefully resolved now
and we already seem to generate correct (and vectorized) code for say:
__attribute__((noinline, noclone)) int
foo2 (int *p)
{
  int i, s = 0;
  #pragma omp simd aligned(a, p : 32) reduction(+:s) lastprivate(l)
  for (i = 0; i < 1024; i++)
{
  a[i] *= p[i];
  s += p[i] + k + (i + 1) * (m + 1);
  l = a[i] + p[i] + i;
}
  return s;
}

Issues I'm struggling with are:
1) The linear clause handling is broken, when each SIMD lane has its
   own private variable, the user code increments that variable by
   whatever the loop body does (which must be equal to the declared
   linear_step), but that is only correct if vectorization factor
   is 1, because otherwise we need to still increment it somewhere by
   the remaining linear_step * (vf - 1).  The array approach is still
   needed at least for the case where the address of the linear privatized
   var is taken, but also because of vectorizer deficiencies.
   For the linear handling, one approach would be to assign the magic
   array element at the start of the loop body to loop iteration #
   times linear step (roughly matching foo function below), this one
   is vectorized, but suboptimal.  Another approach is just have another
   IV that contains the right value, hoping the vectorizer would do the
   expected thing and add vf * (m + 1) to a new vector IV, but the
   vectorizer just gives up on this.  And the last approach would be to
   keep the original user's increment in the loop and add another
   GOMP_SIMD_VF () * linear_step increment somewhere (beginning of the
   loop body (with corresponding adjustment of the initial vals) or
   at the end of the loop body (with a corresponding correction after
   the loop for the final value).  But, as baz function below (everything
   -O3 -mavx2) shows, we don't even merge the two additions and end up
   with two increments even in the vectorized loop (even for signed types,
   I believe if neither x += k nor x += 3 * k overflows, then x += 4 * k
   shouldn't overflow either.  So any preferences what code would be best
   for vectorization?
int a[1024] __attribute__((aligned (32)));
void foo (int k, int m) { int i; for (i = 0; i < 1024; i++) a[i] = k + i * (m + 
1); }
void bar (int k, int m) { int i, k2 = k; for (i = 0; i < 1024; i++) { a[i] = 
k2; k2 += m + 1; } }
void baz (int k, int m) { int i; for (i = 0; i < 1024; i++) { a[i] += k; a[i] 
+= 3 * k; } }

2) the magic array approach still creates too many variables in memory
   which aren't promoted to registers only.  The patch has code to shrink
   the arrays to the actual vectorization factor, but still say int[1]
   is not a GIMPLE type.  Any suggestions how to improve this?
   Already for the shrinking the code looks for all uses of the magic
   GOMP_SIMD_{VF,LANE,LAST_LANE} internal builtins and I need to walk
   the whole IL to find those, perhaps another alternative would be
   just to walk all stmts in the function before vectorization, looking
   say using walk_gimple_op for all stmts mentioning the magic
   "omp simd array" temporary arrays, and note whether all of them
   are convertible from the array representation to something else,
   note those in a hash table and then just after vectorization transform
   all that can be safely transformed (if they have vf 1 to just scalar
   vars with tweaking all uses, for vf > 1 into vectors, and just keep
   what has been addressable as arrays).

3) for better vectorization results, at least for now I think we'll want
   to use the array approach even for private iteration vars in collapse>1
   loops, as they don't seem to be vectorizable right now otherwise
   (vectorizer not liking the PHIs).

--- gcc/internal-fn.def.jj  2013-03-20 10:08:13.024245282 +0100
+++ gcc/internal-fn.def 2013-06-21 11:23:00.616680668 +0200
@@ -40,3 +40,6 @@ along with GCC; see the file COPYING3.
 
 DEF_INTERNAL_FN (LOAD_LANES, ECF_CONST | ECF_LEAF)
 DEF_INTERNAL_FN (STORE_LANES, ECF_CONST | ECF_LEAF)
+DEF_INTERNAL_FN (GOMP_SIMD_LANE, ECF_NOVOPS | ECF_LEAF | ECF_NOTHROW)
+DEF_INTERNAL_FN (GOMP_SIMD_VF, ECF_CONST | ECF_LEAF | ECF_NOTHROW)
+DEF_INTERNAL_FN (GOMP_SIMD_LAST_LANE, ECF_CONST | ECF_LEAF | ECF_NOTHROW)
--- gcc/omp-low.c.jj2013-06-21 08:38:19.085761648 +0200
+++ gcc/omp-low.c   2013-06-24 17:57:57.758930059 +0200
@@ -2508,6 +2508,73 @@ omp_clause_aligned_alignment (tree claus
   return build_int_cst (intege

Re: [Patch, Fortran] Print floating-point exception status after STOP/ERROR STOP

2013-06-24 Thread Eric Botcazou
> Eric, Gerald: Can you confirm that it now works on both FreeBSD and Solaris?

It works fine on Solaris, thanks!

> Eric: Should one (conditionally) include  on Solaris? I
> am asking because LIBGFOR_CHECK_FPSETMASK in acinclude.m4 uses that
> include file during configure - but libgfortran.h (or config/fpu-sysv.h)
> don't.

ieeefp.h is sufficient on Solaris.

-- 
Eric Botcazou


Re: [c++-concepts]: constraint association

2013-06-24 Thread Gabriel Dos Reis
Andrew Sutton  writes:

| Revisions from previous patch.
| 
| I've taken constraint_info out of lang_decl_min and made it specific
| to TEMPLATE_DECLs by saving it as DECL_SIZE_UNIT. It seems to be
| unused for templates. When I start working on the shorthand notation,
| I'll do something similar for template parameters and auto
| declarations.

That sounds good.

| The handling of non-template member functions also changes a little.
| Here's a history of the revisions:
| 
|   - Current branch: the instantiated constraints are stored in
| TEMPLATE_INFO and then checked in add_function_candidate.
|   - Previous patch: instantiated constraints are associated directly
| with the member functions' FUNCTION_DECL.
|   - Current patch: constraints are only instantiated and checked at
| the point of use.

I think that should be OK for now.  If and when needed, we could
use a bit to say the use is OK based on the argument types.  But, for
the moment, I think we should be fine.  In fact, we may not need that
bit at all if we conduct a careful analysis.

| The current patch will lead to redundant checks. I left a comment in
| call.c explaining that we could use a bit in TEMPLATE_INFO to save
| whether or not an instantiated declaration actually satisfies its
| requirements.

See comment below.

|  /* Return a TEMPLATE_DECL corresponding to DECL, using the indicated
| -   template PARMS.  If MEMBER_TEMPLATE_P is true, the new template is
| -   a member template.  Used by push_template_decl below.  */
| +   template PARMS and constraints, CONS.  If MEMBER_TEMPLATE_P is true, 
| +   the new  template is a member template. */
 
| -static tree
| -build_template_decl (tree decl, tree parms, bool member_template_p)
| +tree
| +build_template_decl (tree decl, tree parms, tree cons, bool 
member_template_p)
|  {

GCC source code base is still strongly Lispy, so when one sees 'cons',
one can't avoid association with the function 'cons' (even though it is
in fact spelled tree_cons.)  I would suggest spelling 'constraints' in full.

| +// Access constraints for the declaration, NODE.
| +//
| +// For TEMPLATE_DECL nodes, the constraints are stored in the
| +// DECL_SIZE node.
| +//
| +// TODO: This will need to be updated for shorthand constraints and
| +// constrained auto declarations.
| +#define DECL_CONSTRAINTS(NODE) \
| +  (DECL_SIZE_UNIT (TEMPLATE_DECL_CHECK (NODE)))

The comment should say DECL_SIZE_UNIT, not DECL_SIZE (which is
used to store specializations.)


Patch OK with the suggested fixes.  Thanks,

-- Gaby


Re: [PATCH] Change the badness computation to ensure no integer-underflow

2013-06-24 Thread Dehao Chen
Hi, Richard,

I've updated the patch (as attached) to use sreal to compute badness.

Thanks,
Dehao

On Mon, Jun 24, 2013 at 5:41 AM, Richard Biener
 wrote:
> On Sat, Jun 22, 2013 at 2:59 AM, Dehao Chen  wrote:
>> This patch prevents integer-underflow of badness computation in ipa-inline.
>>
>> Bootstrapped and passed regression tests.
>>
>> OK for trunk?
>>
>> Thanks,
>> Dehao
>>
>> gcc/ChangeLog:
>> 2013-06-21  Dehao Chen  
>>
>> * ipa-inline.c (edge_badness): Fix integer underflow.
>>
>> Index: gcc/ipa-inline.c
>> ===
>> --- gcc/ipa-inline.c (revision 200326)
>> +++ gcc/ipa-inline.c (working copy)
>> @@ -888,11 +888,9 @@ edge_badness (struct cgraph_edge *edge, bool dump)
>>else if (max_count)
>>  {
>>int relbenefit = relative_time_benefit (callee_info, edge, edge_time);
>> -  badness =
>> - ((int)
>> - ((double) edge->count * INT_MIN / 2 / max_count /
>> RELATIVE_TIME_BENEFIT_RANGE) *
>> - relbenefit) / growth;
>> -
>> +  badness = ((int)((double) edge->count / max_count
>> +  * relbenefit / RELATIVE_TIME_BENEFIT_RANGE * INT_MIN / 2)) / growth;
>> +
>
> FP operations on the host are frowned upon if code generation depends
> on their outcome.  They all should use sreal_* as predict already does.
> Other than that I wonder why the final division is int (so we get truncation
> and not rounding)?  That increases the effect of doing the multiply by
> relbenefit in double.
>
> Richard.
>
>>/* Be sure that insanity of the profile won't lead to increasing 
>> counts
>>   in the scalling and thus to overflow in the computation above.  */
>>gcc_assert (max_count >= edge->count);
Index: gcc/ipa-inline.c
===
--- gcc/ipa-inline.c(revision 200326)
+++ gcc/ipa-inline.c(working copy)
@@ -113,10 +113,12 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "ipa-inline.h"
 #include "ipa-utils.h"
+#include "sreal.h"
 
 /* Statistics we collect about inlining algorithm.  */
 static int overall_size;
 static gcov_type max_count;
+static sreal max_count_real, max_relbenefit_real, half_int_min_real;
 
 /* Return false when inlining edge E would lead to violating
limits on function unit growth or stack usage growth.  
@@ -887,12 +889,26 @@ edge_badness (struct cgraph_edge *edge, bool dump)
 
   else if (max_count)
 {
+  sreal tmp, relbenefit_real, growth_real;
   int relbenefit = relative_time_benefit (callee_info, edge, edge_time);
-  badness =
-   ((int)
-((double) edge->count * INT_MIN / 2 / max_count / 
RELATIVE_TIME_BENEFIT_RANGE) *
-relbenefit) / growth;
-  
+
+  sreal_init(&relbenefit_real, relbenefit, 0);
+  sreal_init(&growth_real, growth, 0);
+
+  /* relative_edge_count.  */
+  sreal_init (&tmp, edge->count, 0);
+  sreal_div (&tmp, &tmp, &max_count_real);
+
+  /* relative_time_benefit.  */
+  sreal_mul (&tmp, &tmp, &relbenefit_real);
+  sreal_div (&tmp, &tmp, &max_relbenefit_real);
+
+  /* growth_f_caller.  */
+  sreal_mul (&tmp, &tmp, &half_int_min_real);
+  sreal_div (&tmp, &tmp, &growth_real);
+
+  badness = sreal_to_int (&tmp);
+ 
   /* Be sure that insanity of the profile won't lead to increasing counts
 in the scalling and thus to overflow in the computation above.  */
   gcc_assert (max_count >= edge->count);
@@ -1448,6 +1464,9 @@ inline_small_functions (void)
  if (max_count < edge->count)
max_count = edge->count;
   }
+  sreal_init (&max_count_real, max_count, 0);
+  sreal_init (&max_relbenefit_real, RELATIVE_TIME_BENEFIT_RANGE, 0);
+  sreal_init (&half_int_min_real, INT_MIN / 2, 0);
   ipa_free_postorder_info ();
   initialize_growth_caches ();
 
Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 200326)
+++ gcc/ChangeLog   (working copy)
@@ -1,3 +1,7 @@
+2013-06-21  Dehao Chen  
+
+   * ipa-inline.c (edge_badness): Fix integer underflow.
+
 2013-06-21  Andi Kleen  
 
* doc/extend.texi: Dont use __atomic_clear in HLE
Index: gcc/Makefile.in
===
--- gcc/Makefile.in (revision 200326)
+++ gcc/Makefile.in (working copy)
@@ -2947,7 +2947,7 @@ ipa-inline.o : ipa-inline.c $(CONFIG_H) $(SYSTEM_H
$(DIAGNOSTIC_H) $(FIBHEAP_H) $(PARAMS_H) $(TREE_PASS_H) \
$(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(RTL_H) $(IPA_PROP_H) \
$(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) $(IPA_INLINE_H) $(TARGET_H) \
-   $(IPA_UTILS_H)
+   $(IPA_UTILS_H) sreal.h
 ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) 
coretypes.h $(TM_H) \
$(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
$(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) $(CFGLOOP_H) \


Re: [PATCH, rs6000] power8 patches, patch #8, power8 load fusion + misc.

2013-06-24 Thread Michael Meissner
On Tue, Jun 18, 2013 at 02:30:49PM -0400, David Edelsohn wrote:
> On Wed, May 22, 2013 at 4:52 PM, Michael Meissner
>  wrote:
> 
> > 2013-05-22  Michael Meissner  
> >
> > * config/rs6000/predicates.md (fusion_gpr_addis): New predicates
> > to support power8 load fusion.
> > (fusion_gpr_mem_load): Likewise.
> >
> > * config/rs6000/rs6000-modes.def (PTImode): Update a comment.
> >
> > * config/rs6000/rs6000-protos.h (fusion_gpr_load_p): New
> > declarations for power8 load fusion.
> > (emit_fusion_gpr_load): Likewise.
> >
> > * config/rs6000/rs6000.opt (-mlra): New undocumented switch to
> > turn on using the LRA register allocator.
> > (-mconstrain-regs): New undocumented switch to constrain
> > non-integer values from being loaded into the LR or CTR registers.
> 
> This really should have been a separate patch.

Yes, you are right.  I can separate it to be a separate patch if desired.  The
last I checked, there were still problems in moving to use LRA.  It would be
nice if we could get the switch for better testing, rather than continuing to
use a branch.  Right now my focus as been getting the initial power8 changes
in, so it was added more because it was in the sandbox, I was working from.

> +  /* 32-bit is not done yet.  */
> +  if (TARGET_ELF && !TARGET_POWERPC64)
> +return 0;
> 
> What does "32-bit is not done yet." mean? This means PPC32 Linux is
> not supported but PPC32 AIX is supported?

I don't believe AIX and Linux 64-bit small code model will work with fusion
loading the GPRs, except in the case where you have more than 64K in the static
area that the section anchors point to.  It would work with the VSX fusion that
loads a small constant plus doing hte load.  I tend to feel that restructuring
the code to allow more general addresses before reload, and have secondary
reload, generate the appropriate instructions will work better, but that may
take a longer period to get correct (I'm starting work on it now).

I hadn't gotten around to to looking at 32-bit ELF/Linux.  In theory, 32-bit
Linux should work well with fusion for non-pic code.

> +  if (TARGET_ELF && !TARGET_POWERPC64)
> +return 0;
> 
> Please return "true" and "false" from new predicates, not "1" and "0".

Ok, I was just being constant with the existing code.

> +
> +case DImode:
> +  if (TARGET_POWERPC64)
> +{
> +  mode_name = "long";
> +  load_str = "ld";
> +}
> +  break;
> 
> What happens for DImode when not TARGET_POWERPC64?  This should be
> gcc_unreachable()?

There is a gcc_unreachable () at the end of the switch that is reached by
either an unknown mode (default case), or by DImode on 32-bit.  But I can put
in two separate gcc_unreachable ()'s.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797



Re: C++ PATCH: Change reference to cxx0x to cxx11

2013-06-24 Thread Gabriel Dos Reis
Jason Merrill  writes:

| OK, but please also remove the cxx0x enumerator so that uses don't
| creep in again.

Indeed, that was the follow up patch that I'm preparing separately along
with another fixlet.

-- Gaby


Re: [c++-concepts]: constraint association

2013-06-24 Thread Andrew Sutton
Revisions from previous patch.

I've taken constraint_info out of lang_decl_min and made it specific
to TEMPLATE_DECLs by saving it as DECL_SIZE_UNIT. It seems to be
unused for templates. When I start working on the shorthand notation,
I'll do something similar for template parameters and auto
declarations.

The handling of non-template member functions also changes a little.
Here's a history of the revisions:

  - Current branch: the instantiated constraints are stored in
TEMPLATE_INFO and then checked in add_function_candidate.
  - Previous patch: instantiated constraints are associated directly
with the member functions' FUNCTION_DECL.
  - Current patch: constraints are only instantiated and checked at
the point of use.

The current patch will lead to redundant checks. I left a comment in
call.c explaining that we could use a bit in TEMPLATE_INFO to save
whether or not an instantiated declaration actually satisfies its
requirements.


Andrew



On Sat, Jun 22, 2013 at 6:43 PM, Gabriel Dos Reis  wrote:
> Andrew Sutton  writes:
>
> | > | But, I don't think we have a single TEMPLATE_PARM_DECL node. Template
> | > | parameters are either TYPE_DECLs or PARM_DECLs. I think auto
> | > | declarations, get VAR_DECLs, but I haven't looked closely at that
> | > | design. I'd have to look to see if there are any free tree slots all
> | > | of those decl nodes to minimize.
> | >
> | > The individual constraint for a template parameter should probably go
> | > with the TEMPLATE_PARM_INDEX which is the uniform representation of
> | > template parameters.  But, the real cumulative constraints go with the
> | > TEMPLATE_DECLs.  With Jason's patch that creates TEMPLATE_DECLs for
> | > partial instantiations, I believe we have all the bases covered.
> |
> | I have to look through the template parameter creation code, but that
> | sounds about right.
>
> build_template_parm-- the real (low-level) constructor
> process_template_parm  -- higher-level interface to the parsing
> make_auto_1 -- for type of variables declared with 'auto'.
>
> -- Gaby
>



-- 
Andrew Sutton
andrew.n.sut...@gmail.com


template-decl-2.patch
Description: Binary data


[PATCH, AArch64] Update insv_1.c test for Big Endian

2013-06-24 Thread Ian Bolton
Hi,

The insv_1.c test case I added recently was not compatible with big endian.
I attempted to fix with #ifdefs but dejagnu thinks all dg directives in a
file, regardless of #ifdefs, are applicable, so I had to instead make a
new test and add a new effective target to show when each test is supported.
 
I've tested these two tests on little and big.  All was OK.

OK for trunk?

Cheers,
Ian


2013-06-24  Ian Bolton  

* gcc.target/config/aarch64/insv_1.c: Update to show it doesn't work
on big endian.
* gcc.target/config/aarch64/insv_2.c: New test for big endian.
* lib/target-supports.exp: Define aarch64_little_endian.diff --git a/gcc/testsuite/gcc.target/aarch64/insv_1.c 
b/gcc/testsuite/gcc.target/aarch64/insv_1.c
index bc8928d..6e3c7f0 100644
--- a/gcc/testsuite/gcc.target/aarch64/insv_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/insv_1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
+/* { dg-do run { target aarch64*-*-* } } */
 /* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_little_endian } */
 
 extern void abort (void);
 
diff --git a/gcc/testsuite/gcc.target/aarch64/insv_2.c 
b/gcc/testsuite/gcc.target/aarch64/insv_2.c
new file mode 100644
index 000..a7691a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/insv_2.c
@@ -0,0 +1,85 @@
+/* { dg-do run { target aarch64*-*-* } } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_big_endian } */
+
+extern void abort (void);
+
+typedef struct bitfield
+{
+  unsigned short eight: 8;
+  unsigned short four: 4;
+  unsigned short five: 5;
+  unsigned short seven: 7;
+  unsigned int sixteen: 16;
+} bitfield;
+
+bitfield
+bfi1 (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 56, 8" } } */
+  a.eight = 3;
+  return a;
+}
+
+bitfield
+bfi2 (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 43, 5" } } */
+  a.five = 7;
+  return a;
+}
+
+bitfield
+movk (bitfield a)
+{
+  /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0x1d6b, lsl 16" } } */
+  a.sixteen = 7531;
+  return a;
+}
+
+bitfield
+set1 (bitfield a)
+{
+  /* { dg-final { scan-assembler "orr\tx\[0-9\]+, x\[0-9\]+, 272678883688448" 
} } */
+  a.five = 0x1f;
+  return a;
+}
+
+bitfield
+set0 (bitfield a)
+{
+  /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, -272678883688449" 
} } */
+  a.five = 0;
+  return a;
+}
+
+
+int
+main (int argc, char** argv)
+{
+  static bitfield a;
+  bitfield b = bfi1 (a);
+  bitfield c = bfi2 (b);
+  bitfield d = movk (c);
+
+  if (d.eight != 3)
+abort ();
+
+  if (d.five != 7)
+abort ();
+
+  if (d.sixteen != 7531)
+abort ();
+
+  d = set1 (d);
+  if (d.five != 0x1f)
+abort ();
+
+  d = set0 (d);
+  if (d.five != 0)
+abort ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index a80078a..aca4215 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2105,6 +2105,15 @@ proc check_effective_target_aarch64_big_endian { } {
 }]
 }
 
+# Return 1 if this is a AArch64 target supporting little endian
+proc check_effective_target_aarch64_little_endian { } {
+return [check_no_compiler_messages aarch64_little_endian assembly {
+#if !defined(__aarch64__) || defined(__AARCH64EB__)
+#error FOO
+#endif
+}]
+}
+
 # Return 1 is this is an arm target using 32-bit instructions
 proc check_effective_target_arm32 { } {
 return [check_no_compiler_messages arm32 assembly {


Re: [patch 4/5] fix bugs with -fstrict-volatile-bitfields and packed structures

2013-06-24 Thread Eric Botcazou
> This part of the patch series fixes problems with bad code being emitted
> for unaligned bitfield accesses, as reported in PRs 48784, 56341, and
> 56997.  A secondary goal of this patch was making the bitfield store and
> extract code follow similar logic, at least for the parts relating to
> -fstrict-volatile-bitfield handling.

Thanks for tackling this.  I think we all agree that making the store and 
extract paths follow a similar logic would be a step forward.  Some remarks:

 - the extract_fixed_bit_field changes look good to me (nice cleanup!) modulo 
s/type/mode/ in the added comment,

 - the store_fixed_bit_field changes are less immediate, as the fallback isn't 
the default behavior (contrary to what the comment says).  I presume that this 
is intended?

 - the extract_bit_field_1 changes look good to me (modulo a superfluous "of 
the field" in the first added comment) but I don't really understand the 
ChangeLog entry; I'd just write "do not short-circuit direct extraction for
flag_strict_volatile_bitfields handling" or something along these lines.

-- 
Eric Botcazou


Re: [c++-concepts] code review

2013-06-24 Thread Jason Merrill

On 06/21/2013 08:46 AM, Andrew Sutton wrote:

I can move those patches over to git and push the changes in separate
branches in addition to the usual submission mechanism. Would that be
appropriate? Can I create a bunch of different git branches for small
feature sets?


Sure, that sounds fine.

Jason




Re: C++ PATCH: Change reference to cxx0x to cxx11

2013-06-24 Thread Jason Merrill
OK, but please also remove the cxx0x enumerator so that uses don't creep 
in again.


Jason


Re: [PATCH] Cilk Plus Array Notation for C++

2013-06-24 Thread Jason Merrill

A few more comments:


+ if (processing_template_decl || !TREE_TYPE (t))
+   new_var = build_min_nt_loc (EXPR_LOCATION (t), VAR_DECL, NULL_TREE,
+   NULL_TREE);


Again, we shouldn't be trying to expand array notation during template 
parsing.


And replace_invariant_exprs should also use get_temp_regvar, as should 
most of the places you create temporary variables.



+  /* We need to do this because we are "faking" the builtin function types,
+so the compiler does a bunch of typecasts and this will get rid of
+all that!  */


Again, magic_varargs_p can avoid any gratuitous type conversions.


+case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO:
+case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO:
+case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO:
+case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO:
+  new_var_type = integer_type_node;


I would expect boolean_type_node.


+  an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
+ TREE_TYPE (an_info[0][ii].start));


Here you can use create_temporary_var.


+  an_loop_info[ii].ind_init = build_x_modify_expr
+   (location, an_loop_info[ii].var, NOP_EXPR,
+build_zero_cst (TREE_TYPE (an_loop_info[ii].var)),
+tf_warning_or_error);


Here and in other calls to build_x_modify_expr for initialization, use 
INIT_EXPR rather than NOP_EXPR.



+   *new_var = create_tmp_var (new_var_type, NULL);


create_tmp_var is part of gimplification; it might be appropriate to use 
it when you move lowering to happen later in the compilation, but it 
seems wrong in the current code.



+  code = (an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO) ? EQ_EXPR
+   : NE_EXPR;


A ?: expression split across multiple lines should have parens around it.


+  /* If both are scalar, then the only reason why we will get this far is if
+ there is some array notations inside it and was using a builtin array
+ notation functions.  If so, we have already broken those guys up and now
+ a simple build_x_modify_expr would do.  */
+  if (lhs_rank == 0 && rhs_rank == 0)
+{
+  if (found_builtin_fn)
+   {
+ new_modify_expr = build_x_modify_expr (location, lhs,
+modifycode, rhs, complain);
+ finish_expr_stmt (new_modify_expr);
+ pop_stmt_list (an_init);
+ return an_init;
+   }
+  else
+   {
+ pop_stmt_list (an_init);
+ return NULL_TREE;
+   }
+}


The comment makes it sound like the else should be gcc_unreachable.


+  if (location == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (rhs))
+   location = EXPR_LOCATION (rhs);


This is redundant with code a few lines above.


+ append_to_statement_list_force (lhs_an_loop_info[ii].ind_init,
+ &init_list);


Why do you need _force?

Jason



Re: [RS6000] libffi little-endian

2013-06-24 Thread Anthony Green
It's fine with me.  Please commit it directly to GCC and I'll put it in the 
upstream.

Thanks!

AG


- Original Message -
From: "David Edelsohn" 
To: "GCC Patches" , libffi-disc...@sourceware.org, 
"Alan Modra" 
Sent: Sunday, June 23, 2013 10:32:44 PM
Subject: Re: [RS6000] libffi little-endian

On Sun, Jun 23, 2013 at 8:26 PM, Alan Modra  wrote:
> On Fri, Jun 07, 2013 at 12:12:17AM -0400, David Edelsohn wrote:
>> On Thu, Jun 6, 2013 at 9:34 PM, Alan Modra  wrote:
>> > Bootstrapped and regression tested powerpc64-linux.  OK to apply?
>> >
>> > * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Support
>> > little-endian.
>> > * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise.
>>
>> This patch needs to be applied upstream in the libffi repository.
>>
>> All of the handling of structs in ffi.c and ffi_darwin.c doesn't need
>> any changes?  Cool.  I thought there might be a padding issue.
>
> You were right, of course.  When we finally got around to running an
> all languages bootstrap on powerpc64le, we discovered some missing
> pieces in libffi.  The following adds some ffi.c changes to the
> previous patch (closure.S patches are unchanged).  I haven't tackled
> ffi_darwin.c.
>
> Bootstrapped and regression tested powerpc64-linux.  This one passes
> the libffi testsuite on powerpc64le-linux.  OK mainline and 4.8?
>
> * src/powerpc/ffi.c (ffi_prep_args_SYSV): Move var declaration
> before statements.
> (ffi_prep_args64): Support little-endian.
> (ffi_closure_helper_SYSV, ffi_closure_helper_LINUX64): Likewise.
> * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise.
> * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise.

This looks okay to me and more like the changes I expected.  Assuming
Anthony accepts it upstream.

Thanks, David


Re: [PATCH, libcpp] Do not decrease highest_location if the included file has be included twice.

2013-06-24 Thread Tom Tromey
> "Dehao" == Dehao Chen  writes:

Dehao> Thanks for helping update the patch. The new patch passed all
Dehao> regression test and can fix the problem in my huge source file. I
Dehao> added ChangeLog entry to the patch. Could any libcpp maintainers help
Dehao> check if it is ok for trunk?

I'm sorry about the delay on this.

Dehao> 2013-06-04  Dehao Chen  
Dehao>  * files.c (_cpp_stack_include): Fix the highest_location when header
Dehao>  file is guarded by #ifndef and is included twice.

This is ok.  Thanks.

Tom


[PATCH] Fix PR57521

2013-06-24 Thread Richard Biener

The following fixes a long-standing bug in tree if-conversion.
The transform phase relies on being able to extract edge predicates
by simply using the predicate under which its source block is
executed.  That obviously isn't the correct one if the source
block ends in a condition itself.  Thus the following patch
verifies that each predecessor edge of blocks we will if-convert
is non-critical.

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

Richard.

2013-06-24  Richard Biener  

PR tree-optimization/57521
* tree-if-conv.c (if_convertible_bb_p): Verify that all edges
are non-critical.
(pass_if_conversion): Add TODO_verify_ssa.

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

Index: gcc/tree-if-conv.c
===
*** gcc/tree-if-conv.c  (revision 200367)
--- gcc/tree-if-conv.c  (working copy)
*** if_convertible_bb_p (struct loop *loop,
*** 873,878 
--- 873,886 
&& !bb_postdominates_preds (bb))
  return false;
  
+   /* All incoming edges have to be non-critical as otherwise edge
+  predicates are not equal to basic-block predicates of the edge
+  source.  */
+   if (EDGE_COUNT (bb->preds) > 1)
+ FOR_EACH_EDGE (e, ei, bb->preds)
+   if (EDGE_COUNT (e->src->succs) > 1)
+   return false;
+ 
return true;
  }
  
*** struct gimple_opt_pass pass_if_conversio
*** 1870,1875 
0,  /* properties_destroyed */
0,  /* todo_flags_start */
TODO_verify_stmts | TODO_verify_flow
! /* todo_flags_finish */
   }
  };
--- 1878,1883 
0,  /* properties_destroyed */
0,  /* todo_flags_start */
TODO_verify_stmts | TODO_verify_flow
! | TODO_verify_ssa /* todo_flags_finish */
   }
  };
Index: gcc/testsuite/gcc.dg/torture/pr57521.c
===
*** gcc/testsuite/gcc.dg/torture/pr57521.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr57521.c  (working copy)
***
*** 0 
--- 1,51 
+ /* { dg-do run } */
+ /* { dg-options "-ftree-loop-if-convert" } */
+ 
+ void abort (void);
+ 
+ int a, b, c, d, o = 1, p;
+ short e;
+ 
+ int
+ fn1 (int * p1)
+ {
+   int f, g, h, j = 0, k = 0, l = 0;
+   unsigned int i;
+   int *m[1] = { &l };
+   for (; b >= 0; b--)
+ {
+   if (*p1)
+   if (j >= 0)
+ {
+   int n = 1;
+   e = 1;
+   h = a ? a : 1 % n;
+   g = h > 0 ? 0 : h + 1;
+   k = c + g;
+ }
+   else
+ continue;
+   else
+   {
+ 
+ f = d > 0 ? 0 : d + 1;
+ i = f;
+ j = 1 + i;
+   }
+   l++;
+ }
+   return k;
+ }
+ 
+ int
+ main ()
+ {
+   for (;; p++)
+ {
+   fn1 (&o);
+   break;
+ }
+   if (e != 1)
+ abort ();
+   return 0;
+ }


Re: [ping] [patch 4/5] fix bugs with -fstrict-volatile-bitfields and packed structures

2013-06-24 Thread Sandra Loosemore

On 06/24/2013 06:31 AM, Richard Biener wrote:

On Sun, Jun 23, 2013 at 6:17 PM, Sandra Loosemore
 wrote:

On 06/16/2013 01:08 PM, Sandra Loosemore wrote:


This part of the patch series fixes problems with bad code being emitted
for unaligned bitfield accesses, as reported in PRs 48784, 56341, and
56997.  A secondary goal of this patch was making the bitfield store and
extract code follow similar logic, at least for the parts relating to
-fstrict-volatile-bitfield handling.



Is it possible to get this part of the patch series reviewed?  Except for
the documentation change, it is independent of the controversy surrounding
part 3 regarding whether the target ABI or C/C++ standard should take
precedence when they conflict, and is independent of any further patches to
change the default -fstrict-volatile-bitfields setting.  If the rest of the
patch is approved, I'll take care to fix up invoke.texi to accurately
reflect the behavior of the approved patches before checking anything in.

http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00911.html


It looks sensible to me but I'd like to have Eric have a 2nd look as he is most
familiar with this code.


OK.  Meanwhile there have been some comments in PR56997 indicating that 
this patch still isn't quite right, so I am going to have to tinker with 
it a bit more.


To tell the truth, I've also been somewhat unhappy with the current 
version; I'd much rather restructure the code further so that we check 
for the -fstrict-volatile-bitfields case once at the top instead of 
having to special-case 3 or 4 places deep down in the code to do 
something different.  The current version seemed like a more 
conservative incremental change, but if it's still not correct it might 
be better to bite the bullet on the refactoring.  Anyway, I will spend a 
few more days on it and post a revised patch for review.


-Sandra




[PATCH][RFC] Fix PR57656

2013-06-24 Thread Richard Biener

This fixes the miscompile in PR57656 - folding of

  int t = 1 - (a - b) / c;

to

  int t = (b - a) / c + 1;

which introduces intermediate undefined overflow for
a == -1 and b == INT_MAX.

There seems to be a mix of assumptions of the context
negate_expr_p is called in - for example the comments
and the code suggests that when checking whether
negate_expr_p (A - B) is true then we assume there
is a user-written - (A - B) expression (and thus
we'll at most remove an overflow).  But we happily
recurse for binary operands (which means re-associating
the negate with the operation) for multiplications
and divisions.  Considering - ((A - B) * C) then the
folding to (B - A) * C _introduces_ an intermediate
overflow if C is zero and A == -1 and B == INT_MAX.
So with the notion that the input is always a negation
present in user code the recursion is wrong.  And
if not, then at least the MINUS_EXPR case is wrong.

For maximum benefit the API should probably be split
so that it specifies whether there is a negation in
place that we want to remove or not which we then
can use for the recursion.

Anyway - here is a patch that fixes the testcase by
simply avoiding the recursion in the division case,
handling only two obvious cases as any re-org as
outlined above is certainly not good for backporting.
(and a re-org attempt should probably try to unify
the three functions negate_expr_p, negate_expr and
fold_negate_expr again)

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

Any comments?  Is the patch below ok for trunk and branches
in the mean time?

Thanks,
Richard.

2013-06-24  Richard Biener  

PR middle-end/57656
* fold-const.c (negate_expr_p): Fix division case.
(negate_expr): Likewise.

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

Index: gcc/fold-const.c
===
*** gcc/fold-const.c(revision 200363)
--- gcc/fold-const.c(working copy)
*** negate_expr_p (tree t)
*** 483,493 
 and actually traps on some architectures.  But if overflow is
 undefined, we can negate, because - (INT_MIN / 1) is an
 overflow.  */
!   if (INTEGRAL_TYPE_P (TREE_TYPE (t))
! && !TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (t)))
! break;
!   return negate_expr_p (TREE_OPERAND (t, 1))
!  || negate_expr_p (TREE_OPERAND (t, 0));
  
  case NOP_EXPR:
/* Negate -((double)float) as (double)(-float).  */
--- 483,506 
 and actually traps on some architectures.  But if overflow is
 undefined, we can negate, because - (INT_MIN / 1) is an
 overflow.  */
!   if (INTEGRAL_TYPE_P (TREE_TYPE (t)))
!   {
! if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (t)))
!   break;
! /* If overflow is undefined then we have to be careful because
!we ask whether it's ok to associate the negate with the
!division which is not ok for example for
!-((a - b) / c) where (-(a - b)) / c may invoke undefined
!overflow because of negating INT_MIN.  So do not use
!negate_expr_p here but open-code the two important cases.  */
! if (TREE_CODE (TREE_OPERAND (t, 0)) == NEGATE_EXPR
! || (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST
! && may_negate_without_overflow_p (TREE_OPERAND (t, 0
!   return true;
!   }
!   else if (negate_expr_p (TREE_OPERAND (t, 0)))
!   return true;
!   return negate_expr_p (TREE_OPERAND (t, 1));
  
  case NOP_EXPR:
/* Negate -((double)float) as (double)(-float).  */
*** fold_negate_expr (location_t loc, tree t
*** 682,697 
  return fold_build2_loc (loc, TREE_CODE (t), type,
  TREE_OPERAND (t, 0), negate_expr (tem));
}
tem = TREE_OPERAND (t, 0);
!   if (negate_expr_p (tem))
!   {
! if (INTEGRAL_TYPE_P (type)
! && (TREE_CODE (tem) != INTEGER_CST
! || tree_int_cst_equal (tem, TYPE_MIN_VALUE (type
!   fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC);
! return fold_build2_loc (loc, TREE_CODE (t), type,
! negate_expr (tem), TREE_OPERAND (t, 1));
!   }
  }
break;
  
--- 695,714 
  return fold_build2_loc (loc, TREE_CODE (t), type,
  TREE_OPERAND (t, 0), negate_expr (tem));
}
+ /* If overflow is undefined then we have to be careful because
+we ask whether it's ok to associate the negate with the
+division which is not ok for example for
+-((a - b) / c) where (-(a - b)) / c may invoke undefined
+overflow because of negating INT_MIN.  So do not use
+negate_expr_p here but open-code the two important cases.  */
tem = TREE_OPERAND 

[PATCH] Fix PR56977

2013-06-24 Thread Richard Biener

With -Og we do no constant propagation after folding all remaining
builtins which is a problem when RTL expansion issues errors
such as those for function calls to functions with the error
attribute.

Fixed as follows, bootstrap and regtest pending on 
x86_64-unknown-linux-gnu.

Richard.

2013-06-24  Richard Biener  

PR middle-end/56977
* passes.c (init_optimization_passes): Move pass_fold_builtins
and pass_dce earlier with -Og.

* gcc.dg/pr56977.c: New testcase.

Index: gcc/passes.c
===
*** gcc/passes.c(revision 200367)
--- gcc/passes.c(working copy)
*** init_optimization_passes (void)
*** 1536,1550 
/* Perform simple scalar cleanup which is constant/copy propagation.  */
NEXT_PASS (pass_ccp);
NEXT_PASS (pass_object_sizes);
/* Copy propagation also copy-propagates constants, this is necessary
!  to forward object-size results properly.  */
NEXT_PASS (pass_copy_prop);
NEXT_PASS (pass_asan);
NEXT_PASS (pass_tsan);
NEXT_PASS (pass_rename_ssa_copies);
-   NEXT_PASS (pass_dce);
-   /* Fold remaining builtins.  */
-   NEXT_PASS (pass_fold_builtins);
/* ???  We do want some kind of loop invariant motion, but we possibly
   need to adjust LIM to be more friendly towards preserving accurate
 debug information here.  */
--- 1536,1550 
/* Perform simple scalar cleanup which is constant/copy propagation.  */
NEXT_PASS (pass_ccp);
NEXT_PASS (pass_object_sizes);
+   /* Fold remaining builtins.  */
+   NEXT_PASS (pass_fold_builtins);
/* Copy propagation also copy-propagates constants, this is necessary
!  to forward object-size and builtin folding results properly.  */
NEXT_PASS (pass_copy_prop);
+   NEXT_PASS (pass_dce);
NEXT_PASS (pass_asan);
NEXT_PASS (pass_tsan);
NEXT_PASS (pass_rename_ssa_copies);
/* ???  We do want some kind of loop invariant motion, but we possibly
   need to adjust LIM to be more friendly towards preserving accurate
 debug information here.  */
Index: gcc/testsuite/gcc.dg/pr56977.c
===
*** gcc/testsuite/gcc.dg/pr56977.c  (revision 0)
--- gcc/testsuite/gcc.dg/pr56977.c  (working copy)
***
*** 0 
--- 1,10 
+ /* { dg-do compile } */
+ /* { dg-options "-Og" } */
+ 
+ __attribute__((__error__("error"))) void error ();
+ 
+ void f (int i) {
+ if (__builtin_constant_p (i)) {
+   error ();
+ }
+ }


[v3] libstdc++/57691

2013-06-24 Thread Paolo Carlini

Hi,

see audit trail for details. Committed to mainline.

Thanks,
Paolo.

//
2013-06-24  Bernd Edlinger  

PR libstdc++/57691
* include/c_global/cstdlib (atexit, at_quick_exit): If !_GLIBCC_HOSTED,
declare per the letter of the C++ standard in terms of void.
* include/c_std/cstdlib: Likewise.
Index: include/c_global/cstdlib
===
--- include/c_global/cstdlib(revision 200352)
+++ include/c_global/cstdlib(working copy)
@@ -55,11 +55,11 @@
 namespace std
 {
   extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
-  extern "C" int atexit(void (*)()) throw ();
+  extern "C" int atexit(void (*)(void)) throw ();
   extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
 #if __cplusplus >= 201103L
 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
-  extern "C" int at_quick_exit(void (*)()) throw ();
+  extern "C" int at_quick_exit(void (*)(void)) throw ();
 # endif
 # ifdef _GLIBCXX_HAVE_QUICK_EXIT
   extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;
Index: include/c_std/cstdlib
===
--- include/c_std/cstdlib   (revision 200352)
+++ include/c_std/cstdlib   (working copy)
@@ -55,11 +55,11 @@
 namespace std
 {
   extern "C" void abort(void) throw () _GLIBCXX_NORETURN;
-  extern "C" int atexit(void (*)()) throw ();
+  extern "C" int atexit(void (*)(void)) throw ();
   extern "C" void exit(int) throw () _GLIBCXX_NORETURN;
 #if __cplusplus >= 201103L
 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
-  extern "C" int at_quick_exit(void (*)()) throw ();
+  extern "C" int at_quick_exit(void (*)(void)) throw ();
 # endif
 # ifdef _GLIBCXX_HAVE_QUICK_EXIT
   extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN;


Re: [PATCH] Change the badness computation to ensure no integer-underflow

2013-06-24 Thread Richard Biener
On Sat, Jun 22, 2013 at 2:59 AM, Dehao Chen  wrote:
> This patch prevents integer-underflow of badness computation in ipa-inline.
>
> Bootstrapped and passed regression tests.
>
> OK for trunk?
>
> Thanks,
> Dehao
>
> gcc/ChangeLog:
> 2013-06-21  Dehao Chen  
>
> * ipa-inline.c (edge_badness): Fix integer underflow.
>
> Index: gcc/ipa-inline.c
> ===
> --- gcc/ipa-inline.c (revision 200326)
> +++ gcc/ipa-inline.c (working copy)
> @@ -888,11 +888,9 @@ edge_badness (struct cgraph_edge *edge, bool dump)
>else if (max_count)
>  {
>int relbenefit = relative_time_benefit (callee_info, edge, edge_time);
> -  badness =
> - ((int)
> - ((double) edge->count * INT_MIN / 2 / max_count /
> RELATIVE_TIME_BENEFIT_RANGE) *
> - relbenefit) / growth;
> -
> +  badness = ((int)((double) edge->count / max_count
> +  * relbenefit / RELATIVE_TIME_BENEFIT_RANGE * INT_MIN / 2)) / growth;
> +

FP operations on the host are frowned upon if code generation depends
on their outcome.  They all should use sreal_* as predict already does.
Other than that I wonder why the final division is int (so we get truncation
and not rounding)?  That increases the effect of doing the multiply by
relbenefit in double.

Richard.

>/* Be sure that insanity of the profile won't lead to increasing counts
>   in the scalling and thus to overflow in the computation above.  */
>gcc_assert (max_count >= edge->count);


Re: [ping] [patch 4/5] fix bugs with -fstrict-volatile-bitfields and packed structures

2013-06-24 Thread Richard Biener
On Sun, Jun 23, 2013 at 6:17 PM, Sandra Loosemore
 wrote:
> On 06/16/2013 01:08 PM, Sandra Loosemore wrote:
>>
>> This part of the patch series fixes problems with bad code being emitted
>> for unaligned bitfield accesses, as reported in PRs 48784, 56341, and
>> 56997.  A secondary goal of this patch was making the bitfield store and
>> extract code follow similar logic, at least for the parts relating to
>> -fstrict-volatile-bitfield handling.
>
>
> Is it possible to get this part of the patch series reviewed?  Except for
> the documentation change, it is independent of the controversy surrounding
> part 3 regarding whether the target ABI or C/C++ standard should take
> precedence when they conflict, and is independent of any further patches to
> change the default -fstrict-volatile-bitfields setting.  If the rest of the
> patch is approved, I'll take care to fix up invoke.texi to accurately
> reflect the behavior of the approved patches before checking anything in.
>
> http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00911.html

It looks sensible to me but I'd like to have Eric have a 2nd look as he is most
familiar with this code.

Thanks,
Richard.

> -Sandra
>
>


Re: [PATCH] if-to-switch pass

2013-06-24 Thread Richard Biener
On Fri, Jun 21, 2013 at 10:37 PM, Cesar Philippidis
 wrote:
> Here is an updated version of Tom's if-to-switch conversion pass that
> was originally posted here:
>
> .
>
> I corrected a build problem with ARM by including "tm_p.h" and an ICE
> caused by NULL_TREE argument being passed to fold_binary () inside
> refine_range_plus (). Also, TODO_ggc_collect has been removed in the
> gimple_opt_pass struct.
>
> I bootstrapped and regression tested on x86_64-unknown-linux-gnu and
> arm-none-linux-gnueabi. OK for trunk?

As we are doing switch-to-if conversion in the pass after this it looks like
as if we can save us intermediate code generation if the two passes were
unified?  That is, have a analysis phase that populates an internal
representation
of the switch / cascaded if and peforms transforms based on a single analysis
of that representation.

I also dislike the two passes being in early optimizations - that way they do
not see the effects of IPA inlining / LTO IPA-CP transforms.  I'd rather move
it way down towards RTL expansion (though eventually some may say that
switch-conversion may enable vectorization opportunities for example).

That wasn't a patch review of course.

Richard.

> Cesar
>
>
> 2013-06-21  Tom de Vries  
> Cesar Philippidis  
>
> * tree-if-switch-conversion.c: New pass.
> * tree-pass.h (pass_if_to_switch): Declare.
> * common.opt (ftree-if-to-switch-conversion): New switch.
> * opts.c (default_options_table): Set 
> flag_tree_if_to_switch_conversion
> at -O2 and higher.
> * passes.c (init_optimization_passes): Use new pass.
> * doc/invoke.texi (-ftree-if-to-switch-conversion): New item.
> (Optimization Options, option -O2): Add 
> -ftree-if-to-switch-conversion.
> * Makefile.in (OBJS): Add tree-if-switch-conversion.o.
> (tree-if-switch-conversion.o): New rule.
> * tree.h (expand_switch_using_bit_tests_p): Declare as extern.
> * tree-switch-conversion.c (expand_switch_using_bit_tests_p): Remove
> static from definition.
>
> * gcc.dg/if-to-switch.c: New test.
> * gcc.dg/if-to-switch.c-2: Same.
> * gcc.dg/if-to-switch.c-3: Same.
> * gcc.dg/tree-ssa/vrp33.c: Run with -fno-tree-if-to-switch-conversion.
> * gcc.dg/tree-ssa/vrp63.c: Same.
> * gcc.dg/tree-ssa/vrp64.c: Same.
> * gcc.dg/pr21643.c: Same.


Re: [PATCH] Provide a pointer_map template

2013-06-24 Thread Richard Biener
On Wed, 19 Jun 2013, Richard Biener wrote:

> On Wed, 19 Jun 2013, Richard Biener wrote:
> 
> > 
> > This templates the pointer-map implementation (actually it copies
> > the implementation, leaving the old interface unchanged) providing
> > a templated value type.  That's suitable to replace the various
> > users requesting a pointer-to-integer-type map, like I noticed
> > for the two LTO tree recording mechanisms.  Which in turn saves
> > memory on 64bit hosts (and should be less heavy-weight on the cache).
> > Not very much, but a quarter of the old pointer-map memory usage.
> > 
> > LTO bootstrap and regtest running on x86_64-unknown-linux-gnu.
> > 
> > In theory we can typedef pointer_map pointer_map_t, but
> > that requires touching all pointer_map_t users to drop the
> > leading 'struct' and eventually include pointer-set.h.
> > 
> > I changed the insert () interface to get another output as to
> > whether the slot was present to avoid the need to have a special
> > "not present" value.  That also makes it unnecessary to zero
> > the values array.
> >
> > Any comments?
> > 
> > If not then I'll comb over existing pointer -> integer type map
> > users and convert them.
> 
> Added the dominance.c one and changed the implementation to
> "inherit" from pointer-set instead, sharing a bit more code.
> 
> The pointer-map template is also type-safe for the value array
> so converting all pointer-map users will make the code a tiny
> bit prettier.
> 
> The remaining integer type cases seem to store integer types
> as large as pointer types so they fall in the same category
> (but eventually they chose that large type for no good reason).
> 
> Old patch LTO bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> Any objections?

None and thus installed.

Richard.


Re: [PATCH] Add a couple of dialect and warning options regarding Objective-C instance variable scope

2013-06-24 Thread Dimitris Papavasiliou

Ping!  Would anybody care to comment on this?

On 06/10/2013 12:44 AM, Dimitris Papavasiliou wrote:

Hello,

First, let me say that I have consciously broken most of the rules
mentioned about patch submission at gcc.gnu.org but I have done so in
order to spare myself from wasting time to provide a proper patch in
case the implemented functionality is not deemed worthy of approval and
adoption into GCC. If any of the implemented switches prove to be
welcome I'll be more than happy to split them into separate patches, add
test-cases and add ChangLog entries as needed.

Two of these switches are related to a feature request I submitted a
while ago, Bug 56044
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56044). I won't reproduce
the entire argument here since it is available in the feature request.
The relevant functionality in the patch comes in the form of two switches:

-Wshadow-ivars which controls the "local declaration of ‘somevar’ hides
instance variable" warning which curiously is enabled by default instead
of being controlled at least by -Wshadow. The patch changes it so that
this warning can be enabled and disabled specifically through
-Wshadow-ivars as well as with all other shadowing-related warnings
through -Wshadow.

The reason for the extra switch is that, while searching through the
Internet for a solution to this problem I have found out that other
people are inconvenienced by this particular warning as well so it might
be useful to be able to turn it off while keeping all the other
shadowing-related warnings enabled.

-flocal-ivars which when true, as it is by default, treats instance
variables as having local scope. If false (-fno-local-ivars) instance
variables must always be referred to as self->ivarname and references of
ivarname resolve to the local or global scope as usual.

I've also taken the opportunity of adding another switch unrelated to
the above but related to instance variables:

-fivar-visibility which can be set to either private, protected (the
default), public and package. This sets the default instance variable
visibility which normally is implicitly protected. My use-case for it is
basically to be able to set it to public and thus effectively disable
this visibility mechanism altogether which I find no use for and
therefore have to circumvent. I'm not sure if anyone else feels the same
way towards this but I figured it was worth a try.

I'm attaching a preliminary patch against the current revision in case
anyone wants to have a look. The changes are very small and any blatant
mistakes should be immediately obvious. I have to admit to having
virtually no knowledge of the internals of GCC but I have tried to keep
in line with formatting guidelines and general style as well as looking
up the particulars of the way options are handled in the available
documentation to avoid blind copy-pasting. I have also tried to test the
functionality both in my own (relatively large, or at least not too
small) project and with small test programs and everything works as
expected. Finallly, I tried running the tests too but these fail to
complete both in the patched and unpatched version, possibly due to the
way I've configured GCC.

Dimitris




[PATCH] Fix PR57584

2013-06-24 Thread Richard Biener

Removed the target specific bits and verified the testcase reproduces
the original bug and works after the fix for x86_64 and i686.

Committed.

Richard.

2013-06-24  Richard Biener  

PR testsuite/57686
* gcc.dg/torture/pr57584.c: Remove target specific bits.

Index: gcc/testsuite/gcc.dg/torture/pr57584.c
===
--- gcc/testsuite/gcc.dg/torture/pr57584.c  (revision 200363)
+++ gcc/testsuite/gcc.dg/torture/pr57584.c  (working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 
-typedef int int32_t __attribute__ ((__mode__ (__SI__)));
+typedef int int32_t;
 typedef unsigned char uint8_t;
 typedef unsigned long int uintptr_t;
 typedef uint8_t scm_t_uint8;
@@ -37,7 +37,7 @@ static SCM vm_debug_engine (SCM vm, SCM
 register SCM *fp ;
 struct scm_vm *vp = ((struct scm_vm *) scm_t_bits) (0? 
(*(SCM*)0=SCM *)((scm_t_cell *) (((scm_t_bits) (0? (*(SCM*)0=vm): 
(((vm [((1))]))): (((SCM *)((scm_t_cell *) (((scm_t_bits) (0? 
(*(SCM*)0=vm): (((vm [((1))]));
 static const void **jump_table_pointer = ((void *)0);
-register const void **jump_table asm ("r12");
+const void **jump_table;
 if (__builtin_expect ((!jump_table_pointer), 0)) {
jump_table_pointer[0] = &&l_nop;
 }


Re: [Patch, Fortran] PR52413 - Incorrect behavior of FRACTION when applied to a constant

2013-06-24 Thread Dominique Dhumieres
Tobias,

> I have committed it as Rev. 200361.

Thanks for the quick commit. No backport?

Dominique


[PATCH] Fix PR57488

2013-06-24 Thread Richard Biener

This fixes PR57488 - clearing NEW sets before each insert iteration
ensures we don't propagate memory accesses across back-edges into
regions where that would not be valid.

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

Richard.

2013-06-24  Richard Biener  

PR tree-optimization/57488
* tree-ssa-pre.c (insert): Clear NEW sets before each iteration.

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

Index: gcc/tree-ssa-pre.c
===
*** gcc/tree-ssa-pre.c  (revision 200237)
--- gcc/tree-ssa-pre.c  (working copy)
*** insert (void)
*** 3665,3670 
--- 3666,3677 
if (dump_file && dump_flags & TDF_DETAILS)
fprintf (dump_file, "Starting insert iteration %d\n", num_iterations);
new_stuff = insert_aux (ENTRY_BLOCK_PTR);
+ 
+   /* Clear the NEW sets before the next iteration.  We have already
+  fully propagated its contents.  */
+   if (new_stuff)
+   FOR_ALL_BB (bb)
+ bitmap_set_free (NEW_SETS (bb));
  }
statistics_histogram_event (cfun, "insert iterations", num_iterations);
  }
Index: gcc/testsuite/gcc.dg/torture/pr57488.c
===
*** gcc/testsuite/gcc.dg/torture/pr57488.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr57488.c  (working copy)
***
*** 0 
--- 1,58 
+ /* { dg-do run } */
+ 
+ extern void abort (void);
+ 
+ int i, j, *pj = &j, **ppj = &pj;
+ int x, *px = &x;
+ 
+ short s, *ps = &s, k;
+ 
+ unsigned short u, *pu = &u, **ppu = &pu;
+ 
+ char c, *pc = &c;
+ 
+ unsigned char v = 48;
+ 
+ static int
+ bar (int p)
+ {
+   p = k;
+   *px = **ppu = i;
+   *ppj = &p;
+   if (**ppj)
+ *pj = p;
+   return p;
+ }
+ 
+ void __attribute__((noinline))
+ foo ()
+ {
+   for (; i <= 3; i++)
+ for (; j; j--);
+ 
+   u ^= bar (*pj);
+ 
+   for (k = 1; k >= 0; k--)
+ {
+   int l;
+   bar (0);
+   for (l = 1; l < 5; l++)
+   {
+ int m;
+ for (m = 6; m; m--)
+   {
+ v--;
+ *ps = *pc;
+   }
+   }
+ }
+ }
+ 
+ int
+ main ()
+ {
+   foo ();
+   if (v != 0)
+ abort ();
+   return 0;
+ }


RE: [PATCH,ARM] Define MAX_CONDITIONAL_EXECUTE

2013-06-24 Thread Greta Yorsh
PING...
http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00948.html

Thanks,
Greta

> -Original Message-
> From: Greta Yorsh [mailto:greta.yo...@arm.com]
> Sent: 17 June 2013 12:19
> To: GCC Patches
> Cc: Richard Earnshaw; Ramana Radhakrishnan; p...@codesourcery.com;
> ni...@redhat.com
> Subject: [PATCH,ARM] Define MAX_CONDITIONAL_EXECUTE
> 
> This patch makes the following changes:
> * Define MAX_CONDITIONAL_EXECUTE in arm backend using
> max_insns_skipped,
> which is set based on the current tune.
> * Update max_insns_skipped for Cortex-A15 tune to be 2 (instead of 5).
> * Use max_insns_skipped in thumb2_final_prescan_insn to decide when to
> combine IT blocks
> into larger IT blocks. Previously, max_insns_skipped was only used in
> arm_final_prescan_insn to decide when branch should be converted to
> conditional execution.
> 
> No regression on qemu for arm-none-eabi with cortex-a15 arm/thumb mode.
> Bootstrap successful on Cortex-A15.
> 
> Performance improvement on Cortex-A15 in both arm and thumb states on
> both
> Dhrystone and Coremark, and improvement on Spec2000 in thumb state,
> with all
> benchmarks showing improvements except three benchmarks in CFP2000 that
> have
> slight regressions (189,183,178).
> 
> gcc/ChangeLog
> 
> 2013-06-17  Greta Yorsh  
> 
>   * config/arm/arm.h (MAX_CONDITIONAL_EXECUTE): Define macro.
>   * config/arm/arm-protos.h (arm_max_conditional_execute): New
>   declaration.
>   (tune_params): Update comment.
>   * config/arm/arm.c (arm_cortex_a15_tune): Set max_cond_insns to
> 2.
>   (arm_max_conditional_execute): New function.
>   (thumb2_final_prescan_insn): Use max_insn_skipped and
>   MAX_INSN_PER_IT_BLOCK to compute maximum instructions in a block.





Re: [PATCH, i386, PR57623] Introduce _bextr (single underscore) intrinsucs

2013-06-24 Thread Jakub Jelinek
On Mon, Jun 24, 2013 at 12:55:11PM +0400, Kirill Yukhin wrote:
> Here is snippet from i386.c:
> case
> 3:
>
> 
>   pat = GEN_FCN (icode) (real_target, args[0].op,
> args[1].op,   
>   
> 
> 
> args[2].op);  
>

This is calling genfun, which is
typedef rtx (*insn_gen_fn) (rtx, ...);
therefore there is no compile time number of arguments verification here,
the caller and callee simply has to agree on the number of arguments or at
least caller needs to supply as many arguments as the callee relies on.

> Could you pls take a look?

This looks ok to me, but as I'm not an i386 maintainer, I'll defer it to
Uros or Richard.

> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 53a6cde..6d6aeac 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-06-20  Kirill Yukhin  
> +
> + * config/i386/bmiintrin.h (_bextr_u32): New.
> + (_bextr_u64): Ditto.
> +
>  2013-06-19  Paolo Carlini  
>  
>   PR c++/56544
> diff --git a/gcc/config/i386/bmiintrin.h b/gcc/config/i386/bmiintrin.h
> index 0087f5c..7a30cf0 100644
> --- a/gcc/config/i386/bmiintrin.h
> +++ b/gcc/config/i386/bmiintrin.h
> @@ -52,6 +52,12 @@ __bextr_u32 (unsigned int __X, unsigned int __Y)
>  }
>  
>  extern __inline unsigned int __attribute__((__gnu_inline__, 
> __always_inline__, __artificial__))
> +_bextr_u32 (unsigned int __X, unsigned int __Y, unsigned __Z)
> +{
> +  return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 
> 8)));
> +}
> +
> +extern __inline unsigned int __attribute__((__gnu_inline__, 
> __always_inline__, __artificial__))
>  __blsi_u32 (unsigned int __X)
>  {
>return __X & -__X;
> @@ -91,6 +97,12 @@ __bextr_u64 (unsigned long long __X, unsigned long long 
> __Y)
>  }
>  
>  extern __inline unsigned long long __attribute__((__gnu_inline__, 
> __always_inline__, __artificial__))
> +_bextr_u64 (unsigned long long __X, unsigned long long __Y, unsigned long 
> long __Z)
> +{
> +  return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 
> 8)));
> +}
> +
> +extern __inline unsigned long long __attribute__((__gnu_inline__, 
> __always_inline__, __artificial__))
>  __blsi_u64 (unsigned long long __X)
>  {
>return __X & -__X;

Jakub


Re: [PATCH, i386, PR57623] Introduce _bextr (single underscore) intrinsucs

2013-06-24 Thread Kirill Yukhin
Hello!
>> I actually don't understand how this can work, bmi_bextr_{si,di} expanders
>> have just 3 operands (one target, 2 arguments), so just by giving it
>> 4 operands instead just means the last one is dropped on the floor.
>> Why do you need a builtin for this at all?
>> I was expecting that _bextr_u{32,64} would be implemented either using
>> __bextr_u{32,64} or at least using it's underlying builtin, by constructing
>> the combined len/start argument with shifts/ands first.
>>
>> But I admit I haven't applied the patch and looked how it works.
This was my mistake. I've accidentally intermixed BMI's bextr with TBM's
bextr, which has dedicated expansion in i386.c and different patterns in
i386.md
The tests also was wrong. That's why bootstrapping and regtesting was
actually OK.
This is really strange to me, that when we're trying to call GEN_
function with number of arguments that excess number in the pattern -
nothing is happen. It silently trunc out extra arguments. I believe we
should give ICE here.
Here is snippet from i386.c:
case
3:  
 

  pat = GEN_FCN (icode) (real_target, args[0].op,
args[1].op, 



args[2].op);
 

 
break;  


For my bogus patch, icode was actually:  bmi_bextr_si/2.
And what was generated looked like this:
func_bextr32_3args:
.LFB520:
.cfi_startproc
movl4(%esp), %eax   # 23*movsi_internal/1   [length = 4]
bextr   8(%esp), %eax, %eax # 11bmi_bextr_si/2  [length = 5]
ret # 27simple_return_internal  [length = 1]
.cfi_endproc

> OK, I assumed that the patch was tested according to established
> standards, and that it doesn't need to be reviewed for its most basic
> functionality. If the patch was not tested appropriately, I will
> simply ignore future submissions from the submitters that want to bend
> the rules. Sorry.
>
As I said before, bogus tests and bootstrap was actually working. I
sorry for the crap I've sent.

I've rewrote intrinsics and tests. Bootstrap is passing, new tests are
passing and they perform correct checks.

ChangeLog entry:
2013-06-24  Kirill Yukhin  

* config/i386/bmiintrin.h (_bextr_u32): New.
(_bextr_u64): Ditto.

testsuite/ChangeLog entry:
2013-06-24  Kirill Yukhin  

* gcc.target/i386/bmi-1.c: Extend with new instrinsic.
Fix scan patterns.
* gcc.target/i386/bmi-1.c: Ditto.
* gcc.target/i386/bmi-bextr-3.c: New.
* gcc.target/i386/bmi-bextr-4.c: Ditto.

Could you pls take a look?

Thanks, K


diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 53a6cde..6d6aeac 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-20  Kirill Yukhin  
+
+   * config/i386/bmiintrin.h (_bextr_u32): New.
+   (_bextr_u64): Ditto.
+
 2013-06-19  Paolo Carlini  
 
PR c++/56544
diff --git a/gcc/config/i386/bmiintrin.h b/gcc/config/i386/bmiintrin.h
index 0087f5c..7a30cf0 100644
--- a/gcc/config/i386/bmiintrin.h
+++ b/gcc/config/i386/bmiintrin.h
@@ -52,6 +52,12 @@ __bextr_u32 (unsigned int __X, unsigned int __Y)
 }
 
 extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
+_bextr_u32 (unsigned int __X, unsigned int __Y, unsigned __Z)
+{
+  return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
+}
+
+extern __inline unsigned int __attribute__((__gnu_inline__, __always_inline__, 
__artificial__))
 __blsi_u32 (unsigned int __X)
 {
   return __X & -__X;
@@ -91,6 +97,12 @@ __bextr_u64 (unsigned long long __X, unsigned long long __Y)
 }
 
 extern __inline unsigned long long __attribute__((__gnu_inline__, 
__always_inline__, __artificial__))
+_bextr_u64 (unsigned long long __X, unsigned long long __Y, unsigned long long 
__Z)
+{
+  return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
+}
+
+extern __inline unsigned long long __attribute__((__gnu_inline__, 
__always_inline__, __artificial__))
 __blsi_u64 (unsigned long long __X)
 {
   return __X & -__X;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1d7c2af..27ca5d2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-20  Kirill Yukhin  
+
+   * gcc.target/i386/bmi-1.c: Extend with new instrinsic.
+   Fix scan patterns.
+   * gcc.target/i386/bmi-1.c: Ditto.
+   * gcc.target/i386/bmi-bextr-3.c: New.
+   * gcc.target/i386/bmi-bextr-4.c: Ditto.
+
 2013-06-19  Manuel Lopez-Ibanez  
 
PR c++/57638
diff --git a/gcc/testsuite/gcc.target/i386/bmi-1.c 
b/gcc/testsuite/gc

Re: [Patch, Fortran] PR52413 - Incorrect behavior of FRACTION when applied to a constant

2013-06-24 Thread Tobias Burnus

Dominique Dhumieres wrote:

This patch packages the Steven G. Kargl's patch when MPFR 3.1.0 or newer
is available and fixes the original code for older versions using the
FX Coudert's machinery (see PR for details).

Tested on powerpc-apple-darwin9 and x86_64-apple-darwin10 without
regression.

OK for the trunk? If yes, could someone commit it for me?


OK. Thanks for the patches Steve and FX - and to Dominique for combining 
the two and creating the test case.


I have committed it as Rev. 200361.


2013-06-23  Steven G. Kargl  
Francois-Xavier Coudert  
Dominique d'Humieres  

PR fortran/52413
* simplify.c: Fix the sign of negative values in gfc_simplify_fraction.


The syntax is to place the function name in parentheses, i.e.

* simplify.c (gfc_simplify_fraction): Fix the sign of negative values.


Tobias


Re: [Patch, Fortran] Print floating-point exception status after STOP/ERROR STOP

2013-06-24 Thread Tobias Burnus

Eric, Gerald, all,

I have now committed (Rev. 200360) the attached patch. (Compared to the 
draft patch, with a missing "," added in AC_CHECK_TYPES).


Eric, Gerald: Can you confirm that it now works on both FreeBSD and Solaris?

Eric: Should one (conditionally) include  on Solaris? I 
am asking because LIBGFOR_CHECK_FPSETMASK in acinclude.m4 uses that 
include file during configure - but libgfortran.h (or config/fpu-sysv.h) 
don't.


Tobias
Index: libgfortran/ChangeLog
===
--- libgfortran/ChangeLog	(Revision 200359)
+++ libgfortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,10 @@
+2013-06-24  Tobias Burnus  
+
+	* configure.ac: Check for fp_except and fp_except_t.
+	* config/fpu-sysv.h: Conditionally use either type.
+	* configure: Regenerate.
+	* config.h.in: Regenerate.
+
 2013-06-21  Eric Botcazou  
 
 	* config/fpu-sysv.h (get_fpu_except_flags): Fix typo.
Index: libgfortran/config/fpu-sysv.h
===
--- libgfortran/config/fpu-sysv.h	(Revision 200359)
+++ libgfortran/config/fpu-sysv.h	(Arbeitskopie)
@@ -85,7 +85,13 @@ int
 get_fpu_except_flags (void)
 {
   int result;
+#if HAVE_FP_EXCEPT
   fp_except set_excepts;
+#elif HAVE_FP_EXCEPT_T
+  fp_except_t set_excepts;
+#else
+  choke me
+#endif
 
   result = 0;
   set_excepts = fpgetsticky ();
Index: libgfortran/config.h.in
===
--- libgfortran/config.h.in	(Revision 200359)
+++ libgfortran/config.h.in	(Arbeitskopie)
@@ -405,6 +405,12 @@
 /* fp_enable is present */
 #undef HAVE_FP_ENABLE
 
+/* Define to 1 if the system has the type `fp_except'. */
+#undef HAVE_FP_EXCEPT
+
+/* Define to 1 if the system has the type `fp_except_t'. */
+#undef HAVE_FP_EXCEPT_T
+
 /* fp_trap is present */
 #undef HAVE_FP_TRAP
 
Index: libgfortran/configure
===
--- libgfortran/configure	(Revision 200359)
+++ libgfortran/configure	(Arbeitskopie)
@@ -25977,7 +25977,28 @@ $as_echo "#define HAVE_FPSETMASK 1" >>confdefs.h
 
   fi
 
+ac_fn_c_check_type "$LINENO" "fp_except" "ac_cv_type_fp_except" "#include 
+"
+if test "x$ac_cv_type_fp_except" = x""yes; then :
 
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FP_EXCEPT 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "fp_except_t" "ac_cv_type_fp_except_t" "#include 
+"
+if test "x$ac_cv_type_fp_except_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_FP_EXCEPT_T 1
+_ACEOF
+
+
+fi
+
+
 # Check for AIX fp_trap and fp_enable
 ac_fn_c_check_func "$LINENO" "fp_trap" "ac_cv_func_fp_trap"
 if test "x$ac_cv_func_fp_trap" = x""yes; then :
Index: libgfortran/configure.ac
===
--- libgfortran/configure.ac	(Revision 200359)
+++ libgfortran/configure.ac	(Arbeitskopie)
@@ -498,6 +498,7 @@ fi
 
 # Check for SysV fpsetmask
 LIBGFOR_CHECK_FPSETMASK
+AC_CHECK_TYPES([fp_except,fp_except_t], [], [], [[#include ]])
 
 # Check for AIX fp_trap and fp_enable
 AC_CHECK_FUNC([fp_trap],[have_fp_trap=yes AC_DEFINE([HAVE_FP_TRAP],[1],[fp_trap is present])])


Re: [PATCH, libjava] Use accessor functions to manipulate xmlOutputBuffer

2013-06-24 Thread Andrew Haley
On 06/24/2013 09:13 AM, Dodji Seketeli wrote:
> Just to make sure I understand what you are saying; do you mean that the
> accessor macro GET_XML_OUTPUT_BUFFER_SIZE (that depends on
> LIBXML2_NEW_BUFFER) shouldn't be defined in
> libjava/classpath/native/jni/xmlj/xmlj_io.c but somewhere else by an
> autoconf macro?  If so, maybe you should elaborate more on what you have
> in mind exactly as I am not really well acquainted with (the configury
> of) gnu classpath.  I did this thing quickly so that the build doesn't
> break on newer versions of libxml2.

OK, I get it now, thanks.

Andrew.



Re: [PATCH, libjava] Use accessor functions to manipulate xmlOutputBuffer

2013-06-24 Thread Dodji Seketeli
Hello Andrew,

Andrew Haley  writes:

> On 08/08/2012 11:08 PM, Dodji Seketeli wrote:
>> OK to commit?
>
> Looks good,

Thanks.

Just for the record, you acked this patch a year or so ago, but now I
realize it was by private email.  I am attaching the email I received
(as I see there is nothing really private in it) below.

So the patch has been added to gnu classpath, thanks to a commit from
Andrew Hughes that followed your ACK and my committing (inadvertently)
to the copy of gnu classpath in the gcc tree:

http://git.savannah.gnu.org/cgit/classpath.git/commit/?id=4d4db712cf4df4feb4d7b98bb1b5b448218500b3

The email thread is at http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00564.html.

> but what sets LIBXML2_NEW_BUFFER ?

Daniel Veillard  writes:

> LIBXML2_NEW_BUFFER is a libxml2 public macro from 

Andrew Haley  writes:

>> LIBXML2_NEW_BUFFER is a libxml2 public macro from 

> Sure, but there's no point adding it to libgcj if it's not set by
> anything.  It needs an autoconf macro or somesuch.

Just to make sure I understand what you are saying; do you mean that the
accessor macro GET_XML_OUTPUT_BUFFER_SIZE (that depends on
LIBXML2_NEW_BUFFER) shouldn't be defined in
libjava/classpath/native/jni/xmlj/xmlj_io.c but somewhere else by an
autoconf macro?  If so, maybe you should elaborate more on what you have
in mind exactly as I am not really well acquainted with (the configury
of) gnu classpath.  I did this thing quickly so that the build doesn't
break on newer versions of libxml2.

Cheers.

From: Andrew Haley 
Subject: Re: [PATCH, libjava] Use accessor functions to manipulate 
xmlOutputBuffer
To: Dodji Seketeli 
Date: Thu, 09 Aug 2012 10:06:13 +0100 (45 weeks, 3 days, 22 hours ago)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 
Thunderbird/14.0

On 08/08/2012 11:08 PM, Dodji Seketeli wrote:
> Hello,
> 
> This is a fix to prepare the xmlj_io.c file of gnu classpath to a coming
> API change in libxml2.
> 
> Basically, we were previously accessing fields inside the
> xmlOutputBuffer struct of libxml2.  In a coming version of libxml2,
> that won't be possible anymore.  Client code will have to use accessor
> functions instead.  For the gory details, there is an interestin note
> of Daniel Veillard (author of libxml2) at
> https://mail.gnome.org/archives/desktop-devel-list/2012-August/msg7.html.
> 
> This patch defines too accessor macros that, depending on the version
> of libxml2 we are using will either access the fields of
> xmlOutputBuffer directly, or use the new accessor function.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.
> 
> OK to commit?

OK.

Thanks,
Andrew.


> libjava/classpath/
> 
>   * native/jni/xmlj/xmlj_io.c (GET_XML_OUTPUT_BUFFER_CONTENT)
>   (GET_XML_OUTPUT_BUFFER_SIZE): New macros.
>   (xmljOutputWriteCallback): Use them.
> ---
>  libjava/classpath/native/jni/xmlj/xmlj_io.c |   20 +---
>  1 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/libjava/classpath/native/jni/xmlj/xmlj_io.c 
> b/libjava/classpath/native/jni/xmlj/xmlj_io.c
> index aa2964d..a55e48d 100644
> --- a/libjava/classpath/native/jni/xmlj/xmlj_io.c
> +++ b/libjava/classpath/native/jni/xmlj/xmlj_io.c
> @@ -102,6 +102,19 @@ xmljFreeOutputStreamContext (OutputStreamContext * 
> outContext);
>  xmlCharEncoding
>  xmljDetectCharEncoding (JNIEnv * env, jbyteArray buffer);
>  
> +
> +#ifdef LIBXML2_NEW_BUFFER
> +#define GET_XML_OUTPUT_BUFFER_CONTENT(buf) (gchar *) \
> +  (char *) xmlOutputBufferGetContent(buf)
> +#define GET_XML_OUTPUT_BUFFER_SIZE(buf) \
> +  xmlOutputBufferGetSize(buf)
> +#else
> +#define GET_XML_OUTPUT_BUFFER_CONTENT(buf) \
> + (buf)->buffer->content
> +#define GET_XML_OUTPUT_BUFFER_SIZE(buf) \
> +  (buf)->buffer->use
> +#endif
> +
>  int
>  xmljOutputWriteCallback (void *context, const char *buffer, int len)
>  {
> @@ -752,9 +765,10 @@ xmljLoadExternalEntity (const char *URL, const char *ID,
>inputStream->directory = NULL;
>inputStream->buf = inputBuffer;
>  
> -  inputStream->base = inputStream->buf->buffer->content;
> -  inputStream->cur = inputStream->buf->buffer->content;
> -  inputStream->end = &inputStream->base[inputStream->buf->buffer->use];
> +  inputStream->base = GET_XML_OUTPUT_BUFFER_CONTENT (inputStream->buf);
> +  inputStream->cur = GET_XML_OUTPUT_BUFFER_CONTENT (inputStream->buf);
> +  inputStream->end =
> +  &inputStream->base[GET_XML_OUTPUT_BUFFER_SIZE (inputStream->buf)];
>if ((ctxt->directory == NULL) && (inputStream->directory != NULL))
>  ctxt->directory =
>(char *) xmlStrdup ((const xmlChar *) inputStream->directory);
> 


-- 
Dodji


Re: [PATCH] Basic support for MIPS r5900

2013-06-24 Thread Jürgen Urban
Hello Richard,

Am 23.06.2013 um 22:21 schrieb Richard Sandiford :

> "Jürgen Urban"  writes:
>> 
>> In the native PS2SDK (i.e. no Linux) I detected that there are undefined
>> references to `__fixtfsi', `__floatsitf', `__subtf3', `__multf3',
>> __extenddftf2', `__lttf2' and `__gttf2'. These are the functions for
>> handling "long double".
>> There is a fix needed for this in libgcc. I attached 2 patches to this
>> e-mail. There should be only one of the patches used to fix this.
>> The first one fixes the problem for all mips systems. The second one
>> fixes this only for r5900. I think it is a general problem. I assume the
>> undefined references could appear on all mips64 systems which are not
>> Linux. So the first patch should be applied.
> 
> The second patch is right.  Not all targets have 128-bit long doubles,
> so t-tpbit is intentionally an opt-in rather than opt-out thing.
> 
> E.g. mips*-sde-elf and mips*-mti-elf both use:
> 
> #undef LONG_DOUBLE_TYPE_SIZE
> #define LONG_DOUBLE_TYPE_SIZE 64
> 
> to get a form of n32 in which long doubles are the same as doubles.
> 
> Do you want to stick with 128-bit long doubles for PS2, or would you
> prefer to do what SDE does?

I prefer shorter long doubles because of the performance impact. For 32 bit 
hard float we may need it. Can you change it or do I need to submit a patch?

Best regards
Jürgen