[PATCH] Fix forwporp pattern (T)(P + A) - (T)P - (T)A

2014-06-22 Thread Bernd Edlinger
Hi,

I noticed that several testcases in the GMP-4.3.2 test suite are failing now 
which
did not happen with GCC 4.9.0.  I debugged the first one, mpz/convert, and found
the file mpn/generic/get_str.c was miscompiled.

mpn/get_str.c.132t.dse2:
  pretmp_183 = (sizetype) chars_per_limb_80;
  pretmp_184 = -pretmp_183;
  _23 = chars_per_limb_80 + 4294967295;
  _68 = (sizetype) _23;
  _28 = _68 + pretmp_184;

mpn/get_str.c.133t.forwprop4:
  _28 = 4294967295;


That is wrong, because chars_per_limb is unsigned, and it is not zero.
So the right result should be -1.  This makes the loop termination in that
function fail.

The reason for this is in this check-in:

r210807 | ebotcazou | 2014-05-22 16:32:56 +0200 (Thu, 22 May 2014) | 3 lines

    * tree-ssa-forwprop.c (associate_plusminus): Extend (T)(P + A) - (T)P
    - (T)A transformation to integer types.


Because it implicitly assumes that integer overflow is not allowed with all 
types,
including unsigned int.


The attached patch fixes these regressions, and because the reasoning depends
on the TYPE_OVERFLOW_UNDEFINED attribute, a strict overflow warning has to be
emitted here, at least for widening conversions.


Boot-strapped and regression-tested on x86_64-linux-gnu with all languages, 
including Ada.
OK for trunk?


Thanks
Bernd.
  gcc/ChangeLog:
2014-06-22  Bernd Edlinger  bernd.edlin...@hotmail.de

* tree-ssa-forwprop.c (associate_plusminus): For widening conversions
check for undefined overflow in (T)(P + A) - (T)P - (T)A.
Issue a strict overflow warning if appropriate.

testsuite/ChangeLog:
2014-06-22  Bernd Edlinger  bernd.edlin...@hotmail.de

* gcc.c-torture/execute/20140622-1.c: New test.



patch-forwprop.diff
Description: Binary data


Re: [i386] logical shift right in shrd

2014-06-22 Thread Uros Bizjak
On Sat, Jun 21, 2014 at 6:32 PM, Marc Glisse marc.gli...@inria.fr wrote:

 Er, I am sorry, I don't know what happened, but when testing the backport to
 4.9 I got an obvious failure in the testsuite, which I am sure should also
 happen on trunk, but somehow I didn't see it (I am almost sure I tested the
 right branch though). Anyway, here is an updated patch, that did pass
 bootstrap+testsuite both on trunk and 4.9. I haven't committed anything yet,
 is the new patch ok?


 2014-06-21  Marc Glisse  marc.gli...@inria.fr

 PR target/61503
 * config/i386/i386.md (x86_64_shrd, x86_shrd,
 ix86_rotrdwi3_doubleword): Replace ashiftrt with lshiftrt.

OK, but please wait a couple of days with the backport.

Thanks,
Uros.


[PATCH] DWARFv5 Emit DW_TAG_atomic_type.

2014-06-22 Thread Mark Wielaard
The following is just a prototype to try out a new qualifier type tag
proposed for DWARFv5. There is not even a draft yet of DWARFv5, so this
is just based on a proposal that might or might not be adopted and/or
changed http://dwarfstd.org/ShowIssue.php?issue=131112.1

I have a corresponding patch for GDB so that the new testcase added
PASSes. But without that patch the guality.exp tests will notice GDB
doesn't recognize the new type (or DWARFv5 in general of course) and
just mark the test as UNSUPPORTED.

Since there is not even a draft of DWARFv5 I don't recommend adopting
this patch. All details may change in the future. I am mainly doing it
to give better feedback on the DWARFv5 proposals (in this case the
feedback would be that it is unfortunate we cannot easily do this as a
vendor extension with DW_TAG_GNU_atomic_type since that would break
backward compatibility). Feedback on the patch is of course still very
welcome.

Is there a recommended way for doing/keeping these kind of speculative
patches? I'll keep a local git branch with my experiments that I'll
rebase against master for larger updates. And would like to send out
new patches to the list for review even if we won't adopt them for now.
But if there is a better way/best practice for this kind of experimental
changes based on just ideas for a next version of a not yet public
standard please let me know.

gcc/ChangeLog

* dwarf2out.h (enum dw_mod_flag): Add dw_mod_atomic.
* dwarf2out.c (dw_mod_decl_flags): Handle TYPE_ATOMIC.
(dw_mod_type_flags): Likewise.
(dw_mods_to_quals): Likewise.
(dw_mod_qualified_type): Likewise.
(modified_type_die): Likewise.
opts.c (common_handle_option): Accept -gdwarf-5.

gcc/testsuite/ChangeLog

* lib/gcc-gdb-test.exp (gdb-test): Catch 'unknown type in ' to
recognize older gdb versions.
* gcc.dg/guality/atomic.c: New test.

include/ChangeLog

* dwarf2.def: Add DWARFv5 DW_TAG_atomic_type.
---
 gcc/ChangeLog |   10 ++
 gcc/dwarf2out.c   |   28 
 gcc/dwarf2out.h   |3 ++-
 gcc/opts.c|2 +-
 gcc/testsuite/ChangeLog   |6 ++
 gcc/testsuite/gcc.dg/guality/atomic.c |   13 +
 gcc/testsuite/lib/gcc-gdb-test.exp|2 +-
 include/ChangeLog |4 
 include/dwarf2.def|2 ++
 9 files changed, 63 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/guality/atomic.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 06a8767..4d81763 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-06-22  Mark Wielaard  m...@redhat.com
+
+   * dwarf2out.h (enum dw_mod_flag): Add dw_mod_atomic.
+   * dwarf2out.c (dw_mod_decl_flags): Handle TYPE_ATOMIC.
+   (dw_mod_type_flags): Likewise.
+   (dw_mods_to_quals): Likewise.
+   (dw_mod_qualified_type): Likewise.
+   (modified_type_die): Likewise.
+   opts.c (common_handle_option): Accept -gdwarf-5.
+
 2014-06-20  Mark Wielaard  m...@redhat.com
 
PR debug/59051
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index b99d1b9..2b8a4bd 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10507,7 +10507,8 @@ dw_mod_decl_flags (const_tree decl)
  | (TREE_THIS_VOLATILE (decl) ? dw_mod_volatile : dw_mod_none)
  | ((POINTER_TYPE_P (TREE_TYPE (decl))
   TYPE_RESTRICT (TREE_TYPE (decl)))
-? dw_mod_restrict : dw_mod_none));
+? dw_mod_restrict : dw_mod_none)
+ | (TYPE_ATOMIC (TREE_TYPE (decl)) ? dw_mod_atomic : dw_mod_none));
 }
 
 static int
@@ -10516,7 +10517,8 @@ dw_mod_type_flags (const_tree type)
   return ((TYPE_READONLY (type) ? dw_mod_const : dw_mod_none)
  | (TYPE_VOLATILE (type) ? dw_mod_volatile : dw_mod_none)
  | ((POINTER_TYPE_P (type)  TYPE_RESTRICT (type))
-? dw_mod_restrict : dw_mod_none));
+? dw_mod_restrict : dw_mod_none)
+ | (TYPE_ATOMIC (type) ? dw_mod_atomic : dw_mod_none));
 }
 
 static int
@@ -10524,7 +10526,8 @@ dw_mods_to_quals (int mods)
 {
   return (((mods  dw_mod_const) ? TYPE_QUAL_CONST : 0)
  | ((mods  dw_mod_volatile) ? TYPE_QUAL_VOLATILE : 0)
- | ((mods  dw_mod_restrict) ? TYPE_QUAL_RESTRICT : 0));
+ | ((mods  dw_mod_restrict) ? TYPE_QUAL_RESTRICT : 0)
+ | ((mods  dw_mod_atomic) ? TYPE_QUAL_ATOMIC : 0));
 }
 
 /* Returns true if there is a qualified type with at least one
@@ -10549,6 +10552,9 @@ dw_mod_qualified_type (tree type, int mods)
   if (mods  dw_mod_restrict)
 return dw_mod_qualified_type (type, mods  ~dw_mod_restrict);
 
+  if (mods  dw_mod_atomic)
+return dw_mod_qualified_type (type, mods  ~dw_mod_atomic);
+
   gcc_unreachable ();
 }
 
@@ -10575,6 +10581,10 @@ modified_type_die (tree type, int mods, dw_die_ref 
context_die)
   if (dwarf_version  3)
 

[MIPS, committed] Fix some mips.c warnings

2014-06-22 Thread Richard Sandiford
Fixes unused mode and in_p argument names.  Neither mips_move_to_gpr_cost
nor mips_move_from_gpr_cost care about the mode now, so I just removed it.

Thanks,
Richard


gcc/
* config/mips/mips.c (mips_move_to_gpr_cost): Remove mode argument.
(mips_move_from_gpr_cost): Likewise.
(mips_register_move_cost): Update accordingly.
(mips_secondary_reload_class): Remove name of in_p.

Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  2014-06-14 09:30:21.288981027 +0100
+++ gcc/config/mips/mips.c  2014-06-22 10:48:26.156234088 +0100
@@ -12021,13 +12021,12 @@ mips_canonicalize_move_class (reg_class_
   return rclass;
 }
 
-/* Return the cost of moving a value of mode MODE from a register of
-   class FROM to a GPR.  Return 0 for classes that are unions of other
-   classes handled by this function.  */
+/* Return the cost of moving a value from a register of class FROM to a GPR.
+   Return 0 for classes that are unions of other classes handled by this
+   function.  */
 
 static int
-mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
-  reg_class_t from)
+mips_move_to_gpr_cost (reg_class_t from)
 {
   switch (from)
 {
@@ -12059,12 +12058,12 @@ mips_move_to_gpr_cost (enum machine_mode
 }
 }
 
-/* Return the cost of moving a value of mode MODE from a GPR to a
-   register of class TO.  Return 0 for classes that are unions of
-   other classes handled by this function.  */
+/* Return the cost of moving a value from a GPR to a register of class TO.
+   Return 0 for classes that are unions of other classes handled by this
+   function.  */
 
 static int
-mips_move_from_gpr_cost (enum machine_mode mode, reg_class_t to)
+mips_move_from_gpr_cost (reg_class_t to)
 {
   switch (to)
 {
@@ -12125,15 +12124,15 @@ mips_register_move_cost (enum machine_mo
   /* Handle cases in which only one class deviates from the ideal.  */
   dregs = TARGET_MIPS16 ? M16_REGS : GENERAL_REGS;
   if (from == dregs)
-return mips_move_from_gpr_cost (mode, to);
+return mips_move_from_gpr_cost (to);
   if (to == dregs)
-return mips_move_to_gpr_cost (mode, from);
+return mips_move_to_gpr_cost (from);
 
   /* Handles cases that require a GPR temporary.  */
-  cost1 = mips_move_to_gpr_cost (mode, from);
+  cost1 = mips_move_to_gpr_cost (from);
   if (cost1 != 0)
 {
-  cost2 = mips_move_from_gpr_cost (mode, to);
+  cost2 = mips_move_from_gpr_cost (to);
   if (cost2 != 0)
return cost1 + cost2;
 }
@@ -12158,7 +12157,7 @@ mips_memory_move_cost (enum machine_mode
 
 enum reg_class
 mips_secondary_reload_class (enum reg_class rclass,
-enum machine_mode mode, rtx x, bool in_p)
+enum machine_mode mode, rtx x, bool)
 {
   int regno;
 


[wwwdocs] convert contribute.html to https

2014-06-22 Thread Gerald Pfeifer
Convert references to gcc.gnu.org to use https.  
Shorten textual reference to GCC Bugzilla.

Committed.

Gerald

Index: contribute.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/contribute.html,v
retrieving revision 1.83
diff -u -r1.83 contribute.html
--- contribute.html 3 Dec 2013 01:18:23 -   1.83
+++ contribute.html 22 Jun 2014 13:05:42 -
@@ -69,7 +69,7 @@
 pSubmissions which do not conform to the standards will be returned
 with a request to address any such problems.  To help with the
 preparation of patches respecting these rules, one can use the script
-a href=http://gcc.gnu.org/viewcvs/gcc/trunk/contrib/check_GNU_style.sh;
+a href=https://gcc.gnu.org/viewcvs/gcc/trunk/contrib/check_GNU_style.sh;
 contrib/check_GNU_style.sh/a to detect some of the common
 mistakes. /p
 
@@ -96,7 +96,7 @@
 regression tests to ensure that your patch does not break anything
 else.  Typically, this means comparing post-patch test results to
 pre-patch results by testing twice or comparing with recent posts to
-the a href=http://gcc.gnu.org/ml/gcc-testresults/;gcc-testresults
+the a href=https://gcc.gnu.org/ml/gcc-testresults/;gcc-testresults
 list/a./p
 
 h3Which tests to perform/h3
@@ -192,7 +192,7 @@
 For new features a description of the feature and your implementation.
 For bugs a description of what was wrong with the existing code, and a
 reference to any previous bug report (in the
-a href=http://gcc.gnu.org/bugzilla/;GCC bug tracking system/a or the
+a href=https://gcc.gnu.org/bugzilla/;GCC bug tracker/a or the
 a href=http://gcc.gnu.org/ml/gcc-bugs/;gcc-bugs archives/a) and any
 existing testcases for the problem in the GCC testsuite.
 /dd
@@ -237,7 +237,7 @@
 gcc.gnu.org, please configure your svn to use GNU diff
 and generate patches using the quot;code-up/codequot; or 
 quot;code-cp/codequot; options.
-See a href=http://gcc.gnu.org/wiki/SvnSetup;SVN setup instructions/a
+See a href=https://gcc.gnu.org/wiki/SvnSetup;SVN setup instructions/a
 for more details.br /
 Do not include generated files as part of the patch, just mention
 them in the ChangeLog (e.g., * configure: Regenerate.). 


Re: [PATCH 6/6] rs6000: Merge the var_shift yes/no alternatives

2014-06-22 Thread Segher Boessenkool
  (define_insn rotlmode3
 -  [(set (match_operand:GPR 0 gpc_reg_operand =r,r)
 - (rotate:GPR (match_operand:GPR 1 gpc_reg_operand r,r)
 - (match_operand:GPR 2 reg_or_cint_operand r,n)))]
 +  [(set (match_operand:GPR 0 gpc_reg_operand =r)
 + (rotate:GPR (match_operand:GPR 1 gpc_reg_operand r)
 + (match_operand:GPR 2 reg_or_cint_operand rn)))]

 -  @
 -   rotlwd %0,%1,%2
 -   rotlwdi %0,%1,%hH2
 +  rotlwd%I2 %0,%1,%2

Whoops, removed the hH on this pattern (very first one grmbl).  Fixed.


Segher


Re: Another AIX Bootstrap failure

2014-06-22 Thread David Edelsohn
The new testcases also declare main() as void, but return 0.

- David

On Fri, Jun 20, 2014 at 10:43 PM, Jan Hubicka hubi...@ucw.cz wrote:

 Index: testsuite/gcc.dg/localalias.c
 ===
 --- testsuite/gcc.dg/localalias.c   (revision 0)
 +++ testsuite/gcc.dg/localalias.c   (revision 0)
 @@ -0,0 +1,42 @@
 +/* This test checks that local aliases behave sanely.  This is necessary for 
 code correctness
 +   of aliases introduced by ipa-visibility pass.
 +
 +   If this test fails either aliases needs to be disabled on given target on 
 aliases with
 +   proper semantic needs to be implemented.  This is problem with e.g. AIX 
 .set pseudo-op
 +   that implementes alias syntactically (by substituting in assembler) 
 rather as alternative
 +   symbol defined on a target's location.  */
 +
 +/* { dg-do run }
 +   { dg-options -Wstrict-aliasing=2 -fstrict-aliasing }
 +   { dg-require-alias  }
 +   { dg-xfail-if  { powerpc-ibm-aix* } { * } {  } }
 +   { dg-additional-sources localalias-2.c } */
 +extern void abort (void);
 +extern int test2count;
 +int testcount;
 +__attribute__ ((weak,noinline))
 +void test(void)
 +{
 +  testcount++;
 +}
 +__attribute ((alias(test)))
 +static void test2(void);
 +
 +void main()
^
 +{
 +  test2();
 +  /* This call must bind locally.  */
 +  if (!testcount)
 +abort ();
 +  test();
 +  /* Depending on linker choice, this one may bind locally
 + or to the other unit.  */
 +  if (!testcount  !test2count)
 +abort();
 +  tt();
 +
 +  if ((testcount != 1 || test2count != 3)
 +   (testcount != 3 || test2count != 1))
 +abort ();
 +  reutrn 0;
^^
 +}
 Index: testsuite/gcc.dg/globalalias.c
 ===
 --- testsuite/gcc.dg/globalalias.c  (revision 0)
 +++ testsuite/gcc.dg/globalalias.c  (revision 0)
 @@ -0,0 +1,42 @@
 +/* This test checks that local aliases behave sanely.  This is necessary for 
 code correctness
 +   of aliases introduced by ipa-visibility pass.
 +
 +   This test expose weird behaviour of AIX's .set pseudo-op where the global 
 symbol is created,
 +   but all uses of the alias are syntactically replaced by uses of the 
 target.  This means that
 +   both counters are increased to 2.  */
 +
 +/* { dg-do run }
 +   { dg-options -O2 }
 +   { dg-require-alias  }
 +   { dg-xfail-if  { powerpc-ibm-aix* } { * } {  } }
 +   { dg-additional-sources globalalias-2.c } */
 +extern int test2count;
 +extern void abort (void);
 +int testcount;
 +static
 +void test(void)
 +{
 +  testcount++;
 +}
 +__attribute__ ((weak,noinline))
 +__attribute ((alias(test)))
 +void test2(void);
 +
 +void main()
^^^
 +{
 +  test();
 +  /* This call must bind locally.  */
 +  if (!testcount)
 +abort ();
 +  test2();
 +  /* Depending on linker choice, this one may bind locally
 + or to the other unit.  */
 +  if (!testcount  !test2count)
 +abort();
 +  tt();
 +
 +  if ((testcount != 1 || test2count != 3)
 +   (testcount != 3 || test2count != 1))
 +abort ();
 +  return 0;
^^
 +}
 Index: testsuite/gcc.dg/globalalias-2.c
 ===
 --- testsuite/gcc.dg/globalalias-2.c(revision 0)
 +++ testsuite/gcc.dg/globalalias-2.c(revision 0)
 @@ -0,0 +1,20 @@
 +int test2count;
 +extern void abort (void);
 +static
 +void test(void)
 +{
 +  test2count++;
 +}
 +__attribute__ ((weak,noinline))
 +__attribute ((alias(test)))
 +void test2(void);
 +
 +void tt()
 +{
 +  int prev = test2count;
 +  /* This call must bind locally.  */
 +  test();
 +  if (test2count == prev)
 +abort();
 +  test2();
 + }
 Index: testsuite/gcc.dg/localalias-2.c
 ===
 --- testsuite/gcc.dg/localalias-2.c (revision 0)
 +++ testsuite/gcc.dg/localalias-2.c (revision 0)
 @@ -0,0 +1,19 @@
 +extern void abort (void);
 +int test2count;
 +__attribute__ ((weak,noinline))
 +void test(void)
 +{
 +  test2count++;
 +}
 +__attribute ((alias(test)))
 +static void test2(void);
 +
 +void tt()
 +{
 +  int prev = test2count;
 +  /* This call must bind locally.  */
 +  test2();
 +  if (test2count == prev)
 +abort();
 +  test();
 + }
 Index: ipa-visibility.c
 ===
 --- ipa-visibility.c(revision 211858)
 +++ ipa-visibility.c(working copy)
 @@ -566,7 +566,11 @@ function_and_variable_visibility (bool w
  cheaper and enable more optimization.

  TODO: We can also update virtual tables.  */
 -  if (node-callers  can_replace_by_local_alias (node))
 +  if (node-callers
 +  /* FIXME: currently this optimization breaks on AIX.  Disable it 
 for targets
 + without comdat support for now.  */
 +  SUPPORTS_ONE_ONLY
 +  can_replace_by_local_alias (node))
 {

Re: [PATCH 1/6] rs6000: Remove O alternative from lshrsi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:46 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 Nothing will ever generate RTL matching this alternative.  Maybe long
 ago this was needed, but not anymore.

Can you provide some reference for that assertion?

At some point GCC created shifts with zero shift count. It probably
does not, but does a generic optimization prevent this?

Thanks, David


Re: [PATCH 1/6] rs6000: Remove O alternative from lshrsi3

2014-06-22 Thread Segher Boessenkool
  Nothing will ever generate RTL matching this alternative.  Maybe long
  ago this was needed, but not anymore.
 
 Can you provide some reference for that assertion?
 
 At some point GCC created shifts with zero shift count. It probably
 does not, but does a generic optimization prevent this?

All other SI shifts and all DI shifts do not have this.

The O alternative is not needed for correctness; i is still there.
With the patch, lshrsi3 by 0 generates a srw instead of a mr.
Not a big deal since this can only happen (if at all) with optimisation
turned off.

Shifts by zero are not canonical RTL.  I checked everything in rs6000/
and nothing calls anything with lshr in the name with a shift count
of 0 (which is how almost all non-canonical RTL is created, for rs6000
at least: directly by the backend itself).

The code was added in 1996 (Try to fix inline of fp/int convert);
sadly, our mail archives do not go that far back.  It's not clear to
me what exactly it fixed (or did not fix).  Looks like one of those
gen_lshrsi3(..., 0) things, if I had to guess.


Segher


Re: [PATCH 1/6] rs6000: Remove O alternative from lshrsi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:46 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 Nothing will ever generate RTL matching this alternative.  Maybe long
 ago this was needed, but not anymore.

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 2014-06-21  Segher Boessenkool  seg...@kernel.crashing.org

 gcc/
 * config/rs6000/rs6000.md (lshrsi3, and its two dot patterns):
 Remove O alternative.

Okay.

Thanks, David


Re: [PATCH 2/6] rs6000: Merge lshrsi3 and lshrdi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:46 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 For this create a new mode_attr hH.

 Also change i constraints on the shift amount to n, which better
 describes what it really is (GCC takes the integer value of these
 operands and does arithmetic on them; symbolic constants will not work
 here).

 Also merge the dot insns with the corresponding splitters.  To do
 this, don't allow the dot insns for CBE non-microcode mode at all
 (it previously would just split it back always).

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 2014-06-21  Segher Boessenkool  seg...@kernel.crashing.org

 gcc/
 * config/rs6000/rs6000.md (hH): New define_mode_attr.
 (lshrsi3, two anonymous define_insns and define_splits,
 lshrdi3, *lshrdi3_internal1, *lshrdi3_internal2 and split,
 *lshrdi3_internal3 and split): Delete, merge into...
 (lshrmode3, lshrmode3_dot, lshrmode3_dot2): New.
 (*lshrsi3_64): Fix formatting.  Replace i by n.

Okay.

Thanks, David


Re: [PATCH 3/6] rs6000: Merge ashlsi3 and ashldi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:46 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 As the previous patch.

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 gcc/
 * config/rs6000/rs6000.md (ashlsi3, two anonymous define_insns
 and define_splits, ashldi3, *ashldi3_internal1, *ashldi3_internal2
 and split, *ashldi3_internal3 and split): Delete, merge into...
 (ashlmode3, ashlmode3_dot, ashlmode3_dot2): New.
 (*ashlsi3_64): Fix formatting.  Replace i by n.

Okay.

Thanks, David


Re: [PATCH 4/6] rs6000: Merge rotlsi3 and rotldi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:47 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 This uses the rotl* extended mnemonics instead of the rlw*nm and rld*cl
 mnemonics, because they are shorter and more importantly they look the
 same for 32-bit and 64-bit.

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 gcc/
 * config/rs6000/rs6000.md (rotlsi3, *rotlsi3_internal2 and split,
 *rotlsi3_internal3 and split, rotldi3, *rotldi3_internal2 and split,
 *rotldi3_internal3 and split): Delete, merge into...
 (rotlmode3, rotlmode3_dot, rotlmode3_dot2): New.
 (*rotlsi3_64): Fix formatting.  Fix condition.  Replace i by n.
 Use rotlw extended mnemonic.

Okay.

Thanks, David


Re: [PATCH 5/6] rs6000: Merge ashrsi3 and ashrdi3

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:47 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 The last (and ugliest) kind of shift.

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 2014-06-21  Segher Boessenkool  seg...@kernel.crashing.org

 gcc/
 * config/rs6000/rs6000.md (ashrsi3, two anonymous define_insns and 
 define_splits,
 ashrdi3, *ashrdi3_internal1, *ashrdi3_internal2 and split,
 *ashrdi3_internal3 and split): Delete, merge into...
 (ashrmode3): New expander.
 (*ashrmode3, ashrmode3_dot, ashrmode3_dot2): New.
 (*ashrsi3_64): Fix formatting.  Replace i by n.

Okay.

Thanks, David


Re: [PATCH 6/6] rs6000: Merge the var_shift yes/no alternatives

2014-06-22 Thread David Edelsohn
On Sat, Jun 21, 2014 at 10:47 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 All instructions that are var_shift for some alternative have the shift
 amount as operands[2].

 This patch introduces an attribute maybe_var_shift.  If that is set to
 yes, the default value of var_shift is set based on the operands[2]
 value.

 With that, we can merge the var_shift yes/no cases everywhere.  Do so.

 Also change some more i to n.

 Bootstrapped and tested on powerpc64-linux, {-m64,-m64/-mtune=power8,
 -m32,-m32/-mpowerpc64}, no regressions.  Okay to apply?


 Segher


 2014-06-21  Segher Boessenkool  seg...@kernel.crashing.org

 gcc/
 * config/rs6000/rs6000.md (maybe_var_shift): New define_attr.
 (var_shift): Use it.
 (rotlmode3, *rotlsi3_64, *rotlmode3_dot, *rotlmode3_dot2,
 *rotlsi3_internal4, *rotlsi3_internal5, *rotlsi3_internal6,
 *rotlsi3_internal8le, *rotlsi3_internal8be, *rotlsi3_internal9le,
 *rotlsi3_internal9be, *rotlsi3_internal10le, *rotlsi3_internal10be,
 *rotlsi3_internal11le, *rotlsi3_internal11be, *rotlsi3_internal12le,
 *rotlsi3_internal12be, ashlmode3, *ashlsi3_64, *ashlmode3_dot,
 *ashlmode3_dot2, lshrmode3, *lshrsi3_64, *lshrmode3_dot,
 *lshrmode3_dot2, *ashrmode3, *ashrsi3_64, *ashrmode3_dot,
 *ashrmode3_dot2, *rotldi3_internal4, *rotldi3_internal5,
 *rotldi3_internal6, *rotldi3_internal7le, *rotldi3_internal7be,
 *rotldi3_internal8le, *rotldi3_internal8be, *rotldi3_internal9le,
 *rotldi3_internal9be, *rotldi3_internal10le, *rotldi3_internal10be,
 *rotldi3_internal11le, *rotldi3_internal11be, *rotldi3_internal12le,
 *rotldi3_internal12be, *rotldi3_internal13le, *rotldi3_internal13be,
 *rotldi3_internal14le, *rotldi3_internal14be, *rotldi3_internal15le,
 *rotldi3_internal15be): Use the new attribute.  Merge register and
 integer alternatives.

Okay, with the hH fix that you also noticed.

Thanks, David


[doc] Remove duplicate -Wmaybe-uninitialized

2014-06-22 Thread Marc Glisse

Hello,

a trivial patch to remove a duplicated option, you can see the second one 
4 lines below in the patch. (the mixed use of single or double spaces in 
this list is strange)


This was included in the bootstrap of another patch.

2014-06-23  Marc Glisse  marc.gli...@inria.fr

* doc/invoke.texi (Warning Options): Remove duplicated
-Wmaybe-uninitialized.

--
Marc GlisseIndex: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 211874)
+++ gcc/doc/invoke.texi (working copy)
@@ -246,21 +246,21 @@ Objective-C and Objective-C++ Dialects}.
 -Wno-deprecated -Wno-deprecated-declarations -Wdisabled-optimization  @gol
 -Wno-discarded-qualifiers @gol
 -Wno-div-by-zero -Wdouble-promotion -Wempty-body  -Wenum-compare @gol
 -Wno-endif-labels -Werror  -Werror=* @gol
 -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
 -Wformat-security  -Wformat-signedness  -Wformat-y2k @gol
 -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol
 -Wignored-qualifiers @gol
 -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int @gol
--Winit-self  -Winline -Wmaybe-uninitialized @gol
+-Winit-self  -Winline @gol
 -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
 -Winvalid-pch -Wlarger-than=@var{len}  -Wunsafe-loop-optimizations @gol
 -Wlogical-op -Wlogical-not-parentheses -Wlong-long @gol
 -Wmain -Wmaybe-uninitialized -Wmissing-braces  -Wmissing-field-initializers 
@gol
 -Wmissing-include-dirs @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow -Wopenmp-simd @gol
 -Woverlength-strings  -Wpacked  -Wpacked-bitfield-compat  -Wpadded @gol
 -Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
 -Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls  -Wno-return-local-addr @gol


Warn when returning the address of a temporary (middle-end) v2

2014-06-22 Thread Marc Glisse

Hello,

I followed the advice in this discussion:
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg00269.html

and here is a new patch. I made an effort to isolate a path in at least 
one subcase so it doesn't look too strange that the warning is in this 
file. Computing the dominance info just to tweak the warning message may 
be a bit excessive. I kept the same option as the front-ends, I don't know 
if we want a different one, or maybe a Wmaybe-... version. There will be 
cases where we get a duplicate warning from -Wtarget-lifetime in fortran, 
but none in the testsuite, and I would rather have 2 warnings than miss 
such broken code. The uninit-G testcase is about initialization, not 
returning, so I am changing that, even if it is unnecessary with the 
current version of the patch (only activated at -O2).


Bootstrap+testsuite (--enable-languages=all,obj-c++,ada,go) on 
x86_64-unknown-linux-gnu.


(by the way, contrib/compare_tests is confused when I use all languages, 
it prints comm: file 1 is not in sorted order and tons of spurious 
differences)


2014-06-23  Marc Glisse  marc.gli...@inria.fr

PR c++/60517
gcc/c/
* c-typeck.c (c_finish_return): Return 0 instead of the address of
a local variable.
gcc/cp/
* typeck.c (maybe_warn_about_returning_address_of_local): Return
whether it is returning the address of a local variable.
(check_return_expr): Return 0 instead of the address of a local
variable.
gcc/c-family/
* c.opt (-Wreturn-local-addr): Move to common.opt.
gcc/
* common.opt (-Wreturn-local-addr): Moved from c.opt.
* gimple-ssa-isolate-paths.c: Include diagnostic-core.h.
(isolate_path): New argument to avoid inserting a trap.
(find_implicit_erroneous_behaviour): Handle returning the address
of a local variable.
(find_explicit_erroneous_behaviour): Likewise.
(gimple_ssa_isolate_erroneous_paths): Calculate dominance info.
gcc/testsuite/
* c-c++-common/addrtmp.c: New file.
* c-c++-common/uninit-G.c: Adapt.

--
Marc GlisseIndex: gcc/c/c-typeck.c
===
--- gcc/c/c-typeck.c(revision 211874)
+++ gcc/c/c-typeck.c(working copy)
@@ -9315,22 +9315,26 @@ c_finish_return (location_t loc, tree re
 
  if (DECL_P (inner)
   !DECL_EXTERNAL (inner)
   !TREE_STATIC (inner)
   DECL_CONTEXT (inner) == current_function_decl)
{
  if (TREE_CODE (inner) == LABEL_DECL)
warning_at (loc, OPT_Wreturn_local_addr,
function returns address of label);
  else
-   warning_at (loc, OPT_Wreturn_local_addr,
-   function returns address of local variable);
+   {
+ warning_at (loc, OPT_Wreturn_local_addr,
+ function returns address of local variable);
+ tree zero = build_zero_cst (TREE_TYPE (res));
+ t = build_compound_expr (loc, t, zero);
+   }
}
  break;
 
default:
  break;
}
 
  break;
}
 
Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 211874)
+++ gcc/c-family/c.opt  (working copy)
@@ -682,24 +682,20 @@ ObjC ObjC++ Var(warn_protocol) Init(1) W
 Warn if inherited methods are unimplemented
 
 Wredundant-decls
 C ObjC C++ ObjC++ Var(warn_redundant_decls) Warning
 Warn about multiple declarations of the same object
 
 Wreorder
 C++ ObjC++ Var(warn_reorder) Warning LangEnabledBy(C++ ObjC++,Wall)
 Warn when the compiler reorders code
 
-Wreturn-local-addr
-C ObjC C++ ObjC++ Var(warn_return_local_addr) Init(1) Warning
-Warn about returning a pointer/reference to a local or temporary variable.
-
 Wreturn-type
 C ObjC C++ ObjC++ Var(warn_return_type) Warning LangEnabledBy(C ObjC C++ 
ObjC++,Wall)
 Warn whenever a function's return type defaults to \int\ (C), or about 
inconsistent return types (C++)
 
 Wselector
 ObjC ObjC++ Var(warn_selector) Warning
 Warn if a selector has multiple methods
 
 Wshadow-ivar
 ObjC ObjC++ Var(warn_shadow_ivar) EnabledBy(Wshadow) Init(1) Warning
Index: gcc/common.opt
===
--- gcc/common.opt  (revision 211874)
+++ gcc/common.opt  (working copy)
@@ -596,20 +596,24 @@ Common Var(warn_packed) Warning
 Warn when the packed attribute has no effect on struct layout
 
 Wpadded
 Common Var(warn_padded) Warning
 Warn when padding is required to align structure members
 
 Wpedantic
 Common Var(pedantic) Warning
 Issue warnings needed for strict compliance to the standard
 
+Wreturn-local-addr
+Common Var(warn_return_local_addr) Init(1) Warning
+Warn about returning a 

Re: [PATCH] Fix up -march=native handling under KVM (PR target/61570)

2014-06-22 Thread Uros Bizjak
On Sat, Jun 21, 2014 at 8:07 PM, Jakub Jelinek ja...@redhat.com wrote:

  --- gcc/config/i386/driver-i386.c.jj2014-05-14 14:45:54.0 +0200
  +++ gcc/config/i386/driver-i386.c   2014-06-20 18:59:57.805006358 +0200
  @@ -745,6 +745,11 @@ const char *host_detect_local_cpu (int a
  /* Assume Core 2.  */
  cpu = core2;
  }
  + else if (has_longmode)
  +   /* Perhaps some emulator?  Assume x86-64, otherwise gcc
  +  -march=native would be unusable for 64-bit compilations,
  +  as all the CPUs below are 32-bit only.  */
  +   cpu = x86-64;
else if (has_sse3)
  /* It is Core Duo.  */
  cpu = pentium-m;
 
  Jakub

 host_detect_local_cpu guesses the cpu based on the real processors.
 It doesn't work with emulators due to some conflicts.  This isn't the
 only only place which has the same issue.   I prefer something like
 this.

 I'm fine with your patch too.  Let's wait what Uros (or other i?86
 maintainers) pick up.

This looks OK to me.

Thanks,
Uros.


Re: Another AIX Bootstrap failure

2014-06-22 Thread Jan Hubicka
 The new testcases also declare main() as void, but return 0.

I fixed that with previous commit too (what happened is that I managed to
copy wrong version of the files while testing that they fail on AIX.
They indeed did fail, but for wrong versoin)

Honza


Re: [C/C++ PATCH] Add -Wlogical-not-parentheses (PR c/49706)

2014-06-22 Thread Gerald Pfeifer
On Mon, 2 Jun 2014, Marek Polacek wrote:
   * c-typeck.c (parser_build_binary_op): Warn when logical not is used
   on the left hand side operand of a comparison. 

This...

 +/* Warn about logical not used on the left hand side operand of a comparison.

...and this...

 +  warning_at (location, OPT_Wlogical_not_parentheses,
 +   logical not is only applied to the left hand side of 
 +   comparison);

...does not appear consistent with the actual warning.

Why does that warning say is _ONLY_ applied to the left hand side?

Based on the message, I naively assumed that the code should not warn
about

  int same(int a, int b) {
return !a == !b;
  }

alas this is not the case.  (Code like this occurs in Wine where
bool types are emulated and !!a or a comparison like above ensure
that those emulated bools are normalized to either 0 or 1.)


I understand there is ambiguity in cases like

  return !a == b;

where the warning would be approriately worded and the programmer
might have intended !(a == b).


I do recommend to either omit only from the text of the warning
or not warn for cases where ! occurs on both sides of the comparison
(and keep the text as is).

Gerald


Re: [patch] Update libstdc++ FAQ and ensure stable anchors in HTML docs

2014-06-22 Thread Gerald Pfeifer

On Mon, 9 Jun 2014, Jonathan Wakely wrote:

This fairly tedious patch refreshes the FAQ, including adding some
notes saying This answer is old and probably no longer relevant to
several answers referring to problems in the GCC 3.x era.


I'm wondering, should those old items be removed?  GCC 3.x is
really a looong while ago (and I did check some of those items).

A FAQ that containts many NAFAQs (not actually frequently asked 
questions) may actually be less useful and paint a more negative

picture.

Gerald


[PATCH] Only transform rotate to rotatert and v.v. if target has both

2014-06-22 Thread Segher Boessenkool
Many targets do not have both rotate and rotatert.  Of the 47 targets
in the tree, 17 have both, 9 have only rotate, 2 have only rotatert, and
19 have neither (this is based on grep -wil so it can be slightly off).

rs6000 has only rotate, and mips has only rotatert.  For such targets
simplifying rotate to rotatert and vice versa is not simplifying things
at all.  rs6000 has already way too many rotate patterns (some days it
seems like two thousand, but it is somewhat less in reality still); I
would prefer not to double that again.

So, this patch makes genrecog define HAVE_rotate and HAVE_rotatert if
those RTL codes are mentioned anywhere in the machine description, and
then does the transformation in simplify-rtx.c only if both these flags
are set.

Bootstrapped and tested on powerpc64-linux.  Okay to apply?


Segher


2014-06-22  Segher Boessenkool  seg...@kernel.crashing.org

gcc/
* genconfig.c (have_rotate_flag, have_rotatert_flag): New
variables.
(walk_insn_part) ROTATE, ROTATERT: New cases.
(main): Conditionally write HAVE_rotate c.q. HAVE_rotatert.
* simplify-rtx.c (simplify_binary_operation_1) ROTATE, ROTATERT:
Only do the transformation if both HAVE_rotate and HAVE_rotatert.

---
 gcc/genconfig.c| 18 ++
 gcc/simplify-rtx.c |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/gcc/genconfig.c b/gcc/genconfig.c
index cafa8d3..d1996c3 100644
--- a/gcc/genconfig.c
+++ b/gcc/genconfig.c
@@ -36,6 +36,8 @@ static int have_cc0_flag;
 static int have_cmove_flag;
 static int have_cond_exec_flag;
 static int have_lo_sum_flag;
+static int have_rotate_flag;
+static int have_rotatert_flag;
 static int have_peephole_flag;
 static int have_peephole2_flag;
 
@@ -117,6 +119,16 @@ walk_insn_part (rtx part, int recog_p, int non_pc_set_src)
have_lo_sum_flag = 1;
   return;
 
+case ROTATE:
+  if (recog_p)
+   have_rotate_flag = 1;
+  return;
+
+case ROTATERT:
+  if (recog_p)
+   have_rotatert_flag = 1;
+  return;
+
 case SET:
   walk_insn_part (SET_DEST (part), 0, recog_p);
   walk_insn_part (SET_SRC (part), recog_p,
@@ -346,6 +358,12 @@ main (int argc, char **argv)
   if (have_lo_sum_flag)
 printf (#define HAVE_lo_sum 1\n);
 
+  if (have_rotate_flag)
+printf (#define HAVE_rotate 1\n);
+
+  if (have_rotatert_flag)
+printf (#define HAVE_rotatert 1\n);
+
   if (have_peephole_flag)
 printf (#define HAVE_peephole 1\n);
 
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 181b56f..07b9353 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -3076,6 +3076,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum 
machine_mode mode,
 prefer left rotation, if op1 is from bitsize / 2 + 1 to
 bitsize - 1, use other direction of rotate with 1 .. bitsize / 2 - 1
 amount instead.  */
+#if defined(HAVE_rotate)  defined(HAVE_rotatert)
   if (CONST_INT_P (trueop1)
   IN_RANGE (INTVAL (trueop1),
   GET_MODE_BITSIZE (mode) / 2 + (code == ROTATE),
@@ -3083,6 +3084,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum 
machine_mode mode,
return simplify_gen_binary (code == ROTATE ? ROTATERT : ROTATE,
mode, op0, GEN_INT (GET_MODE_BITSIZE (mode)
- INTVAL (trueop1)));
+#endif
   /* FALLTHRU */
 case ASHIFTRT:
   if (trueop1 == CONST0_RTX (mode))
-- 
1.8.1.4



Re: [patch, mips] delete bit-rotten ADJUST_REG_ALLOC_ORDER definition

2014-06-22 Thread Sandra Loosemore

On 05/14/2014 12:49 PM, Richard Sandiford wrote:

Jeff Law l...@redhat.com writes:

On 05/13/14 14:11, Sandra Loosemore wrote:


2014-05-13  Catherine Moore  c...@codesourcery.com
  Sandra Loosemore  san...@codesourcery.com

  gcc/
  * config/mips/mips.c (mips_order_regs_for_local_alloc): Delete.
  * config/mips/mips.h (ADJUST_REG_ALLOC_ORDER): Delete.
  * config/mips/mips-protos.h (mips_order_regs_for_local_alloc): Delete.

OK for the trunk.


Would it be OK to hold off until after the switch to LRA?  That patch
has been written and the MIPS parts approved, but we're waiting for
some legal things to be sorted out and for a fixed version of the LRA
EXTRA_MEMORY_CONSTRAINT patch.  I just think it'd be better to tune this
sort of thing once that's done, rather than tune it against reload.


Richard, is it OK to commit this patch now that LRA is in, or do you 
want to experiment some more with tuning first?  I think we're all in 
agreement that this is broken old code that should be removed regardless 
of whether we do other things to tune REG_ALLOC_ORDER.


-Sandra



RE: [Committed] [PATCH] PR61123 : Fix the ABI mis-matching error caused by LTO

2014-06-22 Thread Hale Wang


 -Original Message-
 From: Jakub Jelinek [mailto:ja...@redhat.com]
 Sent: 2014年6月21日 5:24
 To: Hale Wang
 Cc: 'Mike Stump'; Richard Biener; Mike Stump; GCC Patches
 Subject: Re: [Committed] [PATCH] PR61123 : Fix the ABI mis-matching error
 caused by LTO
 
 On Fri, Jun 20, 2014 at 01:14:52PM +0800, Hale Wang wrote:
  2014-06-20 Hale Wang hale.w...@arm.com
 
  * gcc.target/arm/lto/: New folder to verify the LTO option.
  * gcc.target/arm/lto/pr61123-enum-size_0.c: New test case.
  * gcc.target/arm/lto/pr61123-enum-size_1.c: Likewise.
  * gcc.target/arm/lto/lto.exp: New exp file used to test LTO
option.
  * lib/lto.exp (object-readelf): New procedure.
 
 This FAILs on non-arm targets.
 
 I've committed following fix as obvious.

Thank you very much.

 On the other side, if you don't plan to add too many arm LTO tests,
 supposedly putting it into gcc.dg/lto and just using arm*-*-* target
selector
 might be better.

We plan to add more cases to check LTO ABI issues, like short-wchar. All the
ABI would be ARM special. So all the test cases would be ARM special.

Thanks and Best Regards,
Hale Wang 
 
 2014-06-20  Jakub Jelinek  ja...@redhat.com
 
   * gcc.target/arm/lto/lto.exp: Exit immediately if not arm*-*-*
target.
 
 --- gcc/testsuite/gcc.target/arm/lto/lto.exp.jj   2014-06-20
 08:02:50.0 +0200
 +++ gcc/testsuite/gcc.target/arm/lto/lto.exp  2014-06-20
 23:19:33.850043692 +0200
 @@ -16,6 +16,10 @@
  #
  # Contributed by Diego Novillo dnovi...@google.com
 
 +# Exit immediately if this isn't an ARM target.
 +if ![istarget arm*-*-*] then {
 +  return
 +}
 
  # Test link-time optimization across multiple files.
  #
 
 
   Jakub





[Committed] [PATCH, loop2_invariant] Pre-check invariants

2014-06-22 Thread Zhenqiang Chen
On 18 June 2014 05:32, Jeff Law l...@redhat.com wrote:
 On 06/11/14 03:35, Zhenqiang Chen wrote:


 Thanks for the comments. df_live seams redundant.

 With flag_ira_loop_pressure, the pass will call df_analyze () at the
 beginning, which can make sure all the DF info are correct.

 Can we guarantee all DF_... correct without df_analyze ()?

 They should be fine in this context.



 +/* Pre-check candidate DEST to skip the one which can not make a valid
 insn
 +   during move_invariant_reg.  SIMPlE is to skip HARD_REGISTER.  */

 s/SIMPlE/SIMPLE/



 + {
 +   /* Multi definitions at this stage, most likely are due to
 +  instruction constrain, which requires both read and
 write

 s/constrain/constraints/

 Though that doesn't make sense.  Constraints don't come into play until much
 later in the pipeline.   Certainly there's been code in the expanders and
 elsewhere to try and make the code we generate more acceptable to 2-address
 targets and that's probably what you're really running into.   I think the
 code is fine, but that you need to improve the comment.

 ISTM that if your primary focus is to filter out read/write operands, then
 just say that and ignore the constraints or other mechanisms by which we got
 a read/write pseudo.

 So I think with those two small comment changes, this patch is OK for the
 trunk.  Please post the final version for archival purposes before checking
 it in.

Thanks. Patch was installed @r211885 with the two comment changes and
one more change to use

FOR_EACH_INSN_INFO_DEF

other than

for (def_rec = DF_INSN_INFO_DEFS (insn_info); *def_rec; def_rec++)

Bootstrap and no make check regression on X86-64.

Index: gcc/loop-invariant.c
===
--- gcc/loop-invariant.c(revision 211832)
+++ gcc/loop-invariant.c(working copy)
@@ -839,6 +839,39 @@
   return true;
 }

+/* Pre-check candidate DEST to skip the one which can not make a valid insn
+   during move_invariant_reg.  SIMPLE is to skip HARD_REGISTER.  */
+static bool
+pre_check_invariant_p (bool simple, rtx dest)
+{
+  if (simple  REG_P (dest)  DF_REG_DEF_COUNT (REGNO (dest))  1)
+{
+  df_ref use;
+  rtx ref;
+  unsigned int i = REGNO (dest);
+  struct df_insn_info *insn_info;
+  df_ref def_rec;
+
+  for (use = DF_REG_USE_CHAIN (i); use; use = DF_REF_NEXT_REG (use))
+   {
+ ref = DF_REF_INSN (use);
+ insn_info = DF_INSN_INFO_GET (ref);
+
+ FOR_EACH_INSN_INFO_DEF (def_rec, insn_info)
+   if (DF_REF_REGNO (def_rec) == i)
+ {
+   /* Multi definitions at this stage, most likely are due to
+  instruction constraints, which requires both read and write
+  on the same register.  Since move_invariant_reg is not
+  powerful enough to handle such cases, just ignore the INV
+  and leave the chance to others.  */
+   return false;
+ }
+   }
+}
+  return true;
+}
+
 /* Finds invariant in INSN.  ALWAYS_REACHED is true if the insn is always
executed.  ALWAYS_EXECUTED is true if the insn is always executed,
unless the program ends due to a function call.  */
@@ -868,7 +901,8 @@
   || HARD_REGISTER_P (dest))
 simple = false;

-  if (!may_assign_reg_p (SET_DEST (set))
+  if (!may_assign_reg_p (dest)
+  || !pre_check_invariant_p (simple, dest)
   || !check_maybe_invariant (SET_SRC (set)))
 return;


Re: [PATCH] Trust TREE_ADDRESSABLE

2014-06-22 Thread Jan Hubicka
  On Fri, 13 Jun 2014, Jan Hubicka wrote:
  

When you extract the address and use it.  For example when you
do auto-parallelization and outline a part of your function it
passes arrays as addresses.

Or if you start to introduce address induction variables like
the vectorizer or IVOPTs does.
   
   I see, nothing really done by current early/IPA optimizers and in those 
   cases
   we also want to set TREE_ADDRESSABLE bit, too I suppose.
   Do you think I should make patch for setting the NOVOPS bits in ipa code?
  
  No, please don't introduce new users of NOVOPS (it's a quite broken
  hack - it's sth like a 'const' function with side-effects so we should
  have instead used 'const' and some kind of volatile flag).  We're
  not using NOVOPS much and that's good (I think handling of such
  function calls are somewhat broken).
 
 I meant DECL_NONALIASED.  I will test the patch and lets see.

Hi,
this patch adds the discussed code to set DECL_NOALIASED so we get better AA
with partitioning.  We probably also can sed DECL_NOALIASED for variables
whose address is passed only to external calls that do not capture the
parameters (i.e. memset).

I suppose I can teach ipa-ref code about this, but will need a bit of
extra infrastructure for that, since currently REF_ADDR does not associate
any information about these.

Martin, this is related to your controlled uses.  What do you think about adding
stable UIDs into ipa_ref datastructure and then adding a vector into cgraph 
edges
that describe what REFs are directly used as parameters of a given callsite?
It will take some work to maintain these, but we will be able to remove them 
when
call site or parameter was eliminated in a more general way.

I suppose we could also use these to associate REFs with given use in the
satement or constructor (i.e. have pointer to statement as well as pointer to
specific use within the statement). With this we will be able to redirect
references same way as we redirect callgraph edges now.  This is something I
need to for the ipa-visibility optimizations.

Honza

Bootstrapped/regtested and lto-bootstrapped x86_64-linux, will commit it 
shortly.

* ipa.c (clear_addressable_bit): Set also DECL_NONALIASED.
(ipa_discover_readonly_nonaddressable_var): Compute also NONALIASED.
Index: ipa.c
===
--- ipa.c   (revision 211881)
+++ ipa.c   (working copy)
@@ -669,6 +669,10 @@ clear_addressable_bit (varpool_node *vno
 {
   vnode-address_taken = false;
   TREE_ADDRESSABLE (vnode-decl) = 0;
+  /* Set also non-aliased bit.  In LTO, when program is partitioned, we no 
longer
+ trust TREE_ADDRESSABLE for TREE_PUBLIC variables and then DECL_NONALIASED 
is
+ useful to improve code.  */
+  DECL_NONALIASED (vnode-decl) = 1;
   return false;
 }
 
@@ -690,6 +694,7 @@ ipa_discover_readonly_nonaddressable_var
   FOR_EACH_VARIABLE (vnode)
 if (!vnode-alias
 (TREE_ADDRESSABLE (vnode-decl)
+   || !DECL_NONALIASED (vnode-decl)
|| !vnode-writeonly
|| !TREE_READONLY (vnode-decl)))
   {
@@ -703,8 +708,8 @@ ipa_discover_readonly_nonaddressable_var
  continue;
if (!address_taken)
  {
-   if (TREE_ADDRESSABLE (vnode-decl)  dump_file)
- fprintf (dump_file,  %s (non-addressable), vnode-name ());
+   if ((TREE_ADDRESSABLE (vnode-decl) || !DECL_NONALIASED 
(vnode-decl))  dump_file)
+ fprintf (dump_file,  %s (non-addressable non-aliased), 
vnode-name ());
varpool_for_node_and_aliases (vnode, clear_addressable_bit, NULL, 
true);
  }
if (!address_taken  !written


Add used_by_single_function flag for static variables

2014-06-22 Thread Jan Hubicka
Hi,
this is patch to add the used_by_single_function flag to varpool.  In full 
generality
it is a simple dataflow problem, since the variable may be referred by other 
variables
as long as all of them are used by one function only.  I have 
bootstrapped/regtested it
on x86_64-linux and lto-bootstrapped with the following variant of earlier 
Richard's
patch to tree-ssa-dce:
Index: tree-ssa-dce.c
===
--- tree-ssa-dce.c  (revision 211881)
+++ tree-ssa-dce.c  (working copy)
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.
 #include flags.h
 #include cfgloop.h
 #include tree-scalar-evolution.h
+#include cgraph.h
 
 static struct stmt_stats
 {
@@ -278,10 +279,21 @@ mark_stmt_if_obviously_necessary (gimple
   break;
 
 case GIMPLE_ASSIGN:
-  if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
-  TREE_CLOBBER_P (gimple_assign_rhs1 (stmt)))
-   return;
-  break;
+  {
+   tree lhs = gimple_assign_lhs (stmt);
+   if (TREE_CODE (lhs) == SSA_NAME
+TREE_CLOBBER_P (gimple_assign_rhs1 (stmt)))
+ return;
+   lhs = get_base_address (lhs);
+   if (TREE_CODE (lhs) == VAR_DECL
+!TREE_ADDRESSABLE (lhs)
+!DECL_NONALIASED (lhs)
+!TREE_THIS_VOLATILE (lhs)
+(TREE_STATIC (lhs) || DECL_EXTERNAL (lhs))
+varpool_node_for_decl (lhs)-used_by_single_function)
+ return;
+   break;
+  }
 
 default:
   break;

I will keep the dce change to Richard - in full generality we may want to
handle asm statements (that seems to be all considered volatile by current
implementation) and calls, too.

The propagation part is not realy consumed by dce but it is useful for other
analysis, like PTA.  Richard, I can also compute flag whether the function
may recurse meaning that it is in SCC region or may call external function or
indirect call (transitively). I guess this may be useful to determine whether 
calls
can use these variables if they are proven to be non-escaping.

Will commit it shortly,
Honza

Index: varpool.c
===
--- varpool.c   (revision 211881)
+++ varpool.c   (working copy)
@@ -211,6 +211,8 @@ dump_varpool_node (FILE *f, varpool_node
 fprintf (f,  initialized);
   if (node-output)
 fprintf (f,  output);
+  if (node-used_by_single_function)
+fprintf (f,  used-by-single-function);
   if (TREE_READONLY (node-decl))
 fprintf (f,  read-only);
   if (ctor_for_folding (node-decl) != error_mark_node)
Index: tree-pass.h
===
--- tree-pass.h (revision 211881)
+++ tree-pass.h (working copy)
@@ -471,6 +471,7 @@ extern simple_ipa_opt_pass *make_pass_ip
 extern simple_ipa_opt_pass *make_pass_omp_simd_clone (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_profile (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_cdtor_merge (gcc::context *ctxt);
+extern ipa_opt_pass_d *make_pass_ipa_single_use (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_comdats (gcc::context *ctxt);
 
 extern gimple_opt_pass *make_pass_cleanup_cfg_post_optimizing (gcc::context
Index: cgraph.h
===
--- cgraph.h(revision 211881)
+++ cgraph.h(working copy)
@@ -719,6 +719,12 @@ public:
   unsigned dynamically_initialized : 1;
 
   ENUM_BITFIELD(tls_model) tls_model : 3;
+
+  /* Set if the variable is known to be used by single function only.
+ This is computed by ipa_signle_use pass and used by late optimizations
+ in places where optimization would be valid for local static variable
+ if we did not do any inter-procedural code movement.  */
+  unsigned used_by_single_function : 1;
 };
 
 /* Every top level asm statement is put into a asm_node.  */
Index: lto-cgraph.c
===
--- lto-cgraph.c(revision 211881)
+++ lto-cgraph.c(working copy)
@@ -614,6 +614,7 @@ lto_output_varpool_node (struct lto_simp
  /* in_other_partition.  */
 }
   bp_pack_value (bp, node-tls_model, 3);
+  bp_pack_value (bp, node-used_by_single_function, 1);
   streamer_write_bitpack (bp);
 
   group = node-get_comdat_group ();
@@ -1275,6 +1276,7 @@ input_varpool_node (struct lto_file_decl
   if (node-alias  !node-analyzed  node-weakref)
 node-alias_target = get_alias_symbol (node-decl);
   node-tls_model = (enum tls_model)bp_unpack_value (bp, 3);
+  node-used_by_single_function = (enum tls_model)bp_unpack_value (bp, 1);
   group = read_identifier (ib);
   if (group)
 {
Index: passes.def
===
--- passes.def  (revision 211881)
+++ passes.def  (working copy)
@@ -109,6 +109,8 @@ along with GCC; see the file COPYING3.
   NEXT_PASS (pass_ipa_inline);
   NEXT_PASS 

[PATCH, PR61554] ICE during CCP

2014-06-22 Thread Chung-Lin Tang
Hi Richard,

In this change:
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01278.html

where substitute_and_fold() was changed to use a dom walker, the calls
to purge dead EH edges during the walk can alter the dom-tree, and have
chaotic results; the testcase in PR 61554 has some blocks traversed
twice during the walk, causing the segfault during CCP.

The patch records the to-be-purged-for-dead-EH blocks in a similar
manner like stmts_to_remove, and processes it after the walk. (another
possible method would be using a bitmap to record the BBs + calling
gimple_purge_all_dead_eh_edges...)

Bootstrapped and tested on x86_64-linux, is this okay for trunk?

Thanks,
Chung-Lin

2014-06-23  Chung-Lin Tang  clt...@codesourcery.com

PR tree-optimization/61554
* tree-ssa-propagate.c (substitute_and_fold_dom_walker):
Add 'vecbasic_block bbs_to_purge_dead_eh_edges' member,
properly update constructor/destructor.
(substitute_and_fold_dom_walker::before_dom_children):
Remove call to gimple_purge_dead_eh_edges, add bb to
bbs_to_purge_dead_eh_edges instead.
(substitute_and_fold): Call gimple_purge_dead_eh_edges for
bbs recorded in bbs_to_purge_dead_eh_edges.
Index: tree-ssa-propagate.c
===
--- tree-ssa-propagate.c	(revision 211874)
+++ tree-ssa-propagate.c	(working copy)
@@ -1031,8 +1031,13 @@ class substitute_and_fold_dom_walker : public dom_
   fold_fn (fold_fn_), do_dce (do_dce_), something_changed (false)
 {
   stmts_to_remove.create (0);
+  bbs_to_purge_dead_eh_edges.create (0);
 }
-~substitute_and_fold_dom_walker () { stmts_to_remove.release (); }
+~substitute_and_fold_dom_walker ()
+{
+  stmts_to_remove.release ();
+  bbs_to_purge_dead_eh_edges.release ();
+}
 
 virtual void before_dom_children (basic_block);
 virtual void after_dom_children (basic_block) {}
@@ -1042,6 +1047,7 @@ class substitute_and_fold_dom_walker : public dom_
 bool do_dce;
 bool something_changed;
 vecgimple stmts_to_remove;
+vecbasic_block bbs_to_purge_dead_eh_edges;
 };
 
 void
@@ -1144,7 +1150,7 @@ substitute_and_fold_dom_walker::before_dom_childre
 	  /* If we cleaned up EH information from the statement,
 	 remove EH edges.  */
 	  if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))
-	gimple_purge_dead_eh_edges (bb);
+	bbs_to_purge_dead_eh_edges.safe_push (bb);
 
 	  if (is_gimple_assign (stmt)
 	   (get_gimple_rhs_class (gimple_assign_rhs_code (stmt))
@@ -1235,6 +1241,14 @@ substitute_and_fold (ssa_prop_get_value_fn get_val
 	}
 }
 
+  while (!walker.bbs_to_purge_dead_eh_edges.is_empty ())
+{
+  basic_block bb = walker.bbs_to_purge_dead_eh_edges.pop ();
+  gimple_purge_dead_eh_edges (bb);
+  if (dump_file  dump_flags  TDF_DETAILS)
+	fprintf (dump_file, Purge dead EH edges from bb %d\n, bb-index);
+}
+
   statistics_counter_event (cfun, Constants propagated,
 			prop_stats.num_const_prop);
   statistics_counter_event (cfun, Copies propagated,