Re: [Aarch64] Add support for ARMv8.1 command line options.

2015-06-16 Thread Marcus Shawcroft
On 4 June 2015 at 10:16, Matthew Wahab matthew.wa...@arm.com wrote:

 gcc/
 2015-06-4  Matthew Wahab  matthew.wa...@arm.com

 * config/aarch64/aarch64-arches.def: Add armv8.1-a.
 * config/aarch64/aarch64-options-extensions.def: Update fP,
 simd and crypto.  Add lse, pan, lor and rdma.
 * gcc/config/aarch64/aarch64.h (AARCH64_FL_LSE): New.
 (AARCH64_FL_PAN): New.
 (AARCH64_FL_LOR): New.
 (AARCH64_FL_RDMA): New.
 (AARCH64_FL_FOR_ARCH8_1): New.
 * doc/invoke.texi (AArch64 Options): Add armv8.1-a to
 -march. Add lse, pan, lor, rdma to feature modifiers.

OK /Marcus


[PATCH][ARM] PR/66433: Reduce cost of memory instructions with autoincrement

2015-06-16 Thread Yury Usishchev
Hello!

Following patch fixes PR target/66433.

As described in PR, cost of memory operation with autoincrement is
considered to be greater than same operation without autoincrement. This
causes auto-inc-dec pass not to optimize vector memory operations like
vld and vst.

Bootstrapped and regtested on armv7l-linux-gnueabi on trunk.
OK for trunk?

--
BR,
Yury Usishchev


gcc/
2015-06-16  Yury Usishchev  y.usishc...@samsung.com

PR target/66433
* config/arm/arm.c (arm_new_rtx_costs): Reduce cost of memory 
instructions
with autoincrement.

gcc/testsuite/
2015-06-16  Yury Usishchev  y.usishc...@samsung.com

PR target/66433
* gcc.target/arm/pr66433.c: New test.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index f5050cb..a8dc0ed 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -9444,7 +9444,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 case MEM:
   /* A memory access costs 1 insn if the mode is small, or the address is
 	 a single register, otherwise it costs one insn per word.  */
-  if (REG_P (XEXP (x, 0)))
+  if (REG_P (XEXP (x, 0))
+	  || (GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_AUTOINC
+	   REG_P (XEXP (XEXP (x, 0), 0
 	*cost = COSTS_N_INSNS (1);
   else if (flag_pic
 	GET_CODE (XEXP (x, 0)) == PLUS
diff --git a/gcc/testsuite/gcc.target/arm/pr66433.c b/gcc/testsuite/gcc.target/arm/pr66433.c
new file mode 100644
index 000..22ba158
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr66433.c
@@ -0,0 +1,21 @@
+/* Test the optimization of `vld*' ARM NEON intrinsic with autoincrement. */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options -O2 } */
+/* { dg-add-options arm_neon } */
+
+#include arm_neon.h
+
+void test_vld_autoinc (uint32_t *__restrict__ a, uint32_t *__restrict__ b)
+{
+  int i;
+  for(i = 0; i  100; i++) {
+vst1q_u32 (b, vld1q_u32 (a));
+a += 4;
+b += 4;
+  }
+}
+
+/* { dg-final { scan-assembler vld1\.32.*!.*\n } } */
+/* { dg-final { scan-assembler vst1\.32.*!.*\n } } */


Re: [PATCH][GSoC] Extend shared_ptr to support arrays

2015-06-16 Thread Jonathan Wakely

On 16/06/15 21:15 +0800, Fan You wrote:

You will also need to write new tests (under testsuite/experimental/)
to check that your new code works as intended.



Is there any pattern or rules I should follow when writing testcase, or I
can just refer to 20_util/* and add some array specified tests?


Follow the style of the 20_util tests, but put the new ones under
testsuite/experimental. Tim can help you with any questions about the
testsuite, it doesn't need to be discussed on the gcc-patches list
(since there's nothing ready to be committed yet anyway).


I wonder if all the new code really needs to be in bits/shared_ptr.h



why it need to be in bits/shared_ptr.h?


It doesn't, that's what I mean.

All the new code is only usable after including experimental/memory,
but you have added lots of code to bits/shared_ptr.h.


or if it can just be in experimental/memory instead. There should be
no need to declare most of it (except maybe the enable_shared_from_this
parts?) when users include memory.





So, what else should I do before its ready to be committed?


Tests, tests and more tests.

Currently you haven't got a single test, so I have no way of knowing
if the code even does what it's supposed to do.

Once you have written tests and they all pass then we can review the
code again fully and get it ready to commit. We are not there yet.

It might be a good idea to publish your changes somewhere visible, so
that people who want to try your code can clone it and test it without
having to apply patches. Are you using Git locally?  If you have a
github account you could fork https://github.com/gcc-mirror/gcc and
then push your changes to a new branch in your fork.



Re: [PATCH, rs6000, testsuite, PR65456] Changes for unaligned vector load/store support on POWER8

2015-06-16 Thread Bill Schmidt
On Tue, 2015-06-16 at 14:37 +0100, Vidya Praveen wrote:
 On Mon, Jun 15, 2015 at 08:14:31PM +0100, Bill Schmidt wrote:
  On Fri, 2015-06-12 at 17:36 +0100, Vidya Praveen wrote:
   On Thu, Apr 30, 2015 at 01:34:18PM +0100, Bill Schmidt wrote:
On Thu, 2015-04-30 at 18:26 +0800, Bin.Cheng wrote:
 On Mon, Apr 27, 2015 at 9:26 PM, Bill Schmidt
 wschm...@linux.vnet.ibm.com wrote:
  On Mon, 2015-04-27 at 14:23 +0800, Bin.Cheng wrote:
  On Mon, Mar 30, 2015 at 1:42 AM, Bill Schmidt
  wschm...@linux.vnet.ibm.com wrote:
 
 
   Index: gcc/testsuite/gcc.dg/vect/vect-33.c
   ===
   --- gcc/testsuite/gcc.dg/vect/vect-33.c (revision 221118)
   +++ gcc/testsuite/gcc.dg/vect/vect-33.c (working copy)
   @@ -36,9 +36,10 @@ int main (void)
  return main1 ();
}
  
   +/* vect_hw_misalign  { ! vect64 } */
  
/* { dg-final { scan-tree-dump-times vectorized 1 loops 1 
   vect  } } */
   -/* { dg-final { scan-tree-dump Vectorizing an unaligned 
   access vect { target { vect_hw_misalign  { {! vect64} || 
   vect_multiple_sizes } } } } } */
   +/* { dg-final { scan-tree-dump Vectorizing an unaligned 
   access vect { target { { { ! powerpc*-*-* }  
   vect_hw_misalign }  { { ! vect64 } || vect_multiple_sizes } } 
   } } }  */
/* { dg-final { scan-tree-dump Alignment of access forced 
   using peeling vect { target { vector_alignment_reachable  { 
   vect64  {! vect_multiple_sizes} } } } } } */
/* { dg-final { scan-tree-dump-times Alignment of access 
   forced using versioning 1 vect { target { { {! 
   vector_alignment_reachable} || {! vect64} }  {! 
   vect_hw_misalign} } } } } */
/* { dg-final { cleanup-tree-dump vect } } */
 
  Hi Bill,
  With this change, the test case is skipped on aarch64 now.  Since 
  it
  passed before, Is it expected to act like this on 64bit platforms?
 
  Hi Bin,
 
  No, that's a mistake on my part -- thanks for the report!  That 
  first
  added line was not intended to be part of the patch:
 
  +/* vect_hw_misalign  { ! vect64 } */
 
  Please try removing that line and verify that the patch succeeds 
  again
  for ARM.  Assuming so, I'll prepare a patch to fix this.
 
  It looks like this mistake was introduced only in this particular 
  test,
  but please let me know if you see any other anomalies.
 Hi Bill,
 I chased the wrong branch.  The test disappeared on fsf-48 branch in
 out build, rather than trunk.  I guess it's not your patch's fault.
 Will follow up and get back to you later.
 Sorry for the inconvenience.

OK, thanks for letting me know!  There was still a bad line in this
patch, although it was only introduced in 5.1 and trunk, so I guess that
wasn't responsible in this case.  Thanks for checking!
   
   
   Hi Bill,
   
   In 4.8 branch, you have changed:
   
   -/* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
   vect } } */
   +/* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
   vect { target { ! vect_hw_misalign } } } } */
   
   Whereas your comment says:
   
  2015-04-24  Bill Schmidt  wschm...@linux.vnet.ibm.com
   
   Backport from mainline r222349
   2015-04-22  Bill Schmidt  wschm...@linux.vnet.ibm.com
   
   PR target/65456
   [...]
   * gcc.dg/vect/vect-33.c: Exclude unaligned access test for
   POWER8.
   [...]
   
   There wasn't an unaligned access test in the first place. But if you 
   wanted to
   introduce it and exclude it for POWER8 then it should've been:
   
...   { { ! powerpc*-*-* }  vect_hw_misalign } ...
   
   like you have done for the trunk. At the moment, this change has made the 
   test
   to be skipped for AArch64. It should've been skipped for x86_64-*-* and 
   i*86-*-*
   as well.
   
   I believe it wasn't intended to be skipped so?
  
  Right, wasn't intended to be skipped.  This test changed substantially
  between 4.8 and 4.9, so when I did the backport I tried (and failed) to
  adjust it properly.
  
  Because the sense of the test has been reversed, I believe the correct
  change is
  
  /* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
  vect { target { { ! powerpc*-*-* } || { ! vect_hw_misalign } } } } } */
 
 Makes sense. If I understand it right, it shouldn't vectorize for targets
 (except powerpc) that support vector misalign access?

It shouldn't vectorize for targets other than powerpc, period
(originally the test was, don't vectorize for absolutely anybody).  This
will now allow vectorization only for powerpc targets for which
vect_hw_misalign is true (POWER8 only at this time).  The cost function
in that case allows us to vectorize it.

However, I may not get approval to 

Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Martin Liška
On 06/16/2015 03:17 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 11:26 AM, Martin Liška mli...@suse.cz wrote:
 On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T* 
 pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
 ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void* 
 cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 provided

 #include new


 Hi.

 new header file is not missing (explicit addition of the file does not 
 help).
 Feel free to play with following patch which should fix cselib.h compilation 
 error.
 
 cselib_val overrides the new operator but fails to provide an overload
 for the placement new
 form.  Fix that and it should work (of course it gets quite awkward
 with its 'new' calling
 pool.allocate and its placement new doing value-construction then...)
 
 Richard.

Do you mean Richard following changes:

alloc-pool.h (allocate):
...
+  /* Placement new contructor.  */
+  inline void *operator new (size_t, elt_loc_list *ptr)
+  {
+return ptr;
+  }

and e.g. cselib.h:

struct cselib_val
{
  /* Pool allocation new operator.  */
  inline void *operator new (size_t)
  {
return pool.allocate ();
  }

  /* Placement new contructor.  */
  inline void *operator new (size_t, char *ptr)
  {
return ptr;
  }
}

Thanks,
Martin



 
 Thanks,
 Martin



Re: [PATCH, rs6000, testsuite, PR65456] Changes for unaligned vector load/store support on POWER8

2015-06-16 Thread Vidya Praveen
On Mon, Jun 15, 2015 at 08:14:31PM +0100, Bill Schmidt wrote:
 On Fri, 2015-06-12 at 17:36 +0100, Vidya Praveen wrote:
  On Thu, Apr 30, 2015 at 01:34:18PM +0100, Bill Schmidt wrote:
   On Thu, 2015-04-30 at 18:26 +0800, Bin.Cheng wrote:
On Mon, Apr 27, 2015 at 9:26 PM, Bill Schmidt
wschm...@linux.vnet.ibm.com wrote:
 On Mon, 2015-04-27 at 14:23 +0800, Bin.Cheng wrote:
 On Mon, Mar 30, 2015 at 1:42 AM, Bill Schmidt
 wschm...@linux.vnet.ibm.com wrote:


  Index: gcc/testsuite/gcc.dg/vect/vect-33.c
  ===
  --- gcc/testsuite/gcc.dg/vect/vect-33.c (revision 221118)
  +++ gcc/testsuite/gcc.dg/vect/vect-33.c (working copy)
  @@ -36,9 +36,10 @@ int main (void)
 return main1 ();
   }
 
  +/* vect_hw_misalign  { ! vect64 } */
 
   /* { dg-final { scan-tree-dump-times vectorized 1 loops 1 
  vect  } } */
  -/* { dg-final { scan-tree-dump Vectorizing an unaligned access 
  vect { target { vect_hw_misalign  { {! vect64} || 
  vect_multiple_sizes } } } } } */
  +/* { dg-final { scan-tree-dump Vectorizing an unaligned access 
  vect { target { { { ! powerpc*-*-* }  vect_hw_misalign }  { 
  { ! vect64 } || vect_multiple_sizes } } } } }  */
   /* { dg-final { scan-tree-dump Alignment of access forced using 
  peeling vect { target { vector_alignment_reachable  { vect64 
   {! vect_multiple_sizes} } } } } } */
   /* { dg-final { scan-tree-dump-times Alignment of access forced 
  using versioning 1 vect { target { { {! 
  vector_alignment_reachable} || {! vect64} }  {! 
  vect_hw_misalign} } } } } */
   /* { dg-final { cleanup-tree-dump vect } } */

 Hi Bill,
 With this change, the test case is skipped on aarch64 now.  Since it
 passed before, Is it expected to act like this on 64bit platforms?

 Hi Bin,

 No, that's a mistake on my part -- thanks for the report!  That first
 added line was not intended to be part of the patch:

 +/* vect_hw_misalign  { ! vect64 } */

 Please try removing that line and verify that the patch succeeds again
 for ARM.  Assuming so, I'll prepare a patch to fix this.

 It looks like this mistake was introduced only in this particular 
 test,
 but please let me know if you see any other anomalies.
Hi Bill,
I chased the wrong branch.  The test disappeared on fsf-48 branch in
out build, rather than trunk.  I guess it's not your patch's fault.
Will follow up and get back to you later.
Sorry for the inconvenience.
   
   OK, thanks for letting me know!  There was still a bad line in this
   patch, although it was only introduced in 5.1 and trunk, so I guess that
   wasn't responsible in this case.  Thanks for checking!
  
  
  Hi Bill,
  
  In 4.8 branch, you have changed:
  
  -/* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
  vect } } */
  +/* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
  vect { target { ! vect_hw_misalign } } } } */
  
  Whereas your comment says:
  
 2015-04-24  Bill Schmidt  wschm...@linux.vnet.ibm.com
  
  Backport from mainline r222349
  2015-04-22  Bill Schmidt  wschm...@linux.vnet.ibm.com
  
  PR target/65456
  [...]
  * gcc.dg/vect/vect-33.c: Exclude unaligned access test for
  POWER8.
  [...]
  
  There wasn't an unaligned access test in the first place. But if you wanted 
  to
  introduce it and exclude it for POWER8 then it should've been:
  
   ...   { { ! powerpc*-*-* }  vect_hw_misalign } ...
  
  like you have done for the trunk. At the moment, this change has made the 
  test
  to be skipped for AArch64. It should've been skipped for x86_64-*-* and 
  i*86-*-*
  as well.
  
  I believe it wasn't intended to be skipped so?
 
 Right, wasn't intended to be skipped.  This test changed substantially
 between 4.8 and 4.9, so when I did the backport I tried (and failed) to
 adjust it properly.
 
 Because the sense of the test has been reversed, I believe the correct
 change is
 
 /* { dg-final { scan-tree-dump-times Vectorizing an unaligned access 0 
 vect { target { { ! powerpc*-*-* } || { ! vect_hw_misalign } } } } } */

Makes sense. If I understand it right, it shouldn't vectorize for targets
(except powerpc) that support vector misalign access?

Regards
VP.






 
 I'll give that a quick test.
 
 Bill
 
  
  Regards
  VP.
  
  
  
  
  
   
   Bill
   

Thanks,
bin

 Thanks very much!

 Bill

 PASS-NA: gcc.dg/vect/vect-33.c -flto -ffat-lto-objects
 scan-tree-dump-times vect Vectorizing an unaligned access 0
 PASS-NA: gcc.dg/vect/vect-33.c scan-tree-dump-times vect 
 Vectorizing
 an unaligned access 0

 Thanks,
 bin




   
   
  
 
 



Re: Drop TYPE_NEEDS_CONSTRUCTING checks from ipa-pure-const and tree-inline

2015-06-16 Thread Richard Biener
On Mon, 15 Jun 2015, Jan Hubicka wrote:

 Hi,
 this patch removes last two remaining uses of TYPE_NEEDS_CONSTRUCTING
 in the back-end.  I believe those are remainders from the time we did not
 gimplify as much as we do now. Alias analysis machinery already skips
 checks of TYPE_NEEDS_CONSTRUCTING and thus we need to mark tree correctly
 as non-readonly if it is constructed.

I think it is relevant only for globals anyway, no?  Thus with
unit-at-a-time and global constructors built we should even see it
is not readonly.

 Incrementally I would like to remove TYPE_NEEDS_CONSTRUCTING streaming
 and clear it in free_lang_data.
 
 Bootstrapped/regtested ppc64le-linux, OK?

Ok.

Thanks,
Richard.

 Honza
 
   * ipa-pure-const.c (check_decl): Do not check TYPE_NEEDS_CONSTRUCTING.
   * tree-inline.c (setup_one_parameter): Likewise.
 Index: ipa-pure-const.c
 ===
 --- ipa-pure-const.c  (revision 224463)
 +++ ipa-pure-const.c  (working copy)
 @@ -335,7 +335,7 @@
if (DECL_EXTERNAL (t) || TREE_PUBLIC (t))
  {
/* Readonly reads are safe.  */
 -  if (TREE_READONLY (t)  !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (t)))
 +  if (TREE_READONLY (t))
   return; /* Read of a constant, do not change the function state.  */
else
   {
 Index: tree-inline.c
 ===
 --- tree-inline.c (revision 224463)
 +++ tree-inline.c (working copy)
 @@ -3151,18 +3151,6 @@
   automatically replaced by the VAR_DECL.  */
insert_decl_map (id, p, var);
  
 -  /* Even if P was TREE_READONLY, the new VAR should not be.
 - In the original code, we would have constructed a
 - temporary, and then the function body would have never
 - changed the value of P.  However, now, we will be
 - constructing VAR directly.  The constructor body may
 - change its value multiple times as it is being
 - constructed.  Therefore, it must not be TREE_READONLY;
 - the back-end assumes that TREE_READONLY variable is
 - assigned to only once.  */
 -  if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (p)))
 -TREE_READONLY (var) = 0;
 -
/* If there is no setup required and we are in SSA, take the easy route
   replacing all SSA names representing the function parameter by the
   SSA name passed to function.
 
 

-- 
Richard Biener rguent...@suse.de
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham 
Norton, HRB 21284 (AG Nuernberg)


Re: [PATCH, RFC] PR middle-end/55299, contract bitnot through ASR and rotations

2015-06-16 Thread Richard Biener
On Mon, Jun 15, 2015 at 12:14 PM, Mikhail Maltsev malts...@gmail.com wrote:
 Hi.

 The attached patch adds new match-and-simplify patterns, which fold
 ~((~a)  b) into (a  b) for arithmetic shifts (i.e. when A is signed)
 and perform similar folds for rotations. It also fixes PR
 tree-optimization/54579 (because we already fold (-a - 1) into ~a).

 A couple of questions:
 1. Should we limit folding to this special case or rather introduce some
 canonical order of bitnot and shifts (when they are commutative)? In the
 latter case, which order is better: bitnot as shift/rotate operand or
 vise-versa?

That's a good question.  Both positions can enable simplifications, either
of a containing or a contained expression.  So ideally when you have
operators that distribute you'd have to always check both forms...

 2. I noticed that some rotation patterns are folded on tree, while other
 are folded rather late (during second forward propagation). For example
 on LP64:

 #define INT_BITS  (sizeof (int) * 8)

 unsigned int
 rol(unsigned int a, unsigned int b)
 {
   return a  b | a  (INT_BITS - b);
 }

 INT_BITS has type unsigned long, so b and (INT_BITS - b) have different
 types and tree folding fails (if I change int to long, everything is
 OK). Should this be addressed somehow?

probably.

 3. Do the new patterns require any special handling of nop-conversions?

In theory you can handle ~(unsigned)((singed)(~x)  n), so yes.  Same
for rotates.  Canonicalization of ~ vs. a sign-changing conversion may
fix this as well, with the same caveats as any such canonicalizations
(see above).

Thanks,
Richard.


 --
 Regards,
 Mikhail Maltsev


Re: [PATCH, ARM] PR target/66541

2015-06-16 Thread Ramana Radhakrishnan
On Tue, Jun 16, 2015 at 1:35 PM, Christian Bruel christian.br...@st.com wrote:
 Hi,

 This fixes the torture/pr52429.c regression due to arm_set_current_function
 that needs to handle DECL_FUNCTION_SPECIFIC_TARGET when set to
 target_option_default_node.

 Catch up with x86 and rs6000 backends.

 no regression with arm-none-eabi. Manual cc1 tests of failing cases (no
 pthreads.a with this configuration).
 No new added tests since the failure is exhibited with regressions

 tests for arm-cortex-linux-gnueabi ongoing for those requiring -lpthreads

 OK for trunk ?

OK if no regression and if (no regression with -mflip-thumb).

Please also mark the Changelog entry with the PR for the original
arm/thumb work.


Thanks,
Ramana



 Many Thanks

 Christian




Re: [Patch ARM-AArch64/testsuite Neon intrinsics 00/20] Executable tests

2015-06-16 Thread Christophe Lyon
On 16 June 2015 at 12:08, James Greenhalgh james.greenha...@arm.com wrote:
 On Mon, Jun 15, 2015 at 11:11:16PM +0100, Christophe Lyon wrote:
 Ping?


 On 27 May 2015 at 22:15, Christophe Lyon christophe.l...@linaro.org wrote:
  This patch series is a follow-up to the tests I already contributed,
  converted from my original testsuite.
 
  This series consists in 20 new patches, which can be committed
  independently. For vrecpe, I added the setting of the Flush-to-Zero
  FP flag, to force AArch64 to behave the same as ARM by default.
 
  This is the final batch, except for the vget_lane tests which I will
  submit later. This should cover the subset of AdvSIMD intrinsics
  common to ARMv7 and AArch64.
 
  Tested with qemu on arm*linux, aarch64-linux.
 
  2015-05-27  Christophe Lyon  christophe.l...@linaro.org
 
  * gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h
  (_ARM_FPSCR): Add FZ field.
  (clean_results): Force FZ=1 on AArch64.
  * gcc.target/aarch64/advsimd-intrinsics/vrecpe.c: New file.
  * gcc.target/aarch64/advsimd-intrinsics/vrecps.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vreinterpret.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrev.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrshl.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrshr_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrshrn_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrsqrte.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrsqrts.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vrsra_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vset_lane.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vshl_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vshll_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vshr_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vshrn_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vsra_n.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vst1_lane.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vstX_lane.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vtbX.c: Likewise.
  * gcc.target/aarch64/advsimd-intrinsics/vtst.c: Likewise.
 

 This patch set is OK.

 As with the last patch set, please do a quick run through of each patch
 before committing and ensure that the trailing '\' characters line up,
 and look for any fall-out (particularly on aarch64_be) after these are in.


I've just re-run the tests on aarch64_be, and the vtbX one is failing
when testing vtlb3.
It does pass on armeb, so I expect the test to be correctly written to
be endianness independant.

As a reminder, there are still several other tests failing on aarch64_be:
vldX_lane
vtrn
vzip
vuzp

we have PR63652 and 63653 for these.

 Thanks,
 James



Re: [patch 6/6] scalar-storage-order merge: testsuite

2015-06-16 Thread Richard Earnshaw
On 16/06/15 10:52, Eric Botcazou wrote:
 This is the testsuite part.
 
 testsuite/
   * c-c++-common/sso-1.c: New test.
   * c-c++-common/sso: New directory.
   * gcc.dg/sso-1.c: New test.
   * g++.dg/sso-1.C: Likewise.
   * gcc.dg/sso: New directory.
   * g++.dg/sso: Likewise.
   * gnat.dg/sso1.adb: New test.
   * gnat.dg/sso2.ad[sb]: Likewise.
   * gnat.dg/sso3.adb: Likewise.
   * gnat.dg/sso4.adb: Likewise.
   * gnat.dg/sso5.adb: Likewise.
   * gnat.dg/sso6.adb: Likewise.
   * gnat.dg/sso7.adb: Likewise.
   * gnat.dg/specs/sso1.ads: Likewise.
   * gnat.dg/specs/sso2.ads: Likewise.
   * gnat.dg/sso: New directory.
 

It appears that all the C tests check the specific syntactic form
'struct __attr_sso__ foo {...};'

What is the impact of changing the location of __attr_sso__?  Eg:

struct foo {...} __attr_sso__;

(Note that alignment attributes can have significant impact depending on
where in the syntax the attribute is placed (I'm expecting this will be
true here as well).

What about with typedefs?

Can I apply the attribute to a previously laid out struct?

Can I apply it to individual fields in the struct, eg:

struct bar
{
int a;
int __attr_sso__ b;
};

Can I modify an existing struct to create an opposite endian variant? Eg.

struct bar
{
int a;
};

struct wibble
{
struct __attr_sso__ bar a;
};

Assuming mixed fields in a struct are possible, can it be applied to
individual bitfields?  What is the impact on mixing big and little
endian bitfields in the same structure.

R.


[PATCH] Alternate fix for PR66251

2015-06-16 Thread Richard Biener

The following reverts the previous bogus fixes and instead fixes
strided store support to properly get at SLP operands.  It also
fixes a typo and exchanges i == i for i == 0.

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

Richard.

2015-06-16  Richard Biener  rguent...@suse.de

PR tree-optimization/66251
* tree-vect-stmts.c (vectorizable_store): Fix gathering of vectorized
stmts for SLP strided stores.

* gfortran.fortran-torture/compile/pr66251-2.f90: New testcase.

Revert
2015-05-22  Richard Biener  rguent...@suse.de

PR tree-optimization/66251
* tree-vect-stmts.c (vectorizable_conversion): Properly
set STMT_VINFO_VEC_STMT even for the SLP case.

2015-05-26  Michael Matz  m...@suse.de

PR middle-end/66251
* tree-vect-stmts.c (vect_create_vectorized_demotion_stmts): Always set
STMT_VINFO_VEC_STMT, also with SLP.

Index: gcc/testsuite/gfortran.fortran-torture/compile/pr66251-2.f90
===
--- gcc/testsuite/gfortran.fortran-torture/compile/pr66251-2.f90
(revision 0)
+++ gcc/testsuite/gfortran.fortran-torture/compile/pr66251-2.f90
(working copy)
@@ -0,0 +1,23 @@
+subroutine mv(m,nc,irp,ja,val,x,ldx,y,ldy,acc)
+  use iso_fortran_env
+  implicit none 
+
+  integer, parameter  :: ipk_ = int32
+  integer, parameter  :: spk_   = real32
+  complex(spk_), parameter   :: czero=(0.0_spk_,0.0_spk_)
+
+  integer(ipk_), intent(in)  :: m,ldx,ldy,nc,irp(*),ja(*)
+  complex(spk_), intent(in)  :: x(ldx,*),val(*)
+  complex(spk_), intent(inout)   :: y(ldy,*)
+  complex(spk_), intent(inout)   :: acc(*)
+  integer(ipk_) :: i,j,k, ir, jc
+
+  do i=1,m 
+acc(1:nc)  = czero
+do j=irp(i), irp(i+1)-1
+  acc(1:nc)  = acc(1:nc) + val(j) * x(ja(j),1:nc)  
+enddo
+y(i,1:nc) = -acc(1:nc)
+  end do
+  
+end subroutine mv
Index: gcc/tree-vect-stmts.c
===
--- gcc/tree-vect-stmts.c   (revision 224514)
+++ gcc/tree-vect-stmts.c   (working copy)
@@ -3370,13 +3370,15 @@ vect_create_vectorized_demotion_stmts (v
 (or in STMT_VINFO_RELATED_STMT chain).  */
  if (slp_node)
SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
-
- if (!*prev_stmt_info)
-   STMT_VINFO_VEC_STMT (stmt_info) = new_stmt;
  else
-   STMT_VINFO_RELATED_STMT (*prev_stmt_info) = new_stmt;
+   {
+ if (!*prev_stmt_info)
+   STMT_VINFO_VEC_STMT (stmt_info) = new_stmt;
+ else
+   STMT_VINFO_RELATED_STMT (*prev_stmt_info) = new_stmt;
 
- *prev_stmt_info = vinfo_for_stmt (new_stmt);
+ *prev_stmt_info = vinfo_for_stmt (new_stmt);
+   }
}
 }
 
@@ -3955,12 +3957,14 @@ vectorizable_conversion (gimple stmt, gi
 
  if (slp_node)
SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
-
- if (!prev_stmt_info)
-   STMT_VINFO_VEC_STMT (stmt_info) = new_stmt;
  else
-   STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt;
- prev_stmt_info = vinfo_for_stmt (new_stmt);
+   {
+ if (!prev_stmt_info)
+   STMT_VINFO_VEC_STMT (stmt_info) = new_stmt;
+ else
+   STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt;
+ prev_stmt_info = vinfo_for_stmt (new_stmt);
+   }
}
}
 
@@ -5327,9 +5331,23 @@ vectorizable_store (gimple stmt, gimple_
  /* We've set op and dt above, from gimple_assign_rhs1(stmt),
 and first_stmt == stmt.  */
  if (j == 0)
-   vec_oprnd = vect_get_vec_def_for_operand (op, first_stmt, NULL);
+   {
+ if (slp)
+   {
+ vect_get_vec_defs (op, NULL_TREE, stmt, vec_oprnds, NULL,
+slp_node, -1);
+ vec_oprnd = vec_oprnds[0];
+   }
+ else
+   vec_oprnd = vect_get_vec_def_for_operand (op, first_stmt, NULL);
+   }
  else
-   vec_oprnd = vect_get_vec_def_for_stmt_copy (dt, vec_oprnd);
+   {
+ if (slp)
+   vec_oprnd = vec_oprnds[j];
+ else
+   vec_oprnd = vect_get_vec_def_for_stmt_copy (dt, vec_oprnd);
+   }
 
  for (i = 0; i  nstores; i++)
{
@@ -5359,7 +5377,7 @@ vectorizable_store (gimple stmt, gimple_
  vect_finish_stmt_generation (stmt, incr, gsi);
 
  running_off = newoff;
- if (j == 0  i == i)
+ if (j == 0  i == 0)
STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = assign;
  else
STMT_VINFO_RELATED_STMT (prev_stmt_info) = assign;


Re: [PATCH 1/2] Memory statistics enhancement.

2015-06-16 Thread Martin Liška
On 06/08/2015 05:01 PM, Martin Liška wrote:
 On 06/01/2015 06:16 PM, mliska wrote:
 Hi.

 Following 2 patches improve memory statistics infrastructure. First one
 ports pool allocator to the new infrastructure. And the second one makes
 column alignment properly.

 Both can bootstrap on x86_64-linux-pc and survive regression tests.

 Ready for trunk?
 Thank you,
 Martin

 Port pool-allocator memory stats to a new infrastructure.

 gcc/ChangeLog:

 2015-06-02  Martin Liska  mli...@suse.cz

  * alloc-pool.c (allocate_pool_descriptor): Remove.
  (struct pool_output_info): Likewise.
  (print_alloc_pool_statistics): Likewise.
  (dump_alloc_pool_statistics): Likewise.
  * alloc-pool.h (struct pool_usage): New struct.
  (pool_allocator::initialize): Change usage of memory statistics
  to a new interface.
  (pool_allocator::release): Likewise.
  (pool_allocator::allocate): Likewise.
  (pool_allocator::remove): Likewise.
  * mem-stats-traits.h (enum mem_alloc_origin): Add new enum value
  for a pool allocator.
  * mem-stats.h (struct mem_location): Add new ctor.
  (struct mem_usage): Add counter for number of
  instances.
  (mem_alloc_description::register_descriptor): New overload of
  the function.
 ---
  gcc/alloc-pool.c   |  60 +
  gcc/alloc-pool.h   | 102 
 +++--
  gcc/mem-stats-traits.h |   3 +-
  gcc/mem-stats.h|  69 ++---
  4 files changed, 132 insertions(+), 102 deletions(-)

 diff --git a/gcc/alloc-pool.c b/gcc/alloc-pool.c
 index e9fdc86..601c2b7 100644
 --- a/gcc/alloc-pool.c
 +++ b/gcc/alloc-pool.c
 @@ -26,70 +26,14 @@ along with GCC; see the file COPYING3.  If not see
  #include hash-map.h
  
  ALLOC_POOL_ID_TYPE last_id;
 -
 -/* Hashtable mapping alloc_pool names to descriptors.  */
 -hash_mapconst char *, alloc_pool_descriptor *alloc_pool_hash;
 -
 -struct alloc_pool_descriptor *
 -allocate_pool_descriptor (const char *name)
 -{
 -  if (!alloc_pool_hash)
 -alloc_pool_hash = new hash_mapconst char *, alloc_pool_descriptor (10,
 - false,
 - false);
 -
 -  return alloc_pool_hash-get_or_insert (name);
 -}
 -
 -/* Output per-alloc_pool statistics.  */
 -
 -/* Used to accumulate statistics about alloc_pool sizes.  */
 -struct pool_output_info
 -{
 -  unsigned long total_created;
 -  unsigned long total_allocated;
 -};
 -
 -/* Called via hash_map.traverse.  Output alloc_pool descriptor pointed out 
 by
 -   SLOT and update statistics.  */
 -bool
 -print_alloc_pool_statistics (const char *const name,
 - const alloc_pool_descriptor d,
 - struct pool_output_info *i)
 -{
 -  if (d.allocated)
 -{
 -  fprintf (stderr,
 -   %-22s %6d %10lu %10lu(%10lu) %10lu(%10lu) %10lu(%10lu)\n,
 -   name, d.elt_size, d.created, d.allocated,
 -   d.allocated / d.elt_size, d.peak, d.peak / d.elt_size,
 -   d.current, d.current / d.elt_size);
 -  i-total_allocated += d.allocated;
 -  i-total_created += d.created;
 -}
 -  return 1;
 -}
 +mem_alloc_descriptionpool_usage pool_allocator_usage;
  
  /* Output per-alloc_pool memory usage statistics.  */
  void
  dump_alloc_pool_statistics (void)
  {
 -  struct pool_output_info info;
 -
if (! GATHER_STATISTICS)
  return;
  
 -  if (!alloc_pool_hash)
 -return;
 -
 -  fprintf (stderr, \nAlloc-pool Kind Elt size  Pools  Allocated 
 (elts)Peak (elts)Leak (elts)\n);
 -  fprintf (stderr, 
 --\n);
 -  info.total_created = 0;
 -  info.total_allocated = 0;
 -  alloc_pool_hash-traverse struct pool_output_info *,
 - print_alloc_pool_statistics (info);
 -  fprintf (stderr, 
 --\n);
 -  fprintf (stderr, %-22s   %7lu %10lu\n,
 -   Total, info.total_created, info.total_allocated);
 -  fprintf (stderr, 
 --\n);
 +  pool_allocator_usage.dump (ALLOC_POOL);
  }
 diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
 index 96a1342..a1727ce 100644
 --- a/gcc/alloc-pool.h
 +++ b/gcc/alloc-pool.h
 @@ -26,6 +26,71 @@ extern void dump_alloc_pool_statistics (void);
  
  typedef unsigned long ALLOC_POOL_ID_TYPE;
  
 +/* Pool allocator memory usage.  */
 +struct pool_usage: public mem_usage
 +{
 +  /* Default contructor.  */
 +  pool_usage (): m_element_size (0), m_pool_name () {}
 +  /* Constructor.  */
 +  pool_usage (size_t allocated, size_t times, size_t peak,
 +  size_t instances, size_t 

Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd

2015-06-16 Thread Maciej W. Rozycki
On Tue, 16 Jun 2015, Joseph Myers wrote:

   Furthermore these checks were deliberately introduced by Richard with his 
  proposal here http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00682.html 
  and agreed upon in the discussion even before IEEE Std 754-2008 has been 
  made.  Are you suggesting that the arguments used there, that have led to 
  the current arrangement, no longer stand and consequently the HONOR_NANS 
  checks introduced are now best dropped?
 
 Only the checks for abs and neg patterns are necessary, not those for 
 fused operations.

 And neither for the unfused combined operations we handle for some MIPS 
processors that implement them presumably?

 In that case I think the HONOR_NANS checks will best be globally removed 
first (where applicable of course), with a separate preparatory change.

  Maciej


Re: match.pd: Three new patterns

2015-06-16 Thread Richard Biener
On Sat, 13 Jun 2015, Marc Glisse wrote:

 They look fine to me.
 
  +/* (x  y) + (x ^ y) - x | y */
 
 This also works if you replace + with | or ^.

  +/* (x | y) - (x ^ y) - x  y */
 
 For symmetry, you probably also want:
 (x | y) - (x  y) - x ^ y
 
 (they both also work with ^ instead of -)

We already have

/* (x  y) ^ (x | y) - x ^ y */
(simplify
 (bit_xor:c (bit_and @0 @1) (bit_ior @0 @1))
 (bit_xor @0 @1))

but of course with minus it doesn't commutate so it's hard to
merge.

  +/* (x  y) + (x | y) - x + y */
 
 Again for symmetry, it seems like this comes with
 x + y - (x | y) - x  y
 x + y - (x  y) - x | y
 which seem fine when overflow is undefined or wraps, but not if for instance
 it saturates.

Can you adjust according to Marcs comment and re-submit?  If you like
you can do it as followup as well and thus the original patch is ok
as well.

Thanks,
Richard.


Re: [PATCH] Enable two UNSIGNED_FLOAT simplifications in simplify_unary_operation_1

2015-06-16 Thread Christophe Lyon
On 20 March 2015 at 18:03, Renlin Li renlin...@arm.com wrote:
 Hi all,

 This is a simple patch to enable two simplifications for UNSIGNED_FLOAT
 expression.

 For the following rtx patterns, they can be simplified when the integer x
 can be
 represented in float mode without precision loss:

 float_truncate (float x) -- float x
 float_extend (float x) -- float x

 Those two simplifications are also applicable to UNSIGNED_FLOAT expression.

 For example, compile the following code using aarch64-none-elf toolchain
 with -O1 flag.
 double
 f1 (uint16_t x)
 {
   return (double)(float)x;
 }
 Before the change, the compiler generates the following code:
 f1:
 uxthw0, w0
 ucvtf   s0, w0
 fcvtd0, s0
 ret
 After the change, the following simplified asm code snipts are generated.
 f1:
 uxthw0, w0
 ucvtf   d0, w0
 ret


 aarch64-none-elf regression test runs Okay. x86_64 bootstraps Okay.
 Okay to commit?

 gcc/ChangeLog:

 2015-03-20  Renlin Li  renlin...@arm.com

 * simplify-rtx.c (simplify_unary_operation_1): Fix a typo. Enable two
 simplifications for UNSIGNED_FLOAT.

 gcc/testsuite/ChangeLog:

 2015-03-20  Renlin Li  renlin...@arm.com

 * gcc.target/aarch64/unsigned-float.c: New.
 * gcc.target/arm/unsigned-float.c: New.

This new test fails on ARM targets defaulting to hard-float which have
no softfp multilib.
I'm not sure about the best way to fix this.

Note that dg-require-effective-target arm_vfp_ok passes, but the
testcase fails because it includes stdint.h, leading to:
sysroot-arm-none-linux-gnueabihf/usr/include/gnu/stubs.h:7:29: fatal
error: gnu/stubs-soft.h: No such file or directory

Christophe.


Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Richard Biener
On Tue, Jun 16, 2015 at 3:38 PM, Martin Liška mli...@suse.cz wrote:
 On 06/16/2015 03:17 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 11:26 AM, Martin Liška mli...@suse.cz wrote:
 On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T* 
 pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
 ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void* 
 cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 provided

 #include new


 Hi.

 new header file is not missing (explicit addition of the file does not 
 help).
 Feel free to play with following patch which should fix cselib.h 
 compilation error.

 cselib_val overrides the new operator but fails to provide an overload
 for the placement new
 form.  Fix that and it should work (of course it gets quite awkward
 with its 'new' calling
 pool.allocate and its placement new doing value-construction then...)

 Richard.

 Do you mean Richard following changes:

 alloc-pool.h (allocate):
 ...
 +  /* Placement new contructor.  */
 +  inline void *operator new (size_t, elt_loc_list *ptr)
 +  {
 +return ptr;
 +  }

That should be there with including new

 and e.g. cselib.h:

 struct cselib_val
 {
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
 return pool.allocate ();
   }

   /* Placement new contructor.  */
   inline void *operator new (size_t, char *ptr)
   {
 return ptr;
   }

Yes, though I wonder whether cselib_val should really have undefined
contents after
allocating it?  (or does the pool allocator zero the memory?)

Richard.

 }

 Thanks,
 Martin




 Thanks,
 Martin



Re: [PATCH] Altivec mulv4si3 and mulv8hi3 cleanup

2015-06-16 Thread Bill Schmidt
FWIW, this patch looks good to me.

Bill

On Mon, 2015-06-15 at 18:15 -0400, David Edelsohn wrote:
 POWER8 added a multiply instruction that makes mulv4si more efficient.
 And vmladduhm can be used for mulv8hi3.  This patch also changes
 vmladduhm from a black box UNSPEC to descriptive RTL.
 
 Bootstrapped on powerpc64le-linux.
 
 * altivec.md: Delete UNSPEC_VMLADDUHM.
 (mulv4si3_p8): New pattern.
 (mulv4si3): Use it for POWER8.
 (mulv8hi3): Use vmladduhm with zero addend.
 (altivec_vmladduhm): Descriptive RTL.
 
 - David




Re: [PATCH] Yet another simple fix to enhance outer-loop vectorization.

2015-06-16 Thread Yuri Rumyantsev
Thanks a lot Richard for your review.

I presented updated patch which is not gated by force_vectorize.
I added test on outer-loop in vect_enhance_data_refs_alignment
and it returns false for it because we can not improve dr alighment
through outer-loop peeling in general. So I assume that only
versioning for alignment can be applied for targets do not support
unaligned memory access.

I did not change tests for outer loops in slpeel_can_duplicate_loop_p
as you proposed since it is not called outside vectorization.

I also noticed one not-resolved issue with outer-loop peeling - we don't
consider remainder for possible vectorization of inner-loop as we can see
on the following example:

  for (i = 0; i  n; i++) {
diff = 0;
for (j = 0; j  M; j++) {
  diff += in[j+i]*coeff[j];
}
out[i] = diff;
  }

Is it worth to fix it?

2015-06-16  Yuri Rumyantsev  ysrum...@gmail.com

* tree-vect-loop-manip.c (rename_variables_in_bb): Add argument
to allow renaming of PHI arguments on edges incoming from outer
loop header, add corresponding check before start PHI iterator.
(slpeel_tree_duplicate_loop_to_edge_cfg): Introduce new bool
variable DUPLICATE_OUTER_LOOP and set it to true for outer loops
with true force_vectorize.  Set-up dominator for outer loop too.
Pass DUPLICATE_OUTER_LOOP as argument to rename_variables_in_bb.
(slpeel_can_duplicate_loop_p): Allow duplicate of outer loop if it
was marked with force_vectorize and has restricted cfg.
* tree-vect-data-refs.c (vector_alignment_reachable_p): Alignment can
not be reachable for outer loops.
(vect_enhance_data_refs_alignment): Add test on true value of
do_peeling.

gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-outer-simd-2.c: New test.

2015-06-09 16:26 GMT+03:00 Richard Biener richard.guent...@gmail.com:
 On Mon, Jun 8, 2015 at 12:27 PM, Yuri Rumyantsev ysrum...@gmail.com wrote:
 Hi All,

 Here is a simple fix which allows duplication of outer loops to
 perform peeling for number of iterations if outer loop is marked with
 pragma omp simd.

 Bootstrap and regression testing did not show any new failures.
 Is it OK for trunk?

 Hmm, I don't remember needing to adjust rename_variables_in_bb
 when teaching loop distibution to call slpeel_tree_duplicate_to_edge_cfg
 on non-innermost loops...  (I just copied, I never called
 slpeel_can_duplicate_loop_p though).

 So - you should just remove the loop-inner condition from
 slpeel_can_duplicate_loop_p as it is used by non-vectorizer
 code as well (yeah, I never merged the nested loop support
 for loop distribution...).

 Index: tree-vect-loop.c
 ===
 --- tree-vect-loop.c(revision 224100)
 +++ tree-vect-loop.c(working copy)
 @@ -1879,6 +1879,10 @@
return false;
  }

 +  /* Peeling for alignment is not supported for outer-loop vectorization.  */
 +  if (LOOP_VINFO_LOOP (loop_vinfo)-inner)
 +LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) = 0;

 I think you can't simply do this - if vect_enhance_data_refs_alignment
 decided to peel for alignment then it has adjusted the DRs alignment
 info already.  So instead of the above simply disallow peeling for
 alignment in vect_enhance_data_refs_alignment?  Thus add
 || -inner to

   /* Check if we can possibly peel the loop.  */
   if (!vect_can_advance_ivs_p (loop_vinfo)
   || !slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
 do_peeling = false;

 ?

 I also can't see why the improvement has to be gated on force_vect,
 it surely looks profitable to enable more outer loop vectorization in
 general, no?

 How do the cost model calculations end up with peeling the outer loop
 for niter?

 On targets which don't support unaligned accesses we're left with
 versioning for alignment.  Isn't peeling for alignment better there?
 Thus only disallow peeling for alignment if there is no unhandled
 alignment?

 Thanks,
 Richard.

 ChangeLog:

 2015-06-08  Yuri Rumyantsev  ysrum...@gmail.com

 * tree-vect-loop-manip.c (rename_variables_in_bb): Add argument
 to allow renaming of PHI arguments on edges incoming from outer
 loop header, add corresponding check before start PHI iterator.
 (slpeel_tree_duplicate_loop_to_edge_cfg): Introduce new bool
 variable DUPLICATE_OUTER_LOOP and set it to true for outer loops
 with true force_vectorize.  Set-up dominator for outer loop too.
 Pass DUPLICATE_OUTER_LOOP as argument to rename_variables_in_bb.
 (slpeel_can_duplicate_loop_p): Allow duplicate of outer loop if it
 was marked with force_vectorize and has restricted cfg.
 * tre-vect-loop.c (vect_analyze_loop_2): Prohibit alignment peeling
 for outer loops.

 gcc/testsuite/ChangeLog:
 * gcc.dg/vect/vect-outer-simd-2.c: New test.


patch.1.2
Description: Binary data


Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd

2015-06-16 Thread Maciej W. Rozycki
On Mon, 15 Jun 2015, Joseph Myers wrote:

   It is only required (well, recommended) to pass the *payload*.  The sign 
   bit is not part of the payload.  For all other operations, this standard 
   does not specify the sign bit of a NaN result, even when there is only 
   one 
   input NaN, or when the NaN is produced from an invalid operation..
  
   However elsewhere: For an operation with quiet NaN inputs, other than 
  maximum and minimum operations, if a floating-point result is to be 
  delivered the result shall be a quiet NaN which should be one of the input 
  NaNs..
 
 See http://grouper.ieee.org/groups/754/email/msg03893.html: The intent 
 is that NaNs which differ only in the sign bit are considered equivalent 
 for the purposes of 6.2..

 Fair enough, thanks for the pointer.

 This makes me wonder however what the point has been to specify a strict 
particular semantics for the copy, negate, abs, copySign operations with 
respect to the sign bit of qNaN data where any other operation can then 
change the bit in a random fashion.  Do you happen to know what the 
rationale and any possible use cases considered have been?

 Furthermore these checks were deliberately introduced by Richard with his 
proposal here http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00682.html 
and agreed upon in the discussion even before IEEE Std 754-2008 has been 
made.  Are you suggesting that the arguments used there, that have led to 
the current arrangement, no longer stand and consequently the HONOR_NANS 
checks introduced are now best dropped?

  Maciej


Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd

2015-06-16 Thread Joseph Myers
On Tue, 16 Jun 2015, Maciej W. Rozycki wrote:

  This makes me wonder however what the point has been to specify a strict 
 particular semantics for the copy, negate, abs, copySign operations with 
 respect to the sign bit of qNaN data where any other operation can then 
 change the bit in a random fashion.  Do you happen to know what the 
 rationale and any possible use cases considered have been?

I don't know.

  Furthermore these checks were deliberately introduced by Richard with his 
 proposal here http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00682.html 
 and agreed upon in the discussion even before IEEE Std 754-2008 has been 
 made.  Are you suggesting that the arguments used there, that have led to 
 the current arrangement, no longer stand and consequently the HONOR_NANS 
 checks introduced are now best dropped?

Only the checks for abs and neg patterns are necessary, not those for 
fused operations.

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


Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Richard Biener
On Tue, Jun 16, 2015 at 11:26 AM, Martin Liška mli...@suse.cz wrote:
 On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T* 
 pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
 ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void* 
 cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 provided

 #include new


 Hi.

 new header file is not missing (explicit addition of the file does not 
 help).
 Feel free to play with following patch which should fix cselib.h compilation 
 error.

cselib_val overrides the new operator but fails to provide an overload
for the placement new
form.  Fix that and it should work (of course it gets quite awkward
with its 'new' calling
pool.allocate and its placement new doing value-construction then...)

Richard.

 Thanks,
 Martin


Re: match.pd: Optimize (x y) ^ (x | y)

2015-06-16 Thread Richard Biener
On Sat, 13 Jun 2015, Marc Glisse wrote:

 On Fri, 12 Jun 2015, Marek Polacek wrote:
 
 fold-const.c traditionally avoided the combinatorial explosion by
 using
 strip_nops.

Yeah.  We can probably special case conditional conversions in code
generation instead of lowering it.  And then go the full way and special
case nop conversions so you can avoid writing the predicate as well.
   
   Without special casing, I currently have:
   
   (match (nopcvt @0)
(convert? @0)
(if (tree_nop_conversion_p (type, TREE_TYPE (@0)
   (simplify
(bit_xor:c (convert1? (bit_and@2 (nopcvt @0) (nopcvt @1)))
   (convert2? (bit_ior:c (nopcvt @0) (nopcvt @1
(if (tree_nop_conversion_p (type, TREE_TYPE (@2)))
 
 This could use @0 instead of @2 to save 2 characters.
 
 (bit_xor (convert @0) (convert @1
   
   which simplifies Jakub's testcase without exploding the size of *-match.c,
   but it is still not very satisfying.
  
  Yeah, imagine if we'd have to change every pattern like that :-(.

Indeed.  I don't like adding that (match (nopcvt)).  We should improve
on the IL instead.

 I am not sure that we will be able to completely avoid it. Nop conversions can
 be ignored in some places, but not everywhere, so we have to be explicit about
 it. We could make a nice short notation, say bit_and# to switch whether there
 is an implicit strip_nops or not, and pick the default that applies to most
 patterns. We would still need a way to access the unstripped version of @2
 (@#2 maybe?). And we would still need the 'convert' in the output pattern,
 unless we teach genmatch to add nop conversions in many places, which sounds
 complicated.

Yeah, I also think we want to be explicit, which means adding both
the conditional nop-convert and the output convert.  What we can do
is invent new [s]nop (according to STRIP_NOPS / STRIP_SIGN_NOPS)
codes that when used conditional (not sure if we want to support
unconditional use?) always act like if you were using nop1, nop2, nop3, 
... but special-case it in code-generation to magically add
a tree_nop_conversion_p check (somewhere).

I think we can't easily remove the exponential explosion in the number
of nodes in the decision tree though (but for a single leaf op or by
outlining to a function which is the effect of your (match (nopcvt))
approach - though in the end I'd like to have those inlined)

Richard.


Re: [gomp4,bootstrap] Remove unused variable in lower_reduction_clauses

2015-06-16 Thread Tom de Vries

On 16/06/15 12:08, Tom de Vries wrote:

Committed this patch to fix bootstrap.



And this one.

Thanks,
- Tom

Declare parm unused in make_offloadable_1

2015-06-16  Tom de Vries  t...@codesourcery.com

	* varpool.c (make_offloadable_1): Declare decl with ATTRIBUTE_UNUSED.
---
 gcc/varpool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/varpool.c b/gcc/varpool.c
index 070d1c3..a6c8d1d 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -163,7 +163,7 @@ varpool_node::create_empty (void)
 }   
 
 static void
-make_offloadable_1 (varpool_node *node, tree decl)
+make_offloadable_1 (varpool_node *node, tree decl ATTRIBUTE_UNUSED)
 {
   node-offloadable = 1;
 #ifdef ENABLE_OFFLOADING
-- 
1.9.1



Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Martin Liška
On 06/16/2015 04:02 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 3:38 PM, Martin Liška mli...@suse.cz wrote:
 On 06/16/2015 03:17 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 11:26 AM, Martin Liška mli...@suse.cz wrote:
 On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T* 
 pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
 ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void* 
 cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 
 provided

 #include new


 Hi.

 new header file is not missing (explicit addition of the file does not 
 help).
 Feel free to play with following patch which should fix cselib.h 
 compilation error.

 cselib_val overrides the new operator but fails to provide an overload
 for the placement new
 form.  Fix that and it should work (of course it gets quite awkward
 with its 'new' calling
 pool.allocate and its placement new doing value-construction then...)

 Richard.

 Do you mean Richard following changes:

 alloc-pool.h (allocate):
 ...
 +  /* Placement new contructor.  */
 +  inline void *operator new (size_t, elt_loc_list *ptr)
 +  {
 +return ptr;
 +  }
 
 That should be there with including new
 
 and e.g. cselib.h:

 struct cselib_val
 {
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
 return pool.allocate ();
   }

   /* Placement new contructor.  */
   inline void *operator new (size_t, char *ptr)
   {
 return ptr;
   }
 
 Yes, though I wonder whether cselib_val should really have undefined
 contents after
 allocating it?  (or does the pool allocator zero the memory?)
 
 Richard.

Hio.

I've added calling of placement new operators and memset a memory, look the 
patch
works for me.

If it's the right way, I'll write Changelog and run testsuite.

Thanks,
Martin

 
 }

 Thanks,
 Martin




 Thanks,
 Martin


From d60bc8fa02161df64ddbb6bdb35c733af5e073c6 Mon Sep 17 00:00:00 2001
From: mliska mli...@suse.cz
Date: Tue, 16 Jun 2015 17:28:27 +0200
Subject: [PATCH] Add placement new for classes in pool allocator.

---
 gcc/alloc-pool.h   | 10 +-
 gcc/asan.c |  6 ++
 gcc/cselib.c   |  6 ++
 gcc/cselib.h   | 15 +++
 gcc/dse.c  | 30 ++
 gcc/et-forest.c|  6 ++
 gcc/et-forest.h|  8 
 gcc/ira-color.c|  6 ++
 gcc/lra-int.h  | 18 ++
 gcc/regcprop.c |  6 ++
 gcc/tree-sra.c | 12 
 gcc/var-tracking.c | 21 +
 12 files changed, 143 insertions(+), 1 deletion(-)

diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 1785df5..237ece3 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -413,7 +413,15 @@ pool_allocatorT::allocate ()
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
 
   /* Call default constructor.  */
-  return (T *)(header);
+  T *ptr = (T *)header;
+
+  if (!m_ignore_type_size)
+{
+  memset (header, 0, sizeof (T));
+  return new (ptr) T ();
+}
+  else
+return ptr;
 }
 
 /* Puts PTR back on POOL's free list.  */
diff --git a/gcc/asan.c b/gcc/asan.c
index 599c822..a6160f7 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -361,6 +361,12 @@ struct asan_mem_ref
   /* The size of the access.  */
   HOST_WIDE_INT access_size;
 
+  /* Placement new contructor.  */
+  inline void *operator new (size_t, asan_mem_ref *ptr)
+  {
+return ptr;
+  }
+
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
diff --git a/gcc/cselib.c b/gcc/cselib.c
index 7ccaab4..9873aa0 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -53,6 +53,12 @@ struct elt_list
   struct elt_list *next;
   cselib_val *elt;
 
+  /* Placement new contructor.  */
+  inline void *operator new (size_t, elt_list *ptr)
+  {
+return ptr;
+  }
+
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
diff --git a/gcc/cselib.h b/gcc/cselib.h
index cdd06ad..9ef95e3 100644
--- a/gcc/cselib.h
+++ b/gcc/cselib.h
@@ -48,6 +48,12 @@ struct cselib_val
 return pool.allocate ();
   }
 
+  /* Placement new contructor.  */
+  inline void *operator new (size_t, cselib_val *ptr)
+  {
+return ptr;
+  }
+
   /* Delete operator utilizing pool allocation.  */
   

[PING]Re: [PATCH]Use unsigned int instead of int to hold alignment in emit_local function.

2015-06-16 Thread Renlin Li

Ping~

Thank you!
Renlin Li

On 04/06/15 12:05, Renlin Li wrote:

Hi all,

This is a simple patch to change the align variable (used in 
emit_local()) from type int to type unsigned int.


It should be defined as unsigned int which is the same data type 
returned by symtab_node::get (decl)-definition_alignment ()
For the maximum alignment allowed by GCC(without producing error: 
requested alignment is too large), int will overflow.


Okay to Commit on the trunk and backport to branch 5.0?

Regards,
Renlin Li

gcc/ChangeLog:

2015-06-04  Renlin Li  renlin...@arm.com

* varasm.c (emit_local): Use unsigned int for align variable.




[PATCH, testsuite]: Fix PR 65944, FAIL: g++.dg/lto/pr65276: undefined reference to std2::exception::~exception()

2015-06-16 Thread Uros Bizjak
Hello!

Following patch fixes:

cp_lto_pr65276_1.o: In function `std2::runtime_error::~runtime_error()':^M
pr65276_1.C:(.text._ZN4std213runtime_errorD2Ev[_ZN4std213runtime_errorD5Ev]+0x8):
undefined reference to `std2::exception::~exception()'^M
cp_lto_pr65276_1.o: In function `std2::runtime_error::~runtime_error()':^M
pr65276_1.C:(.text._ZN4std213runtime_errorD0Ev[_ZN4std213runtime_errorD5Ev]+0xc):
undefined reference to `std2::exception::~exception()'^M
cp_lto_pr65276_1.o:(.rodata._ZTVN4std29exceptionE[_ZTVN4std29exceptionE]+0x10):
undefined reference to `std2::exception::~exception()'^M
cp_lto_pr65276_1.o:(.rodata._ZTVN4std29exceptionE[_ZTVN4std29exceptionE]+0x18):
undefined reference to `std2::exception::~exception()'^M
collect2: error: ld returned 1 exit status^M

link error with g++.dg/lto/pr65276 testcase.

2015-06-16  Uros Bizjak  ubiz...@gmail.com

PR testsuite/65944
* g++.dg/lto/pr65276_0.C: Add std2::exception::~exception() function.

Tested on x86_64-linux-gnu CentOS 5.11 (where linking failed) and
Fedora 22 (where linking didn't fail).

OK for mainline and gcc-5 branch?

Uros.

Index: g++.dg/lto/pr65276_0.C
===
--- g++.dg/lto/pr65276_0.C  (revision 224475)
+++ g++.dg/lto/pr65276_0.C  (working copy)
@@ -59,3 +59,5 @@
   };
   static ios_base::Init __ioinit;
 }
+
+std2::exception::~exception() noexcept { }


[PATCH, i386]: Fix PR 56766, generate ADDSUB insns

2015-06-16 Thread Uros Bizjak
Hello!

Attached patch implements missing (vec_select (vec_concat ...)) forms
of ADDSUB insn.

The core of the problem is with the fact, that we are able to expand
DFmode vectors with a shuffle pattern, which is not the case with
SFmode vectors (shuffle has certain limitations on x86). SFmode
vectors were expanded using blend pattern, and existing forms of
ADDSUB patterns were written to combine plus and minus RTXes with
blend pattern.

The new patterns are able to emit addsub for both following tests:

typedef double v4df __attribute__((vector_size(32)));
typedef long long v4di __attribute__((vector_size(32)));
v4df foo_v4df (v4df x, v4df y)
{
  v4df tem0 = x - y;
  v4df tem1 = x + y;
  return __builtin_shuffle (tem0, tem1, (v4di) { 0, 5, 2, 7 });
}

v4df bar_v4df (v4df x, v4df y)
{
  v4df tem0 = x + y;
  v4df tem1 = x - y;
  return __builtin_shuffle (tem0, tem1, (v4di) { 4, 1, 6, 3 });
}

However, existing shuffle patterns fail for the second case of
otherwise functionally identical testcases:

typedef float v4sf __attribute__((vector_size(16)));
typedef int v4si __attribute__((vector_size(16)));
v4sf foo_v4sf (v4sf x, v4sf y)
{
  v4sf tem0 = x - y;
  v4sf tem1 = x + y;
  return __builtin_shuffle (tem0, tem1, (v4si) { 0, 5, 2, 7 });
}

v4sf bar_v4sf (v4sf x, v4sf y)
{
  v4sf tem0 = x + y;
  v4sf tem1 = x - y;
  return __builtin_shuffle (tem0, tem1, (v4si) { 4, 1, 6, 3 });
}

due to the missing:

(set (reg:V4SF 93 [ D.2159 ])
   (vec_merge:V4SF (minus:V4SF (reg/v:V4SF 91 [ x ])
   (reg/v:V4SF 92 [ y ]))
   (plus:V4SF (reg/v:V4SF 91 [ x ])
   (reg/v:V4SF 92 [ y ]))
   (const_int 5 [0x5])))

(I'll open a PR for this).

The new patterns also implement partially swapped case, where
operands for a commutative plus RTX get swapped. As discussed in the
PR, there is currently no other way than duplicating the patterns.

2015-06-16  Uros Bizjak  ubiz...@gmail.com

PR target/56776
* config/i386/sse.md (*avx_addsubv4df3_1): New insn pattern.
(*avx_addsubv4df3_1s): Ditto.
(*sse3_addsubv2df3_1): Ditto.
(*sse3_addsubv2df3_1s): Ditto.
(*avx_addsubv8sf3_1): Ditto.
(*avx_addsubv8sf3_1s): Ditto.
(*sse3_addsubv4sf3_1): Ditto.
(*sse3_addsubv4sf3_1s): Ditto.

testsuite/ChangeLog:

2015-06-16  Uros Bizjak  ubiz...@gmail.com

PR target/56776
* gcc.target/i386/pr56776-1.c: New test.
* gcc.target/i386/pr56776-2.c: Ditto.

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

Uros.
Index: config/i386/sse.md
===
--- config/i386/sse.md  (revision 224523)
+++ config/i386/sse.md  (working copy)
@@ -2032,6 +2032,38 @@
(set_attr prefix vex)
(set_attr mode V4DF)])
 
+(define_insn *avx_addsubv4df3_1
+  [(set (match_operand:V4DF 0 register_operand =x)
+   (vec_select:V4DF
+ (vec_concat:V8DF
+   (minus:V4DF
+ (match_operand:V4DF 1 register_operand x)
+ (match_operand:V4DF 2 nonimmediate_operand xm))
+   (plus:V4DF (match_dup 1) (match_dup 2)))
+ (parallel [(const_int 0) (const_int 5)
+(const_int 2) (const_int 7)])))]
+  TARGET_AVX
+  vaddsubpd\t{%2, %1, %0|%0, %1, %2}
+  [(set_attr type sseadd)
+   (set_attr prefix vex)
+   (set_attr mode V4DF)])
+
+(define_insn *avx_addsubv4df3_1s
+  [(set (match_operand:V4DF 0 register_operand =x)
+   (vec_select:V4DF
+ (vec_concat:V8DF
+   (minus:V4DF
+ (match_operand:V4DF 1 register_operand x)
+ (match_operand:V4DF 2 nonimmediate_operand xm))
+   (plus:V4DF (match_dup 2) (match_dup 1)))
+ (parallel [(const_int 0) (const_int 5)
+(const_int 2) (const_int 7)])))]
+  TARGET_AVX
+  vaddsubpd\t{%2, %1, %0|%0, %1, %2}
+  [(set_attr type sseadd)
+   (set_attr prefix vex)
+   (set_attr mode V4DF)])
+
 (define_insn sse3_addsubv2df3
   [(set (match_operand:V2DF 0 register_operand =x,x)
(vec_merge:V2DF
@@ -2050,6 +2082,44 @@
(set_attr prefix orig,vex)
(set_attr mode V2DF)])
 
+(define_insn *sse3_addsubv2df3_1
+  [(set (match_operand:V2DF 0 register_operand =x,x)
+   (vec_select:V2DF
+ (vec_concat:V4DF
+   (minus:V2DF
+ (match_operand:V2DF 1 register_operand 0,x)
+ (match_operand:V2DF 2 nonimmediate_operand xm,xm))
+   (plus:V2DF (match_dup 1) (match_dup 2)))
+ (parallel [(const_int 0) (const_int 3)])))]
+  TARGET_SSE3
+  @
+   addsubpd\t{%2, %0|%0, %2}
+   vaddsubpd\t{%2, %1, %0|%0, %1, %2}
+  [(set_attr isa noavx,avx)
+   (set_attr type sseadd)
+   (set_attr atom_unit complex)
+   (set_attr prefix orig,vex)
+   (set_attr mode V2DF)])
+
+(define_insn *sse3_addsubv2df3_1s
+  [(set (match_operand:V2DF 0 register_operand =x,x)
+   (vec_select:V2DF
+ (vec_concat:V4DF
+   (minus:V2DF
+ (match_operand:V2DF 1 register_operand 0,x)
+ 

Re: C++ PATCH for c++/66387 (error with lambda and constexpr array)

2015-06-16 Thread Jason Merrill

On 06/10/2015 09:01 AM, Jason Merrill wrote:

My change to rationalize the *_constant_value functions broke this
testcase, because we were no longer replacing the reference to the array
with its constant value.  Fixed by using maybe_constant_value instead.


We need to deal with this properly in tsubst_copy, as well.  Fixed by 
calling process_outer_var_ref.


Tested x86_64-pc-linux-gnu, applying to trunk and 5.


commit a7a168ac826a3adffd8cc7c7db5061451f638fd0
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 15 15:57:34 2015 -0400

	PR c++/66387
	* pt.c (tsubst_copy) [VAR_DECL]: Use process_outer_var_ref.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ea8c8b6..9236311 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13071,10 +13071,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 		  if (TREE_STATIC (r))
 			rest_of_decl_compilation (r, toplevel_bindings_p (),
 		  at_eof);
-		  else if (decl_constant_var_p (r))
-			/* A use of a local constant decays to its value.
-			   FIXME update for core DR 696.  */
-			r = scalar_constant_value (r);
+		  else
+			r = process_outer_var_ref (r, complain);
 		}
 		}
 	  /* Remember this for subsequent uses.  */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 59ec9047..a1519b9 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3103,6 +3103,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
   if (cp_unevaluated_operand)
 /* It's not a use (3.2) if we're in an unevaluated context.  */
 return decl;
+  if (decl == error_mark_node)
+return decl;
 
   tree context = DECL_CONTEXT (decl);
   tree containing_function = current_function_decl;
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C
new file mode 100644
index 000..57e0ad2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C
@@ -0,0 +1,123 @@
+// PR c++/66387
+// { dg-do compile { target c++14 } }
+
+namespace boost {
+namespace hana {
+namespace detail {
+namespace std {
+using size_t = decltype(0);
+}
+}
+namespace ic_detail {
+template typename T, T struct _with_index {
+  template typename F constexpr void operator()(F ) const;
+};
+template typename T, T v struct _times { _with_indexT, v with_index; };
+}
+template typename T, T v struct _integral_constant {
+  using value_type = T;
+  operator value_type() const;
+  ic_detail::_timesT, v times;
+};
+template detail::std::size_t i
+constexpr _integral_constantdetail::std::size_t, i size_t{};
+template typename, typename = void struct datatype;
+}
+}
+namespace std {
+typedef int size_t;
+inline namespace __cxx11 {}
+}
+namespace boost {
+namespace hana {
+template bool struct when;
+template typename, typename, typename struct to_impl;
+template typename T, typename struct datatype : datatypeT, whentrue {};
+template typename T, bool condition struct datatypeT, whencondition {
+  using type = typename T::hana::datatype;
+};
+template typename struct _models;
+template typename To, typename From
+struct to_impl  To,
+From, when  _modelsFrom {
+}  ;
+namespace detail {
+namespace std {
+template typename T, T struct integer_sequence;
+template size_t... n using index_sequence = integer_sequencesize_t, n...;
+namespace int_seq_detail {
+template size_t struct make_index_sequence {
+  using type = index_sequence0;
+};
+template typename, typename struct cast_to;
+template typename T, typename U, U... u
+struct cast_toT, integer_sequenceU, u... {
+  using type = integer_sequenceT, u...;
+};
+}
+template typename T, T
+using make_integer_sequence = typename int_seq_detail::cast_to
+T, int_seq_detail::make_index_sequence1::type::type;
+}
+}
+namespace ic_detail {
+template typename T, T N, typename = detail::std::make_integer_sequenceT, N
+struct go;
+template typename T, T N, T... i
+struct goT, N, detail::std::integer_sequenceT, i... {
+  using swallow = T;
+  template typename F static void with_index(F f) {
+swallow{(f(_integral_constantT, i{}), 0)...};
+  }
+};
+template typename T, T v
+template typename F
+constexpr void _with_indexT, v::operator()(F f) const {
+  goT, 0::with_index(f);
+}
+}
+}
+}
+namespace std {
+template typename class allocator;
+template class struct char_traits;
+template typename _CharT, typename = char_traits_CharT class basic_ostream;
+namespace __cxx11 {
+template typename _CharT, typename = char_traits_CharT,
+  typename = allocator_CharT
+class basic_stringstream;
+}
+typedef basic_ostreamchar ostream;
+typedef basic_stringstreamchar stringstream;
+template typename, typename class basic_ostream {};
+template typename _CharT, typename
+class basic_iostream : public basic_ostream_CharT {};
+namespace __cxx11 {
+template typename _CharT, typename _Traits, typename
+class basic_stringstream : public basic_iostream_CharT, _Traits {};
+}
+}
+namespace hana = boost::hana;
+template typename struct print_impl;
+template 

Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Richard Biener
On June 16, 2015 5:31:57 PM GMT+02:00, Martin Liška mli...@suse.cz wrote:
On 06/16/2015 04:02 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 3:38 PM, Martin Liška mli...@suse.cz wrote:
 On 06/16/2015 03:17 PM, Richard Biener wrote:
 On Tue, Jun 16, 2015 at 11:26 AM, Martin Liška mli...@suse.cz
wrote:
 On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static
casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T*
pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for
call to ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void*
cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument,
2 provided

 #include new


 Hi.

 new header file is not missing (explicit addition of the file
does not help).
 Feel free to play with following patch which should fix cselib.h
compilation error.

 cselib_val overrides the new operator but fails to provide an
overload
 for the placement new
 form.  Fix that and it should work (of course it gets quite awkward
 with its 'new' calling
 pool.allocate and its placement new doing value-construction
then...)

 Richard.

 Do you mean Richard following changes:

 alloc-pool.h (allocate):
 ...
 +  /* Placement new contructor.  */
 +  inline void *operator new (size_t, elt_loc_list *ptr)
 +  {
 +return ptr;
 +  }
 
 That should be there with including new
 
 and e.g. cselib.h:

 struct cselib_val
 {
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
 return pool.allocate ();
   }

   /* Placement new contructor.  */
   inline void *operator new (size_t, char *ptr)
   {
 return ptr;
   }
 
 Yes, though I wonder whether cselib_val should really have undefined
 contents after
 allocating it?  (or does the pool allocator zero the memory?)
 
 Richard.

Hio.

I've added calling of placement new operators and memset a memory, look
the patch
works for me.

It might be better to just dispatch to
::new?

Richard.


If it's the right way, I'll write Changelog and run testsuite.

Thanks,
Martin

 
 }

 Thanks,
 Martin




 Thanks,
 Martin





RE: [Patch, MIPS] Modify sysroot layout for mips-mti-* and mips-img-*

2015-06-16 Thread Steve Ellcey
As follow-up to this patch, I forgot to include a testsuite patch to two
mips specific tests that fail with the new layout.  These tests are
loongson specific and have includes of system headers in them.   The way
mips.exp in testsuite/gcc.target/mips works is that for runnable tests
requiring a specific ABI that is incompatible with the ABI being tested
the test is converted to an assemble only test.  With the old layouts
for mips-mti-linux* and mips-img-linux*, this was no problem because
there was a single copy of /usr/include in sysroot used by all
compilations.  With the new layout there are multiple copies
of /usr/include under each of the various system sysroots and if the ABI
does not match any of those than the test will not know where to find
the include files.  Since there are only two of these tests and I could
not think of a clean way to make the tests work on the mti or img
toolchains I just added a target option to skip them for the mti and img
toolchains.

I ran this by Matthew and got his OK so I will check this patch in along
with the patch to change the sysroot layout.

Steve Ellcey
sell...@imgtec.com

2015-06-16  Steve Ellcey  sell...@imgtec.com

* gcc.target/mips/loongson-shift-count-truncated-1.c:
Skip on mips*-mti-linux* and mips*-img-linux* targets.
* gcc.target/mips/loongson-simd.c: Ditto.


diff --git a/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c 
b/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
index 778d739..f57a18c 100644
--- a/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
+++ b/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
@@ -1,6 +1,6 @@
 /* Test case for SHIFT_COUNT_TRUNCATED on Loongson.  */
 
-/* { dg-do run } */
+/* { dg-do run { target { ! { mips*-mti-linux* mips*-img-linux* } } } } */
 /* loongson.h does not handle or check for MIPS16ness.  There doesn't
seem any good reason for it to, given that the Loongson processors
do not support MIPS16.  */
diff --git a/gcc/testsuite/gcc.target/mips/loongson-simd.c 
b/gcc/testsuite/gcc.target/mips/loongson-simd.c
index 3d72e93..6d2ceb6 100644
--- a/gcc/testsuite/gcc.target/mips/loongson-simd.c
+++ b/gcc/testsuite/gcc.target/mips/loongson-simd.c
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 http://www.gnu.org/licenses/.  */
 
-/* { dg-do run } */
+/* { dg-do run { target { ! { mips*-mti-linux* mips*-img-linux* } } } } */
 /* loongson.h does not handle or check for MIPS16ness or
microMIPSness.  There doesn't seem any good reason for it to, given
that the Loongson processors do not support either.  The effective target




Re: [Patch, MIPS] Enable fp-contract on MIPS and update -mfused-madd

2015-06-16 Thread Joseph Myers
On Tue, 16 Jun 2015, Maciej W. Rozycki wrote:

 On Tue, 16 Jun 2015, Joseph Myers wrote:
 
Furthermore these checks were deliberately introduced by Richard with 
   his 
   proposal here http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00682.html 
   and agreed upon in the discussion even before IEEE Std 754-2008 has been 
   made.  Are you suggesting that the arguments used there, that have led to 
   the current arrangement, no longer stand and consequently the HONOR_NANS 
   checks introduced are now best dropped?
  
  Only the checks for abs and neg patterns are necessary, not those for 
  fused operations.
 
  And neither for the unfused combined operations we handle for some MIPS 
 processors that implement them presumably?

Indeed.

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


[C++ Patch] PR 59682

2015-06-16 Thread Paolo Carlini

Hi,

fixing this accepts-invalid seems just matter of carefully checking the 
return value of cp_parser_parenthesized_expression_list (eg, 
vec_safe_is_empty would not do, because it returns true when the 
argument is null). Tested x86_64-linux.


Thanks,
Paolo.

/
/cp
2015-06-16  Paolo Carlini  paolo.carl...@oracle.com

PR c++/59682
* parser.c (cp_parser_new_placement): Reject an empty expression-list.

/testsuite
2015-06-16  Paolo Carlini  paolo.carl...@oracle.com

PR c++/59682
* g++.dg/parse/new-placement1.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 224523)
+++ cp/parser.c (working copy)
@@ -7560,6 +7560,9 @@ cp_parser_new_placement (cp_parser* parser)
  /*allow_expansion_p=*/true,
  /*non_constant_p=*/NULL));
 
+  if (expression_list  expression_list-is_empty ())
+error (expected expression);
+
   return expression_list;
 }
 
Index: testsuite/g++.dg/parse/new-placement1.C
===
--- testsuite/g++.dg/parse/new-placement1.C (revision 0)
+++ testsuite/g++.dg/parse/new-placement1.C (working copy)
@@ -0,0 +1,3 @@
+// PR c++/59682
+
+int* p = new() int;  // { dg-error expected expression }


[patch 2/5] Remove tree.h compilation dependency for tm.h

2015-06-16 Thread Andrew MacLeod


There are 2 macros defined in tree.h the depend on the definition of 
NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL.   These are ANON_AGGRNAME_FORMAT 
and ANON_AGGRNAME_P.  This means that in order to get the correct values 
for those macros, you have to be sure that tm.h was included before 
tree.h, and thats the only conditional dependency tree.h has on tm.h.


By changing those 2 macos to functions and defining them in tree.c, the 
restriction/requirement is removed.  These are not heavily used, Im sure 
compilation issues are unmeasurable.


There is also single hard compilation dependency on the definition of 
TARGET_DLLIMPORT_DECL_ATTRIBUTES. it shows:


#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
/* Given two Windows decl attributes lists, possibly including
   dllimport, return a list of their union .  */
extern tree merge_dllimport_decl_attributes (tree, tree);

/* Handle a dllimport or dllexport attribute.  */
extern tree handle_dll_attribute (tree *, tree, tree, int, bool *);
#endif


defaults.h provides a default definition of 0, but I'm not convinced 
that we need to hide function prototypes like this...  Anything that 
cares will be checking that macro before calling or creating those 
functions...  and if they don't there will be an unresolved external at 
compilation time.. so we still get an error.  We also don't get any 
errors if the prototype isn't used.  If it is not protected, then it 
removes the need to have defaults.h and tm.h included before tree.h


This patch makes both these changes, and tree.h no longer requires tm.h 
or defaults.h


bootstraps on x86_64-unknown-linux-gnu with no new regressions.  No 
failures on config-list.mk target runs either.


OK for trunk?
Andrew



	* tree.h (merge_dllimport_decl_attributes, handle_dll_attribute):
	Remove conditional exposure of prototypes.
	(ANON_AGGRNAME_FORMAT, ANON_AGGRNAME_P): Delete.
	* tree.c (anon_aggrname_format, anon_aggrname_p): New.  Replace macro
	defintions in tree.h with functions.
	* lto-streamer-out.c (DFS_write_tree_body, hash_tree): Use
	anon_aggrname_p.
	* tree-streamer-out.c (write_ts_decl_minimal_tree_pointers): Likewise.

	* cp/cp-lang.c (cxx_dwarf_name): Use anon_aggrname_p.
	* cp/cp-tree.h (TYPE_ANONYMOUS_P): Likewise.
	* cp/decl.c (grokdeclarator, xref_tag_1): Likewise.
	* cp/error.c (dump_aggr_type): likewise.
	* cp/pt.c (push_template_decl_real): Likewise.
	* cp/name-lookup.c (make_anon_name): Use anon_aggrname_format.

Index: tree.h
===
*** tree.h	(revision 224345)
--- tree.h	(working copy)
*** extern tree remove_attribute (const char
*** 3988,4001 
  
  extern tree merge_attributes (tree, tree);
  
- #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
  /* Given two Windows decl attributes lists, possibly including
 dllimport, return a list of their union .  */
  extern tree merge_dllimport_decl_attributes (tree, tree);
  
  /* Handle a dllimport or dllexport attribute.  */
  extern tree handle_dll_attribute (tree *, tree, tree, int, bool *);
- #endif
  
  /* Returns true iff unqualified CAND and BASE are equivalent.  */
  
--- 3988,3999 
*** target_opts_for_fn (const_tree fndecl)
*** 4899,4921 
  /* For anonymous aggregate types, we need some sort of name to
 hold on to.  In practice, this should not appear, but it should
 not be harmful if it does.  */
! #ifndef NO_DOT_IN_LABEL
! #define ANON_AGGRNAME_FORMAT ._%d
! #define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '.' \
!    IDENTIFIER_POINTER (ID_NODE)[1] == '_')
! #else /* NO_DOT_IN_LABEL */
! #ifndef NO_DOLLAR_IN_LABEL
! #define ANON_AGGRNAME_FORMAT $_%d
! #define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '$' \
!    IDENTIFIER_POINTER (ID_NODE)[1] == '_')
! #else /* NO_DOLLAR_IN_LABEL */
! #define ANON_AGGRNAME_PREFIX __anon_
! #define ANON_AGGRNAME_P(ID_NODE) \
!   (!strncmp (IDENTIFIER_POINTER (ID_NODE), ANON_AGGRNAME_PREFIX, \
! 	 sizeof (ANON_AGGRNAME_PREFIX) - 1))
! #define ANON_AGGRNAME_FORMAT __anon_%d
! #endif	/* NO_DOLLAR_IN_LABEL */
! #endif	/* NO_DOT_IN_LABEL */
  
  /* The tree and const_tree overload templates.   */
  namespace wi
--- 4897,4904 
  /* For anonymous aggregate types, we need some sort of name to
 hold on to.  In practice, this should not appear, but it should
 not be harmful if it does.  */
! extern const char *anon_aggrname_format();
! extern bool anon_aggrname_p (const_tree);
  
  /* The tree and const_tree overload templates.   */
  namespace wi
Index: tree.c
===
*** tree.c	(revision 224345)
--- tree.c	(working copy)
*** clean_symbol_name (char *p)
*** 9258,9263 
--- 9258,9299 
*p = '_';
  }
  
+ /* For anonymous aggregate types, we need some sort of name to
+hold on to.  In practice, this should not appear, but it should
+not be harmful if it does.  */
+ bool 
+ 

[PATCH, committed] PR jit/66539: Add parentheses as needed to gcc_jit_object_get_debug_string

2015-06-16 Thread David Malcolm
gcc_jit_object_get_debug_string wasn't adding parentheses, leading to
misleading dumps for certain compound expressions.

This patch adds:
  rvalue::get_debug_string_parens
  rvalue::get_precedence
methods, mimicing C's precedence rules, using them in the get_debug_string
implementation so that we get parentheses where needed when generating
debug strings for compound expressions.

Tested via make check-jit; takes the total expected passes of
jit.sum from 7609 to 7699.

Committed to trunk as r224531.

gcc/jit/ChangeLog:
PR jit/66539
* jit-recording.c: Within namespace gcc::jit::recording::
(rvalue::get_debug_string_parens): New function.
(binary_op::make_debug_string): Update to mimic C precedence
rules.
(binary_op_precedence): New array.
(binary_op::get_precedence): New function.
(comparison::make_debug_string): Update to mimic C precedence
rules.
(comparison_precedence): New array.
(comparison::get_precedence): New function.
(cast::make_debug_string): Update to mimic C precedence rules.
(call::make_debug_string): Likewise.
(call_through_ptr::make_debug_string): Likewise.
(array_access::make_debug_string): Likewise.
(access_field_of_lvalue::make_debug_string): Likewise.
(access_field_rvalue::make_debug_string): Likewise.
(dereference_field_rvalue::make_debug_string): Likewise.
(dereference_rvalue::make_debug_string): Likewise.
(get_address_of_lvalue::make_debug_string): Likewise.
* jit-recording.h: Within namespace gcc::jit::recording::
(precedence): New enum.
(rvalue::rvalue): Initialize field m_parenthesized_string.
(rvalue::get_debug_string_parens): New method.
(rvalue::get_precedence): New pure virtual function.
(rvalue::m_parenthesized_string): New field.
(param::get_precedence): New function.
(global::get_precedence): New function.
(memento_of_new_rvalue_from_const::get_precedence): New function.
(memento_of_new_string_literal::get_precedence): New function.
(unary_op::get_precedence): New function.
(binary_op::get_precedence): New function.
(comparison::get_precedence): New function.
(cast::get_precedence): New function.
(call::get_precedence): New function.
(call_through_ptr::get_precedence): New function.
(array_access::get_precedence): New function.
(access_field_of_lvalue::get_precedence): New function.
(access_field_rvalue::get_precedence): New function.
(dereference_field_rvalue::get_precedence): New function.
(dereference_rvalue::get_precedence): New function.
(get_address_of_lvalue::get_precedence): New function.
(local::get_precedence): New function.

gcc/testsuite/ChangeLog:
PR jit/66539
* jit.dg/all-non-failing-tests.h: Add test-debug-strings.c.
* jit.dg/test-debug-strings.c: New test case.
* jit.dg/test-quadratic.c (make_calc_discriminant): Verify that
the discriminant has a sane debug string.
---
 gcc/jit/jit-recording.c  | 150 ++---
 gcc/jit/jit-recording.h  |  49 ++-
 gcc/testsuite/jit.dg/all-non-failing-tests.h |   7 +
 gcc/testsuite/jit.dg/test-debug-strings.c| 190 +++
 gcc/testsuite/jit.dg/test-quadratic.c|  28 ++--
 5 files changed, 393 insertions(+), 31 deletions(-)
 create mode 100644 gcc/testsuite/jit.dg/test-debug-strings.c

diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index 32d7f31..f379b58 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -3021,6 +3021,63 @@ recording::rvalue::access_as_rvalue (reproducer r)
   return r.get_identifier (this);
 }
 
+/* Return a debug string for the given rvalue, wrapping it in parentheses
+   if needed to mimic C's precedence rules, i.e. if OUTER_PREC is of
+   stronger precedence that this rvalue's precedence.
+
+   For example, given:
+
+   MULT
+  /\
+   PLUS MINUS
+  /\   / \
+ A  B C   D
+
+   we want to emit:
+
+ (A + B) * (C - D)
+
+   since MULT has strong precedence than PLUS and MINUS, whereas for:
+
+   PLUS
+  /\
+   MULT DIVIDE
+  /\   /  \
+ A  B CD
+
+   we can simply emit:
+
+ A * B + C / D
+
+   since PLUS has weaker precedence than MULT and DIVIDE.  */
+
+const char *
+recording::rvalue::get_debug_string_parens (enum precedence outer_prec)
+{
+  enum precedence this_prec = get_precedence ();
+
+  /* If this_prec has stronger precedence than outer_prec, we don't
+ need to wrap this in parens within the outer debug string.
+ Stronger precedences occur earlier than weaker within the enum,
+ so this is a less than test.  Equal precedences don't need
+ parentheses.  */
+  if (this_prec = 

[patch] libstdc++/65393 move shared_ptrs in thread::_M_make_thread

2015-06-16 Thread Jonathan Wakely

This is a small optimisation to avoid atomic updates to the
ref-counts. I have a bigger change in the pipeline for the trunk, but
this is an incremental improvement and is safe for gcc-5-branch.

Tested powerpc64le-linux, committed to trunk.
commit 6cd552bb41661fc48111b7162641d4e8b4c85404
Author: Jonathan Wakely jwak...@redhat.com
Date:   Thu Mar 12 13:23:23 2015 +

	PR libstdc++/65393
	* src/c++11/thread.cc (thread::_M_make_thread): Replace shared_ptr
	copies with moves.

diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index 954f267..906cafa 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -92,7 +92,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 	  std::terminate();
 	}
 
-  return 0;
+  return nullptr;
 }
   }
 
@@ -137,18 +137,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_system_error(int(errc::operation_not_permitted));
 #endif
 
-_M_start_thread(__b, nullptr);
+_M_start_thread(std::move(__b), nullptr);
   }
 
   void
   thread::_M_start_thread(__shared_base_type __b, void (*)())
   {
-__b-_M_this_ptr = __b;
+auto ptr = __b.get();
+ptr-_M_this_ptr = std::move(__b);
 int __e = __gthread_create(_M_id._M_thread,
-			   execute_native_thread_routine, __b.get());
+			   execute_native_thread_routine, ptr);
 if (__e)
 {
-  __b-_M_this_ptr.reset();
+  ptr-_M_this_ptr.reset();
   __throw_system_error(__e);
 }
   }


Re: [C++/58583] ICE instantiating NSDMIs

2015-06-16 Thread Nathan Sidwell

On 06/16/15 03:47, Andreas Schwab wrote:

Nathan Sidwell nat...@acm.org writes:


PR c++/58583
* g++.dg/cpp0x/nsdmi-template14.C: New test.


spawn -ignore SIGHUP 
/usr/local/gcc/gcc-20150616/Build/gcc/testsuite/g++2/../../xg++ 
-B/usr/local/gcc/gcc-20150616/Build/gcc/testsuite/g++2/../../ 
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C 
-fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++ 
-I/usr/local/gcc/gcc-20150616/Build/ia64-suse-linux/libstdc++-v3/include/ia64-suse-linux
 -I/usr/local/gcc/gcc-20150616/Build/ia64-suse-linux/libstdc++-v3/include 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/libsupc++ 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/include/backward 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/testsuite/util -fmessage-length=0 
-std=c++11 -pedantic-errors -Wno-long-long -S -o nsdmi-template14.s.
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C:14:6: 
error: recursive instantiation of non-static data member initializer for 
'B1::p'.
compiler exited with status 1
output is:
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C:14:6: 
error: recursive instantiation of non-static data member initializer for 
'B1::p'.

FAIL: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 4)
FAIL: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 6)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 14)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11 (test for excess errors)


strange.  This is what I got on x86_64-linux (fedora21, FWIW)


spawn -ignore SIGHUP 
/home/nathan/egcs/head/x86_64-linux/gcc/testsuite/g++3/../../xg++ 
-B/home/nathan/egcs/head/x86_64-linux/gcc/testsuite/g++3/../../ 
/home/nathan/egcs/head/src/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C 
-fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++ 
-I/home/nathan/egcs/head/x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu 
-I/home/nathan/egcs/head/x86_64-linux/x86_64-unknown-linux-gnu/libstdc++-v3/include 
-I/home/nathan/egcs/head/src/libstdc++-v3/libsupc++ 
-I/home/nathan/egcs/head/src/libstdc++-v3/include/backward 
-I/home/nathan/egcs/head/src/libstdc++-v3/testsuite/util -fmessage-length=0 
-std=c++11 -pedantic-errors -Wno-long-long -S -o nsdmi-template14.s


PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 4)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 6)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 14)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11 (test for excess errors)

The missing errors are here:

templateint struct A // { dg-error has been parsed }
{
  int i = (A0(), 0); // { dg-error has been parsed }
};

It's almost as if the initializer isn't being parsed at all. (prior to my patch, 
it should end up ICEing instantiating DEFARG)


nathan


Re: [patch 0/5] Dependency removal and header adjustments

2015-06-16 Thread Andrew MacLeod

On 06/16/2015 01:20 PM, Joseph Myers wrote:

On Tue, 16 Jun 2015, Andrew MacLeod wrote:


component... as indicated by an analysis of what is usually needed.Does
that seem like a reasonable breakdown?  what was the *real* intention of
target.h?

target.h is what needs to be included to use target hooks.

In particular, it would be desirable to eliminate the tm.h include from
target.h (required by hard-reg-set.h, at least, at present), so that once
a file has been freed of uses of target macros (all converted to hooks)
they can't accidentally creep back in.  I don't know offhand the best way
of eliminating tm.h dependence in the types of hook arguments, but at
least it would be best to *avoid* any designs that make it harder to
remove that tm.h include.

Ah, ok. I'll have a look at that shortly, and look for a different place 
to organize rtl's includes


Andrew


RE: [Patch, MIPS] Modify sysroot layout for mips-mti-* and mips-img-*

2015-06-16 Thread Matthew Fortune
Steve Ellcey steve.ell...@imgtec.com writes:
 As follow-up to this patch, I forgot to include a testsuite patch to two
 mips specific tests that fail with the new layout.  These tests are
 loongson specific and have includes of system headers in them.   The way
 mips.exp in testsuite/gcc.target/mips works is that for runnable tests
 requiring a specific ABI that is incompatible with the ABI being tested
 the test is converted to an assemble only test.  With the old layouts
 for mips-mti-linux* and mips-img-linux*, this was no problem because
 there was a single copy of /usr/include in sysroot used by all
 compilations.  With the new layout there are multiple copies
 of /usr/include under each of the various system sysroots and if the ABI
 does not match any of those than the test will not know where to find
 the include files.  Since there are only two of these tests and I could
 not think of a clean way to make the tests work on the mti or img
 toolchains I just added a target option to skip them for the mti and img
 toolchains.
 
 I ran this by Matthew and got his OK so I will check this patch in along
 with the patch to change the sysroot layout.

Agreed, I see no way to avoid this.

Thanks,
Matthew


[patch 0/5] Dependency removal and header adjustments

2015-06-16 Thread Andrew MacLeod
I took a snapshot of trunk and completely flattened all the header files 
and tried removing them one by one. Then I looked at the dependencies 
between the files which prevented removal of certain headers and looked 
to see what could be simplified.


Initially I was looking at removing the need to include  tm.h on headers 
that didn't seem like they should need it, but it turned out 
hard-reg-set.h was also a big offender.


The following 5 patches are the initial results of my experiment. Once 
these are approved/adjusted and I get them checked in, I will do the 
exercise again and look at building up some module headers... assuming 
the trimming seems reasonable..


There may be a bit more tweaking needed, especially since I'm not sure 
what he original intentions were for some of those files.   It seems to 
me that after these patches, there is probably 3 major component headers 
to set up.  tree, gimple and rtl.


tree.h and gimple.h are pretty obvious, but I was wondering about rtl.h. 
It is  complicated by the fact that it is included by a lot of the 
generators in a very handcuffed way,  and I'm not really going to try to 
untangle that.. its very target configured and I don't think it needs 
mucking with right now.  Instead, I noticed that target.h looks like 
someone was trying to build that up as the main file to include when you 
needed to do something for a target, like generate rtl and target code.


So I'd propose that I'd look to see whats necessary for compilation, as 
well as the most heavily used auxiliary routines for 3 major components:

tree.h
gimple.h
target.h
and that source files be adjusted to include anywhere from the 1-3 of 
those that they need, and that they each bring in most the required 
files  for the component... as indicated by an analysis of what is 
usually needed.Does that seem like a reasonable breakdown?  what was 
the *real* intention of target.h?


I also plan to rebuild cgraph.h and df.h a bit so they don't bring in a 
lot of extra things and line up well, and possibly some other minor 
sub-headers... we'll see where things fall... Im just not quite there 
yet :-)


Andrew



Re: [patch 0/5] Dependency removal and header adjustments

2015-06-16 Thread Joseph Myers
On Tue, 16 Jun 2015, Andrew MacLeod wrote:

 component... as indicated by an analysis of what is usually needed.Does
 that seem like a reasonable breakdown?  what was the *real* intention of
 target.h?

target.h is what needs to be included to use target hooks.

In particular, it would be desirable to eliminate the tm.h include from 
target.h (required by hard-reg-set.h, at least, at present), so that once 
a file has been freed of uses of target macros (all converted to hooks) 
they can't accidentally creep back in.  I don't know offhand the best way 
of eliminating tm.h dependence in the types of hook arguments, but at 
least it would be best to *avoid* any designs that make it harder to 
remove that tm.h include.

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


[patch 5/5] Remove function.h dependency on hard-reg-set.

2015-06-16 Thread Andrew MacLeod
function.h defines struct rtl_data which is used for generating rtl. In 
particular, it defines an instance 'crtl' which for generating rtl 
appears analagous to cfun for gimple and trees.


That is the only reason function.h requires hard-reg-set.h.  I tried a 
lot of variations.. like moving it into rtl.h, moving it into its own 
file,  and eventually settled on putting it in emit-rtl.h   In fact, it 
turns out emit-rtl.c is where the instance is actually declared 
function.h was simply providing a reference to it so someone didn't have 
to include emit-rtl I guess.  BUt then emit-rtl.h has most of the inline 
functions for accessing it.  There appears to be some historical reason 
for not wanting to include emit-rtl.h? Im not sure.


Placing it in rtl.h appeared to be someones original plan if I read the 
various comments correctly. I tried that in many variations, but the 
intricate dance between the generators and rtl.h and how to detect who 
really needs it made it ugly, and I couldn't find any decent way to do 
it.  Putting it in Its own file worked OK, but it required that file to 
be incliuded a lot of other places.  Thats still an option however.
Given the changes to put it into emit-rtl.h are so simple in comparison, 
and all the routines that manipulate are already declared there, it 
seems like the most appropriate place.


there were also 2 function prototypes in function.h which were guarded 
by #ifdef RTX_CODE  I remove that and let the prototypes be 
defined.  I'm not sure why they were guarded... they aren't called if 
there is no RTX_CODE defined anyway... lots of other parameter lists 
refer to 'rtx' and there's no compilation error if the prototypes is 
produced but not used.


By doing that, there is no longer any ordering requirement that 
function.h be included before rtl.h, and no dependency.  And of course, 
function.h no longer requires hard-reg-set.h etiher.


bootstraps on x86_64-unknown-linux-gnu with no new regressions, and also 
compiles stage 1 for all the targets in config-list.mk.


OK for trunk?
Andrew


	* function.h (struct rtl_data): Remove struct and accessor macros.
	* emit-rtl.h (struct rtl_data): Relocate to here.
	* Makefile.in (GTFILES): Add emit-rtl.h.
	* df-core.c: Include emit-rtl.h.
	* genattrtab.c: Likewise.
	* genconditions.c: Likewise.
	* genpreds.c: Likewise.
	* genrecog.c: Likewise.
	* regcprop.c: Likewise.
	* resource.c: Likewise.
	* sched-rgn.c: Likewise.
	* config/aarch64/cortex-a57-fma-steering.c: Likewise.
	* config/i386/winnt.c: Likewise.


Index: function.h
===
*** function.h	(revision 224493)
--- function.h	(working copy)
*** struct GTY(()) rtl_eh {
*** 153,160 
  #define stack_pointer_delta (crtl-expr.x_stack_pointer_delta)
  
  struct gimple_df;
- struct temp_slot;
- typedef struct temp_slot *temp_slot_p;
  struct call_site_record_d;
  struct dw_fde_node;
  
--- 153,158 
*** struct GTY(()) frame_space
*** 223,483 
HOST_WIDE_INT length;
  };
  
- /* Datastructures maintained for currently processed function in RTL form.  */
- struct GTY(()) rtl_data {
-   struct expr_status expr;
-   struct emit_status emit;
-   struct varasm_status varasm;
-   struct incoming_args args;
-   struct function_subsections subsections;
-   struct rtl_eh eh;
- 
-   /* For function.c  */
- 
-   /* # of bytes of outgoing arguments.  If ACCUMULATE_OUTGOING_ARGS is
-  defined, the needed space is pushed by the prologue.  */
-   int outgoing_args_size;
- 
-   /* If nonzero, an RTL expression for the location at which the current
-  function returns its result.  If the current function returns its
-  result in a register, current_function_return_rtx will always be
-  the hard register containing the result.  */
-   rtx return_rtx;
-   /* If nonxero, an RTL expression for the lcoation at which the current
-  function returns bounds for its result.  */
-   rtx return_bnd;
- 
-   /* Vector of initial-value pairs.  Each pair consists of a pseudo
-  register of approprite mode that stores the initial value a hard
-  register REGNO, and that hard register itself.  */
-   /* ??? This could be a VEC but there is currently no way to define an
- 	 opaque VEC type.  */
-   struct initial_value_struct *hard_reg_initial_vals;
- 
-   /* A variable living at the top of the frame that holds a known value.
-  Used for detecting stack clobbers.  */
-   tree stack_protect_guard;
- 
-   /* List (chain of INSN_LIST) of labels heading the current handlers for
-  nonlocal gotos.  */
-   rtx_insn_list *x_nonlocal_goto_handler_labels;
- 
-   /* Label that will go on function epilogue.
-  Jumping to this label serves as a return instruction
-  on machines which require execution of the epilogue on all returns.  */
-   rtx_code_label *x_return_label;
- 
-   /* Label that will go on the end of function epilogue.
-  Jumping to this label 

Re: [PATCH 4.8] PR66306 Fix reload problem with commutative operands

2015-06-16 Thread Ulrich Weigand
Andreas Krebbel wrote:

 this fixes a reload problem with match_dup's on commutative operands.
 
 Bootstrapped and regtested on x86-64, ppc64, and s390x.
 
 Ok?
 
 Bye,
 
 -Andreas-
 
 2015-06-11  Andreas Krebbel  kreb...@linux.vnet.ibm.com
 
   PR rtl-optimization/66306
   * reload.c (find_reloads): Swap the match_dup info for
   commutative operands.

This does indeed appear to be broken, and the fix looks good to me.

However, I'm not clear why this should be a 4.8 only patch ... the
same problem seems to be still there on mainline, right?

Patch is OK for mainline if it passes regression tests there.

Backports to release branches are fine with me if OK with the
release maintainers, after the change has been in mainline with
no problems reported for a bit.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



[patch 1/5] Move input.h and is-a.h to coretypes.h

2015-06-16 Thread Andrew MacLeod
Pretty much everything in the compiler has a need for both is-a.h and 
input.h, so this patch moves those into coretypes.h (and rtl.h for 
generators.. :-P  still working on a good way around that)


is-a.h is required by anything which includes gimple.h, rtl.h or 
cgraph.h currently, and I expect its use to grow if anything.
input.h includes line-map.h and provides location_t whose use is 
ubiquitous throughout the compiler. tree-core.h, rtl.h, gimple.h, 
function.h all require its definition for instance.  There are some 
files where input.h is included indirectly up to 7 times :-P


I think those are the last two which I'd currently propose go into 
coretypes.h.   This patch puts them there, and removes all the other 
places in the compiler that include them directly, allowing them to come 
only from coretypes.h.   The patch is big, but almost all mechanical. 
the first 2 files in the patch are coretypes.h and rtl.h so you don't 
have to paw around for them.


Bootstraps on x86_64-unknown-linux-gnu with no new regressions, and 
compiles the targets in config-list.mk.


OK for trunk?

Andrew


iil.patch.Z
Description: Unix compressed data


Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Marc Glisse

On Tue, 16 Jun 2015, Martin Liška wrote:


On 06/15/2015 07:31 PM, Marc Glisse wrote:

On Mon, 15 Jun 2015, Martin Liška wrote:


Ah, I overlooked that it's not a placement new, but just static casting.
Anyway, if I added:

cselib_val () {}

to struct cselib_val and changed the cast to placement new:
 char *ptr = (char *) header;
 return new (ptr) T ();

I got following compilation error:

In file included from ../../gcc/alias.c:46:0:
../../gcc/alloc-pool.h: In instantiation of ‘T* pool_allocatorT::allocate() 
[with T = cselib_val]’:
../../gcc/cselib.h:51:27:   required from here
../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
‘cselib_val::operator new(sizetype, char*)’
  return new (ptr) T ();
  ^
In file included from ../../gcc/alias.c:47:0:
../../gcc/cselib.h:49:16: note: candidate: static void* cselib_val::operator 
new(size_t)
  inline void *operator new (size_t)
   ^
../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 provided


#include new


Hi.

new header file is not missing (explicit addition of the file does not help).
Feel free to play with following patch which should fix cselib.h compilation 
error.


-  return (T *)(header);
+  return ::new (header) T ();

compiles just fine for me (without touching cselib.h).
(the discussion has moved on so this might not be relevant anymore)

--
Marc Glisse


[patch] Make std::list safe against overloaded operator

2015-06-16 Thread Jonathan Wakely

This fixes some unsafe uses of operator in std::list, and also in
Debug Mode found running the new test with -D_GLIBCXX_DEBUG.

Tested powerpc64le-linux, committed to trunk.

commit 588d91ac5190efb29369da9bec60d069fd7891cd
Author: Jonathan Wakely jwak...@redhat.com
Date:   Tue Jun 16 19:12:08 2015 +0100

	* include/bits/list.tcc (list::operator=(const list), list::merge):
	Use __addressof instead of operator.
	(list::sort): Use array-to-pointer decay instead of operator.
	* include/bits/stl_list.h (list::splice): Use __addressof instead of
	operator.
	* include/debug/formatter.h (_Error_formatter::_Parameter::_Parameter):
	Likewise.
	* include/debug/functions.h (__check_singular): Likewise.
	* include/debug/list (list::splice, list::merge): Likewise.
	* testsuite/23_containers/list/modifiers/addressof.cc: New.

diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index c5d2ab4..95193c1 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -265,7 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 list_Tp, _Alloc::
 operator=(const list __x)
 {
-  if (this != __x)
+  if (this != std::__addressof(__x))
 	{
 	  iterator __first1 = begin();
 	  iterator __last1 = end();
@@ -373,7 +373,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 {
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 300. list::merge() specification incomplete
-  if (this != __x)
+  if (this != std::__addressof(__x))
 	{
 	  _M_check_equal_allocators(__x); 
 
@@ -410,7 +410,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   {
 	// _GLIBCXX_RESOLVE_LIB_DEFECTS
 	// 300. list::merge() specification incomplete
-	if (this != __x)
+	if (this != std::__addressof(__x))
 	  {
 	_M_check_equal_allocators(__x);
 
@@ -446,14 +446,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   {
 list __carry;
 list __tmp[64];
-list * __fill = __tmp[0];
+list * __fill = __tmp;
 list * __counter;
 
 do
 	  {
 	__carry.splice(__carry.begin(), *this, begin());
 
-	for(__counter = __tmp[0];
+	for(__counter = __tmp;
 		__counter != __fill  !__counter-empty();
 		++__counter)
 	  {
@@ -466,7 +466,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  }
 	while ( !empty() );
 
-for (__counter = __tmp[1]; __counter != __fill; ++__counter)
+for (__counter = __tmp + 1; __counter != __fill; ++__counter)
   __counter-merge(*(__counter - 1));
 swap( *(__fill - 1) );
   }
@@ -523,14 +523,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  {
 	list __carry;
 	list __tmp[64];
-	list * __fill = __tmp[0];
+	list * __fill = __tmp;
 	list * __counter;
 
 	do
 	  {
 		__carry.splice(__carry.begin(), *this, begin());
 
-		for(__counter = __tmp[0];
+		for(__counter = __tmp;
 		__counter != __fill  !__counter-empty();
 		++__counter)
 		  {
@@ -543,7 +543,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  }
 	while ( !empty() );
 
-	for (__counter = __tmp[1]; __counter != __fill; ++__counter)
+	for (__counter = __tmp + 1; __counter != __fill; ++__counter)
 	  __counter-merge(*(__counter - 1), __comp);
 	swap(*(__fill - 1));
 	  }
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index a26859e..a498de5 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -1438,7 +1438,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 	if (__position == __i || __position == __j)
 	  return;
 
-	if (this != __x)
+	if (this != std::__addressof(__x))
 	  _M_check_equal_allocators(__x);
 
 	this-_M_transfer(__position._M_const_cast(),
@@ -1501,7 +1501,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   {
 	if (__first != __last)
 	  {
-	if (this != __x)
+	if (this != std::__addressof(__x))
 	  _M_check_equal_allocators(__x);
 
 	size_t __n = this-_M_distance(__first._M_node, __last._M_node);
diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h
index 3786839..56ee807 100644
--- a/libstdc++-v3/include/debug/formatter.h
+++ b/libstdc++-v3/include/debug/formatter.h
@@ -241,7 +241,7 @@ namespace __gnu_debug
 	: _M_kind(__iterator),  _M_variant()
 	{
 	  _M_variant._M_iterator._M_name = __name;
-	  _M_variant._M_iterator._M_address = __it;
+	  _M_variant._M_iterator._M_address = std::__addressof(__it);
 	  _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it);
 	  _M_variant._M_iterator._M_constness =
 	std::__are_same_Safe_iterator_Iterator, _Sequence,
@@ -271,7 +271,7 @@ namespace __gnu_debug
 	: _M_kind(__iterator),  _M_variant()
 	{
 	  _M_variant._M_iterator._M_name = __name;
-	  _M_variant._M_iterator._M_address = __it;
+	  _M_variant._M_iterator._M_address = std::__addressof(__it);
 	  _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it);
 	  _M_variant._M_iterator._M_constness =
 	std::__are_same_Safe_local_iterator_Iterator, 

Re: [patch 2/6] scalar-storage-order merge: C front-end

2015-06-16 Thread Joseph Myers
On Tue, 16 Jun 2015, Eric Botcazou wrote:

 +@item unused
 +@cindex @code{unused} type attribute
 +When attached to a type (including a @code{union} or a @code{struct}),
 +this attribute means that variables of that type are meant to appear
 +possibly unused.  GCC does not produce a warning for any variables of
 +that type, even if the variable appears to do nothing.  This is often
 +the case with lock or thread classes, which are usually defined and then
 +not referenced, but contain constructors and destructors that have
 +nontrivial bookkeeping functions.

You appear to be duplicating the documentation of an unrelated attribute.

What happens when typeof is applied to a field with reversed storage 
order?

 +  else if (TYPE_REVERSE_STORAGE_ORDER (t)
 + TREE_CODE (field) == FIELD_DECL
 + TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)
 + {
 +   tree ftype = TREE_TYPE (field);
 +   do
 + ftype = TREE_TYPE (ftype);
 +   while (TREE_CODE (ftype) == ARRAY_TYPE);
 +   if (!RECORD_OR_UNION_TYPE_P (ftype))
 + {
 +   tree *ftypep = TREE_TYPE (field);
 +   do {
 + *ftypep = build_distinct_type_copy (*ftypep);
 + TYPE_REVERSE_STORAGE_ORDER (*ftypep) = 1;
 + ftypep = TREE_TYPE (*ftypep);
 +   } while (TREE_CODE (*ftypep) == ARRAY_TYPE);

I don't think this type construction is safe when the array type has 
qualified element type.  The following invariant is meant to hold: for an 
array type whose element type (possibly after going down through several 
levels of array types) is qualified, the TYPE_MAIN_VARIANT is a 
corresponding array type whose element type is unqualified.  So in that 
case you need to build two sequences of array types, not one: the main 
variants with unqualified element type, and the versions with qualified 
element type.  See c_build_qualified_type.

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


[PATCH] rs6000: Clean up the cmp* insns

2015-06-16 Thread Segher Boessenkool
No change in behaviour; bootstrapped and tested as usual.  Is this okay
for trunk?

Now the output modifier %b is unused; what do we do with that?
Leave it in place in case anything uses it in inline asm?  It never
was documented.  We could use some freed modifiers, almost everything
is used now (there are only 52 possible ones).


Segher


2015-06-16  Segher Boessenkool  seg...@kernel.crashing.org

* config/rs6000/rs6000.md (*cmpmode_internal1): Rename to...
(*cmpmode_signed): ... this.
(*cmpsi_internal2, *cmpdi_internal2): Merge, rename to...
(*cmpmode_unsigned): ... this.  Remove %b.

---
 gcc/config/rs6000/rs6000.md | 26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 5d3e04b..6a14ee8 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10714,7 +10714,7 @@ (define_insn stack_protect_testdi
 
 
 ;; Here are the actual compare insns.
-(define_insn *cmpmode_internal1
+(define_insn *cmpmode_signed
   [(set (match_operand:CC 0 cc_reg_operand =y)
(compare:CC (match_operand:GPR 1 gpc_reg_operand r)
(match_operand:GPR 2 reg_or_short_operand rI)))]
@@ -10722,6 +10722,14 @@ (define_insn *cmpmode_internal1
   cmpwd%I2 %0,%1,%2
   [(set_attr type cmp)])
 
+(define_insn *cmpmode_unsigned
+  [(set (match_operand:CCUNS 0 cc_reg_operand =y)
+   (compare:CCUNS (match_operand:GPR 1 gpc_reg_operand r)
+  (match_operand:GPR 2 reg_or_u_short_operand rK)))]
+  
+  cmplwd%I2 %0,%1,%2
+  [(set_attr type cmp)])
+
 ;; If we are comparing a register for equality with a large constant,
 ;; we can do this with an XOR followed by a compare.  But this is profitable
 ;; only if the large constant is only used for the comparison (and in this
@@ -10766,22 +10774,6 @@ (define_peephole2
   operands[10] = GEN_INT (sextc);
 })
 
-(define_insn *cmpsi_internal2
-  [(set (match_operand:CCUNS 0 cc_reg_operand =y)
-   (compare:CCUNS (match_operand:SI 1 gpc_reg_operand r)
-  (match_operand:SI 2 reg_or_u_short_operand rK)))]
-  
-  cmplw%I2 %0,%1,%b2
-  [(set_attr type cmp)])
-
-(define_insn *cmpdi_internal2
-  [(set (match_operand:CCUNS 0 cc_reg_operand =y)
-   (compare:CCUNS (match_operand:DI 1 gpc_reg_operand r)
-  (match_operand:DI 2 reg_or_u_short_operand rK)))]
-  
-  cmpld%I2 %0,%1,%b2
-  [(set_attr type cmp)])
-
 ;; The following two insns don't exist as single insns, but if we provide
 ;; them, we can swap an add and compare, which will enable us to overlap more
 ;; of the required delay between a compare and branch.  We generate code for
-- 
1.8.1.4



Re: Fix verify_type ICE with -fshort-enum

2015-06-16 Thread Jan Hubicka
PR middle-end/66325
* c-decl.c (start_enum): Set TYPE_PACKED consistently among type 
  variants.
  Index: c-decl.c
  ===
  --- c-decl.c  (revision 224250)
  +++ c-decl.c  (working copy)
  @@ -7946,7 +7946,8 @@
 the_enum-enum_overflow = 0;
 
 if (flag_short_enums)
  -TYPE_PACKED (enumtype) = 1;
  +for (tree v = TYPE_MAIN_VARIANT (enumtype); v ;v = TYPE_NEXT_VARIANT 
  (v))
 
 Though I wonder why flag_short_enums was not true when building the
 (main-)variant?

What I believe happens is that there is forward declaration of enum that leads
to biuld incomplete enum type that has no packed flag set.  Then we produce
a type variant and after that we complete the main variant, but do not update
the other variant.

Actually looking into where the variant is updated, it happens in finish_enum
that copies many flags, perhaps it would make more sense to copy TYPE_PACKED
there?

 Looks like -fshort-enums is also 'Optimization', so the above is bogus for
 
 enum foo {x = 1 };
 
 void __attribute__((optimize(short-enums))) foo()
 {
   const enum foo x = 1;
 }
 
 no?  The main variant is correctly _not_ packed but now you make it
 packed as you reach foo ()?

Perhaps it is defined as Optimization but it does not bind to uses of types:

enum foo {a,b,c};
 __attribute__((optimize(short-enums))) 
main()
{
  const enum foo x;
  enum bar {a,b,c};
  printf (%i %i\n,sizeof (x), sizeof(enum bar));
}

prints
4 1

it depends when the main variant is finished.  I wonder if there is any
practical value on support Optimization attribute for this kind of ABI breaking
options.  It may be easier to simply drop the Optimization flag completely from
-fshort-enums and friends.

-fshort-double ICEs at initialization time at least since 4.8.x
$ gcc t.c -fshort-double
built-in: internal compiler error: in layout_type, at stor-layout.c:2220
0xafe41b layout_type(tree_node*)
../../gcc/stor-layout.c:2219

so I suggest dropping that flag completely.

Honza
 
 Richard.
 
  Please fix the formatting here: no space before ;.
 
  Ok with that change.
 
  Marek


[PATCH], Add IEEE 128-bit floating point to PowerPC, patch #2

2015-06-16 Thread Michael Meissner
This is the second of my IEEE 128-bit floating point support.  This patch adds
new helper macros to the infrastructure, and changes the code in rs6000.c where
we are supporting floating point to deal with IEEE 128-bit floating point when
the rest of the patches are installed.

I have tested these patches on a big endian power7 and a little endian power8
with no regressions.  Are these patches ok to install in the trunk?

2015-06-16  Michael Meissner  meiss...@linux.vnet.ibm.com

* config/rs6000/rs6000-protos.h (rs6000_secondary_reload_memory):
Use machine mode, not enum machine_mode in the prototype.

* config/rs6000/rs6000.h (FLOAT128_IEEE_P): New helper macros to
classify 128-bit floating point support.
(FLOAT128_IBM_P): Likewise.
(FLOAT128_VECTOR_P): Likewise.
(FLOAT128_2REG_P): Likewise.
(SCALAR_FLOAT_MODE_NOT_VECTOR_P): Likewise.
(SLOW_UNALIGNED_ACCESS): Add IEEE 128-bit floating point support.
(HARD_REGNO_CALLER_SAVE_MODE): Likewise.
(HARD_REGNO_CALL_PART_CLOBBERED): Likewise.

* config/rs6000/rs6000.c (rs6000_hard_regno_nregs_internal): Drop
tests against TFmode/TDmode, since those modes do not use VSX
addresses.
(rs6000_hard_regno_mode_ok): Add IEEE 128-bit floating point
support.
(rs6000_init_hard_regno_mode_ok): Use new helper macros instead of
tests against TFmode, etc.
(invalid_e500_subreg): Add tests against IFmode/KFmode.
(reg_offset_addressing_ok_p): Likewise.
(rs6000_legitimate_offset_address_p): Likewise.
(rs6000_legitimize_address): Likewise.
(rs6000_legitimize_reload_address): Likewise.
(rs6000_legitimate_address_p): Clean up tests against TFmode and
TDmode to use the new helper macros, which will include IFmode and
KFmode.
(rs6000_emit_move): Likewise.
(rs6000_darwin64_record_arg_recurse): Likewise.
(print_operand): Likewise.
(rs6000_member_type_forces_blk): Treat IEEE 128-bit floating point
that uses a single vector register as a vector and not as a
floating point register in terms of the calling sequence.
(rs6000_discover_homogeneous_aggregate): Likewise.
(rs6000_return_in_memory): Likewise.
(init_cumulative_args): Likewise.
(rs6000_function_arg_boundary): Likewise.
(rs6000_function_arg_advance_1): Likewise.
(rs6000_function_arg): Likewise.
(rs6000_pass_by_reference): Likewise.
(rs6000_gimplify_va_arg): Likewise.
(rs6000_secondary_reload_memory): Use machine_mode not enum
machine mode.
(rs6000_split_multireg_move): Use new helper macros.
(spe_func_has_64bit_regs_p): Likewise.
(rs6000_output_function_epilogue): Add IFmode/KFmode support.
(output_toc): Use new helper macros.
(rs6000_register_move_cost): Likewise.
(rs6000_function_value): Add IEEE 128-bit floating point calling
sequence support.
(rs6000_libcall_value): Likewise.
(rs6000_scalar_mode_supported_p): Add support for IEEE 128-bit
floating point support.
(rs6000_vector_mode_supported_p): Likewise.

Note, I will be on vacation starting on Friday evening, and I will return on
July 1st.  If the patch approval comes after Thursday, I will hold these
patches until I return and retest them.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/rs6000-protos.h
===
--- gcc/config/rs6000/rs6000-protos.h   (revision 224486)
+++ gcc/config/rs6000/rs6000-protos.h   (working copy)
@@ -133,8 +133,7 @@ extern void rs6000_split_multireg_move (
 extern void rs6000_emit_le_vsx_move (rtx, rtx, machine_mode);
 extern void rs6000_emit_move (rtx, rtx, machine_mode);
 extern rtx rs6000_secondary_memory_needed_rtx (machine_mode);
-extern machine_mode rs6000_secondary_memory_needed_mode (enum
- machine_mode);
+extern machine_mode rs6000_secondary_memory_needed_mode (machine_mode);
 extern rtx (*rs6000_legitimize_reload_address_ptr) (rtx, machine_mode,
int, int, int, int *);
 extern bool rs6000_legitimate_offset_address_p (machine_mode, rtx,
Index: gcc/config/rs6000/rs6000.h
===
--- gcc/config/rs6000/rs6000.h  (revision 224486)
+++ gcc/config/rs6000/rs6000.h  (working copy)
@@ -402,6 +402,33 @@ extern const char *host_detect_local_cpu
 #define TARGET_DEBUG_TARGET(rs6000_debug  MASK_DEBUG_TARGET)
 #define TARGET_DEBUG_BUILTIN   (rs6000_debug  MASK_DEBUG_BUILTIN)
 
+/* Helper macros for TFmode.  Quad floating point (TFmode) can be either IBM
+   long double format that uses a 

[patch 4/5] Remove cgraph.h dependence on hard-reg-set.h

2015-06-16 Thread Andrew MacLeod
cgraph.h requires hard-reg-set.h in order to compile simply because the 
cgraph_rtl_info structure contains a HARD_REG_SET element.


All accesses to this structure are already handled by returning a 
pointer to the structure within the cgraph_node.  By moving the 
defintion of struct cgraph_rtl_info into rtl.h and maintaining a pointer 
to it instead of the structure within cgraph_node,  the compilation 
requirement on hard-reg-set.h can be completely removed when including 
cgraph.h.  This will hopefully help prevent bringing hard-reg-set and 
tm.h into a number of source files.


 The structure in rtl.h is protected by  checking for HARD_CONST (which 
many other things in rtl.h do). This is mostly so generator files won't 
trip over them.  2 source files needed adjustment because they didn't 
include hard-reg-set.h before rtl.h.  I guess they never referenced the 
other things protected by HARD_CONST in the file.  This ordering issue 
should shortly be resolved by an include grouping.


Bootstraps on x86_64-unknown-linux-gnu with no new regressions. Also 
passes all the targets in config-list.mk


OK for trunk?

Andrew

PS shortly I plan to do some module header bundling and include 
reductions. At that point I'll remove unneeded includes of 
hard-reg-set.h from files




	* cgraph.h (cgraph_rtl_info): Move to rtl.h
	(cgraph_node): Maintain pointer to struct cgraph_rtl_info instead of
	and instance.
	* rtl.h (struct cgraph_rtl_info): Define when HARD_REG_SET available.
	* cgraph.c (cgraph_node::rtl_info): Allocate cgraph_rtl_info if one
	doesn't exist.
	* calls.c: Include hard-reg-set.h before rtl.h.
	* ira.c: Likewise.

Index: cgraph.h
===
*** cgraph.h	(revision 224342)
--- cgraph.h	(working copy)
*** struct GTY(()) cgraph_global_info {
*** 613,632 
cgraph_node *inlined_to;
  };
  
- /* Information about the function that is propagated by the RTL backend.
-Available only for functions that has been already assembled.  */
- 
- struct GTY(()) cgraph_rtl_info {
-unsigned int preferred_incoming_stack_boundary;
- 
-   /* Call unsaved hard registers really used by the corresponding
-  function (including ones used by functions called by the
-  function).  */
-   HARD_REG_SET function_used_regs;
-   /* Set if function_used_regs is valid.  */
-   unsigned function_used_regs_valid: 1;
- };
- 
  /* Represent which DECL tree (or reference to such tree)
 will be replaced by another tree while versioning.  */
  struct GTY(()) ipa_replace_map
--- 613,618 
*** public:
*** 1194,1200 
static cgraph_local_info *local_info (tree decl);
  
/* Return local info for the compiled function.  */
!   static cgraph_rtl_info *rtl_info (tree);
  
/* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
   Return NULL if there's no such node.  */
--- 1180,1186 
static cgraph_local_info *local_info (tree decl);
  
/* Return local info for the compiled function.  */
!   static struct cgraph_rtl_info *rtl_info (tree);
  
/* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
   Return NULL if there's no such node.  */
*** public:
*** 1263,1269 
  
cgraph_local_info local;
cgraph_global_info global;
!   cgraph_rtl_info rtl;
cgraph_clone_info clone;
cgraph_thunk_info thunk;
  
--- 1249,1255 
  
cgraph_local_info local;
cgraph_global_info global;
!   struct cgraph_rtl_info *rtl;
cgraph_clone_info clone;
cgraph_thunk_info thunk;
  
Index: rtl.h
===
*** rtl.h	(revision 224342)
--- rtl.h	(working copy)
*** extern void _fatal_insn (const char *, c
*** 3709,3712 
--- 3709,3729 
  /* reginfo.c */
  extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER];
  
+ #ifdef HARD_CONST
+ /* Information about the function that is propagated by the RTL backend.
+Available only for functions that has been already assembled.  */
+ 
+ struct GTY(()) cgraph_rtl_info {
+unsigned int preferred_incoming_stack_boundary;
+ 
+   /* Call unsaved hard registers really used by the corresponding
+  function (including ones used by functions called by the
+  function).  */
+   HARD_REG_SET function_used_regs;
+   /* Set if function_used_regs is valid.  */
+   unsigned function_used_regs_valid: 1;
+ };
+ #endif
+ 
+ 
  #endif /* ! GCC_RTL_H */
Index: cgraph.c
===
*** cgraph.c	(revision 224342)
--- cgraph.c	(working copy)
*** cgraph_node::rtl_info (tree decl)
*** 1894,1900 
if (node-decl != current_function_decl
 !TREE_ASM_WRITTEN (node-decl))
  return NULL;
!   return node-ultimate_alias_target ()-rtl;
  }
  
  /* Return a string describing the failure REASON.  */
--- 1894,1903 
if (node-decl != current_function_decl
 

[patch 3/5] Remove options.h dependency from tree-core.h

2015-06-16 Thread Andrew MacLeod
tree-core.h won't compile without seeing options.h (which is usually 
brought in by tm.h)  because a TARGET_OPTION node contains an instance 
of struct  cl_target_option, defined thru options.h.


Its fairly straightforward to change it so the tree node simply contains 
a pointer to one of these structures, and allocates it whenever the node 
is created or copied.  This adds an extra allocation, but I don't think 
this tree node is extensively utilized.


This removes the only compilation dependency on options.h from 
tree-core.   This will hopefully lead to many less instances of tm,h 
being required.


THis bootstraps on x86_64-unknown-linux-gnu with no new regressions, and 
passes compilation on all the config-list.mk targets.


OK for mainline?

Andrew

	* tree-core.h (tree_target_option): Make opts a pointer to a 
	cl_target_option.
	* tree.h (TREE_TARGET_OPTION): Return the pointer, not an address of
	the structure.
	* tree.c (make_node_stat ): Allocate a cl_target_option struct for 
	TARGET_OPTION_NODE.
	(copy_node_stat): Allocate and copy struct cl_target_option.

Index: tree-core.h
===
*** tree-core.h	(revision 224342)
--- tree-core.h	(working copy)
*** struct GTY(()) tree_target_option {
*** 1676,1682 
struct target_globals *globals;
  
/* The optimization options used by the user.  */
!   struct cl_target_option opts;
  };
  
  /* Define the overall contents of a tree node.
--- 1676,1682 
struct target_globals *globals;
  
/* The optimization options used by the user.  */
!   struct cl_target_option *opts;
  };
  
  /* Define the overall contents of a tree node.
Index: tree.h
===
*** tree.h	(revision 224342)
--- tree.h	(working copy)
*** extern vectree, va_gc **decl_debug_arg
*** 2839,2845 
  extern tree build_optimization_node (struct gcc_options *opts);
  
  #define TREE_TARGET_OPTION(NODE) \
!   (TARGET_OPTION_NODE_CHECK (NODE)-target_option.opts)
  
  #define TREE_TARGET_GLOBALS(NODE) \
(TARGET_OPTION_NODE_CHECK (NODE)-target_option.globals)
--- 2839,2845 
  extern tree build_optimization_node (struct gcc_options *opts);
  
  #define TREE_TARGET_OPTION(NODE) \
!   (TARGET_OPTION_NODE_CHECK (NODE)-target_option.opts)
  
  #define TREE_TARGET_GLOBALS(NODE) \
(TARGET_OPTION_NODE_CHECK (NODE)-target_option.globals)
Index: tree.c
===
*** tree.c	(revision 224342)
--- tree.c	(working copy)
*** make_node_stat (enum tree_code code MEM_
*** 1096,1101 
--- 1096,1108 
  	}
break;
  
+ case tcc_exceptional:
+   if (code == TARGET_OPTION_NODE)
+ {
+ 	  TREE_TARGET_OPTION(t) = ggc_cleared_allocstruct cl_target_option ();
+ 	}
+   break;
+ 
  default:
/* Other classes need no special treatment.  */
break;
*** copy_node_stat (tree node MEM_STAT_DECL)
*** 1177,1182 
--- 1184,1195 
  	  TYPE_CACHED_VALUES (t) = NULL_TREE;
  	}
  }
+ else if (code == TARGET_OPTION_NODE)
+   {
+ TREE_TARGET_OPTION (t) = ggc_allocstruct cl_target_option();
+ 	memcpy (TREE_TARGET_OPTION (t), TREE_TARGET_OPTION (node),
+ 		sizeof (struct cl_target_option));
+   }
  
return t;
  }


[PATCH] Add CFI entries for ARM Linux idiv0 / ldiv0

2015-06-16 Thread James Lemke

A divide by zero exception was not giving a proper traceback for LINUX
ARM_EABI.  The attached patch fixes the problem on trunk (and several
local branches).

Tested on gcc-trunk for arm-none-linux-gnueabi.

OK to commit?

--
Jim Lemke, GNU Tools Sourcerer
Mentor Graphics / CodeSourcery
Orillia, Ontario
2015-06-16  James Lemke  jwle...@codesourcery.com

	libgcc/config/arm/
	* lib1funcs.S (aeabi_idiv0, aeabi_ldiv0): Add CFI entries for
	Linux ARM_EABI.

Index: libgcc/config/arm/lib1funcs.S
===
--- libgcc/config/arm/lib1funcs.S	(revision 224523)
+++ libgcc/config/arm/lib1funcs.S	(working copy)
@@ -1336,23 +1336,30 @@ LSYM(Lover12):
 #define SIGFPE	8
 
 #ifdef __ARM_EABI__
+	cfi_start	__aeabi_ldiv0, LSYM(Lend_aeabi_ldiv0)
 	WEAK aeabi_idiv0
 	WEAK aeabi_ldiv0
 	ARM_FUNC_START aeabi_idiv0
 	ARM_FUNC_START aeabi_ldiv0
+	do_push	{r1, lr}
+98:	cfi_push 98b - __aeabi_ldiv0, 0xe, -0x4, 0x8
 #else
+	cfi_start	__div0, LSYM(Lend_div0)
 	ARM_FUNC_START div0
+	do_push	{r1, lr}
+98:	cfi_push 98b - __div0, 0xe, -0x4, 0x8
 #endif
 
-	do_push	{r1, lr}
 	mov	r0, #SIGFPE
 	bl	SYM(raise) __PLT__
-	RETLDM	r1
+	RETLDM	r1 unwind=98b
 
 #ifdef __ARM_EABI__
+	cfi_end	LSYM(Lend_aeabi_ldiv0)
 	FUNC_END aeabi_ldiv0
 	FUNC_END aeabi_idiv0
 #else
+	cfi_end	LSYM(Lend_div0)
 	FUNC_END div0
 #endif
 	


[PATCH, committed] jit: Add a test for compound assignment

2015-06-16 Thread David Malcolm
Add a testcase of assignment to structs and unions to the libgccjit
testsuite.

Tested with make check-jit; takes jit.sum from 7829 to 7974 passes.

Committed to trunk as r224536.

gcc/testsuite/ChangeLog:
* jit.dg/all-non-failing-tests.h: Add test-compound-assignment.c.
* jit.dg/test-compound-assignment.c: New testcase.
---
 gcc/testsuite/jit.dg/all-non-failing-tests.h|  10 ++
 gcc/testsuite/jit.dg/test-compound-assignment.c | 157 
 2 files changed, 167 insertions(+)
 create mode 100644 gcc/testsuite/jit.dg/test-compound-assignment.c

diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h 
b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index 2ac56f2..389e1c6 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -57,6 +57,13 @@
 #undef create_code
 #undef verify_code
 
+/* test-compound-assignment.c */
+#define create_code create_code_compound_assignment
+#define verify_code verify_code_compound_assignment
+#include test-compound-assignment.c
+#undef create_code
+#undef verify_code
+
 /* test-constants.c */
 #define create_code create_code_constants
 #define verify_code verify_code_constants
@@ -219,6 +226,9 @@ const struct testcase testcases[] = {
   {calling_function_ptr,
create_code_calling_function_ptr,
verify_code_calling_function_ptr},
+  {compound_assignment,
+   create_code_compound_assignment,
+   verify_code_compound_assignment},
   {constants,
create_code_constants,
verify_code_constants},
diff --git a/gcc/testsuite/jit.dg/test-compound-assignment.c 
b/gcc/testsuite/jit.dg/test-compound-assignment.c
new file mode 100644
index 000..8b82e09
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-compound-assignment.c
@@ -0,0 +1,157 @@
+#include stdlib.h
+#include stdio.h
+
+#include libgccjit.h
+
+#include harness.h
+
+struct assignable_struct
+{
+  int a;
+  char b;
+  float c;
+};
+
+union assignable_union
+{
+  int a;
+  char b;
+  float c;
+};
+
+/* Verify that compound assignment works; let's try to inject the
+   equivalent of:
+
+ struct assignable_struct
+ test_struct_assignment (struct assignable_struct x)
+ {
+   struct assignable_struct y, z;
+   y = x;
+   z = y;
+   return z;
+ }
+
+   and the same, for union assignable_union.  */
+
+/* Make the type struct assignable_struct or union assignable_union.  */
+
+static gcc_jit_type *
+make_type (gcc_jit_context *ctxt, int make_union)
+{
+  gcc_jit_type *t_int =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
+  gcc_jit_type *t_char =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_CHAR);
+  gcc_jit_type *t_float =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT);
+
+  gcc_jit_field *a =
+gcc_jit_context_new_field (ctxt,
+  NULL,
+  t_int,
+  a);
+  gcc_jit_field *b =
+gcc_jit_context_new_field (ctxt,
+  NULL,
+  t_char,
+  b);
+  gcc_jit_field *c =
+gcc_jit_context_new_field (ctxt,
+  NULL,
+  t_float,
+  c);
+  gcc_jit_field *fields[] = {a, b, c};
+  if (make_union)
+  return gcc_jit_context_new_union_type (ctxt, NULL,
+assignable_union,
+3, fields);
+  else
+return gcc_jit_struct_as_type (
+  gcc_jit_context_new_struct_type (ctxt, NULL,
+  assignable_struct,
+  3, fields));
+}
+
+static void
+make_function (gcc_jit_context *ctxt, int make_union, const char *funcname)
+{
+  gcc_jit_type *test_type = make_type (ctxt, make_union);
+  gcc_jit_param *x =
+gcc_jit_context_new_param (ctxt, NULL,
+  test_type, x);
+  gcc_jit_function *fn =
+gcc_jit_context_new_function (ctxt, NULL,
+ GCC_JIT_FUNCTION_EXPORTED,
+ test_type,
+ funcname,
+ 1, x,
+ 0);
+  gcc_jit_lvalue *y =
+gcc_jit_function_new_local (fn, NULL, test_type, y);
+  gcc_jit_lvalue *z =
+gcc_jit_function_new_local (fn, NULL, test_type, z);
+  gcc_jit_block *block =
+gcc_jit_function_new_block (fn, NULL);
+  gcc_jit_block_add_assignment (block, NULL,
+   y, gcc_jit_param_as_rvalue (x));
+  gcc_jit_block_add_assignment (block, NULL,
+   z, gcc_jit_lvalue_as_rvalue (y));
+  gcc_jit_block_end_with_return (block, NULL,
+gcc_jit_lvalue_as_rvalue (z));
+}
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  make_function (ctxt, 0, test_struct_assignment);
+  make_function (ctxt, 1, 

Re: [PATCH, AARCH64] make stdarg functions work with +nofp

2015-06-16 Thread Jim Wilson
On Tue, Jun 16, 2015 at 1:46 AM, James Greenhalgh
james.greenha...@arm.com wrote:
 I'm happy for this to be backported.

Thanks.  Applied.

 I think Grub probably wants to change if they want to be safe, from
 what I've read it looks like they are hoping to use something like a
 standard printf without touching the FP registers, which is suspect...

Grub has its own printf code, as it can't use glibc, and the
grub_printf function doesn't support FP format codes.  So this should
not be a problem for grub.

FYI In the git tree, grub changed from using +nofp to
-mgeneral-regs-only on June 2, because the kernel uses
-mgeneral-regs-only, and because +nofp was broken in gcc-5-branch.
But we still needed the patch backported for people who could not or
didn't want to upgrade grub.

Jim


C++ PATCH for c++/66536 (ICE with brace-initialized temp in initializer)

2015-06-16 Thread Jason Merrill
Here, arrayct_eq0, 0{} produces a CONSTRUCTOR that is not part of 
an aggregate initializer for the eq_arrays variable, so we shouldn't try 
to treat it as such.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit d3e127fb66647a1f0d8ddffc981cc0c732563815
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 15 21:44:19 2015 -0400

	PR c++/66536
	* tree.c (replace_placeholders_r) [CONSTRUCTOR]: Handle type
	mismatch.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index a52e6f4..e6442cd 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2599,7 +2599,12 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
 	if (TREE_CODE (*valp) == CONSTRUCTOR
 		 AGGREGATE_TYPE_P (type))
 	  {
-		subob = build_ctor_subob_ref (ce-index, type, obj);
+		/* If we're looking at the initializer for OBJ, then build
+		   a sub-object reference.  If we're looking at an
+		   initializer for another object, just pass OBJ down.  */
+		if (same_type_ignoring_top_level_qualifiers_p
+		(TREE_TYPE (*t), TREE_TYPE (obj)))
+		  subob = build_ctor_subob_ref (ce-index, type, obj);
 		if (TREE_CODE (*valp) == TARGET_EXPR)
 		  valp = TARGET_EXPR_INITIAL (*valp);
 	  }
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ30.C b/gcc/testsuite/g++.dg/cpp1y/var-templ30.C
new file mode 100644
index 000..e89aa7c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ30.C
@@ -0,0 +1,19 @@
+// PR c++/66536
+// { dg-do compile { target c++14 } }
+
+template typename struct make_impl;
+struct Tuple;
+template  struct make_implTuple {};
+struct A {
+  template typename X auto operator()(X) { return make_implTuple(); }
+};
+template typename A make;
+template typename _Tp, int struct array { _Tp _M_elems; };
+struct Tracked {
+  Tracked(int);
+};
+struct B {
+  Tracked tracker{0};
+};
+template int using ct_eq = B;
+auto eq_arrays = makeTuple(arrayct_eq0, 0{});


[PATCH, committed] PR jit/66539: Properly add testcase

2015-06-16 Thread David Malcolm
This hunk was omitted from r224531.

Tested with make check-jit; takes jit.sum from 7699
to 7829 passes.

Committed to trunk as r224535.

gcc/testsuite/ChangeLog:
PR jit/66539
* jit.dg/all-non-failing-tests.h: Add test-debug-strings.c
to testcases array.
---
 gcc/testsuite/jit.dg/all-non-failing-tests.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h 
b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index fcc..2ac56f2 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -222,6 +222,9 @@ const struct testcase testcases[] = {
   {constants,
create_code_constants,
verify_code_constants},
+  {debug_strings,
+   create_code_debug_strings,
+   verify_code_debug_strings},
   {dot_product,
create_code_dot_product,
verify_code_dot_product},
-- 
1.8.5.3



C++ PATCH for c++/58063 (wrong-code with virtual base and default argument)

2015-06-16 Thread Jason Merrill
The problem here was that break_out_target_exprs was duplicating a 
SAVE_EXPR, so we ended up evaluating the inner call twice.  Fixed by 
mapping them as well as TARGET_EXPRs.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 7dcc38201366f5c3043e78f7074ba863229b21d3
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jun 15 15:25:10 2015 -0400

	PR c++/58063
	* tree.c (bot_manip): Remap SAVE_EXPR.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 3553d7c..a52e6f4 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2423,6 +2423,29 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
   *walk_subtrees = 0;
   return NULL_TREE;
 }
+  if (TREE_CODE (*tp) == SAVE_EXPR)
+{
+  t = *tp;
+  splay_tree_node n = splay_tree_lookup (target_remap,
+	 (splay_tree_key) t);
+  if (n)
+	{
+	  *tp = (tree)n-value;
+	  *walk_subtrees = 0;
+	}
+  else
+	{
+	  copy_tree_r (tp, walk_subtrees, NULL);
+	  splay_tree_insert (target_remap,
+			 (splay_tree_key)t,
+			 (splay_tree_value)*tp);
+	  /* Make sure we don't remap an already-remapped SAVE_EXPR.  */
+	  splay_tree_insert (target_remap,
+			 (splay_tree_key)*tp,
+			 (splay_tree_value)*tp);
+	}
+  return NULL_TREE;
+}
 
   /* Make a copy of this node.  */
   t = copy_tree_r (tp, walk_subtrees, NULL);
diff --git a/gcc/testsuite/g++.dg/overload/defarg10.C b/gcc/testsuite/g++.dg/overload/defarg10.C
new file mode 100644
index 000..b8275d6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/defarg10.C
@@ -0,0 +1,28 @@
+// PR c++/58063
+// { dg-do run }
+
+struct basic_ios
+{
+  bool operator!() const { return false; }
+};
+
+struct ostream : virtual basic_ios
+{
+};
+
+int i;
+
+ostream operator(ostream os, const char* s) {
+  ++i;
+  return os;
+}
+
+ostream cout;
+
+void f(bool x = !(cout  hi!\n)) { }
+
+int main() {
+  f();
+  if (i != 1)
+__builtin_abort();
+}


Re: [C++ Patch] PR 59682

2015-06-16 Thread Jason Merrill

On 06/16/2015 12:13 PM, Paolo Carlini wrote:

+error (expected expression);


I would say expression-list or type-id, since new (int) is also 
well-formed.  OK with that change.


Jason



Re: [RFC] COMDAT Safe Module Level Multi versioning

2015-06-16 Thread Sriraman Tallam
On Tue, May 19, 2015 at 9:11 AM, Xinliang David Li davi...@google.com wrote:

 Hm.  But which options are unsafe?  Also wouldn't it be better to simply
 _not_ have unsafe options produce comdats but always make local clones
 for them (thus emit the comdat with unsafe flags dropped)?

 Always localize comdat functions may lead to text size increase. It
 does not work if the comdat function is a virtual function for
 instance.

Based on Richard's suggestion, I have a patch to localize comdat
functions which seems like a very effective solution to this problem.
The text size increase is limited to the extra comdat copies generated
for the specialized modules (modules with unsafe options) which is
usually only a few.   Since -fweak does something similar for
functions,  I have called the new option -fweak-comdat-functions.
This does not apply to virtual comdat functions as their addresses can
always be leaked via the vtable. Using this flag with virtual
functions generates a warning.

To summarize, this is the intended usage of this option. Modules which
use unsafe code options, like -misa for multiversioning, to generate
code that is meant to run only on a subset of CPUs can generate
comdats with specialized instructions which when picked by the linker
can get run unconditionally causing SIGILL on unsupported platforms.
This flag hides these comdats to be local to these modules and not
make them available publicly,  with the caveat that it does not apply
to virtual comdats.

Could you please review?

* c-family/c.opt (fweak-comdat-functions): New option.
* cp/decl2.c (comdat_linkage): Implement new option.  Warn when
virtual comdat functions are seen.
* doc/invoke.texi: Document new option.
* testsuite/g++.dg/no-weak-comdat-functions-1.C: New test.


Thanks
Sri



 David



 Richard.


 Thanks
 Sri
* c-family/c.opt (fweak-comdat-functions): New option.
* cp/decl2.c (comdat_linkage): Implement new option.  Warn when
virtual comdat functions are seen.
* doc/invoke.texi: Document new option.
* testsuite/g++.dg/no-weak-comdat-functions-1.C: New test.

Index: c-family/c.opt
===
--- c-family/c.opt  (revision 224486)
+++ c-family/c.opt  (working copy)
@@ -1236,6 +1236,14 @@ fweak
 C++ ObjC++ Var(flag_weak) Init(1)
 Emit common-like symbols as weak symbols
 
+fweak-comdat-functions
+C++ Var(flag_weak_comdat_functions) Init(1)
+Specific to comdat functions(-fno-weak-comdat-functions : Localize Comdat 
Functions).
+With -fno-weak-comdat-functions, virtual comdat functions are still linked as
+weak functions.  With -fno-weak-comdat-functions, the address of the comdat
+functions that are localized will be unique and this can cause unintended
+behavior when addresses of comdat functions are used.
+
 fwide-exec-charset=
 C ObjC C++ ObjC++ Joined RejectNegative
 -fwide-exec-charset=cset Convert all wide strings and character 
constants to character set cset
Index: cp/decl2.c
===
--- cp/decl2.c  (revision 224486)
+++ cp/decl2.c  (working copy)
@@ -1702,8 +1702,19 @@ mark_vtable_entries (tree decl)
 void
 comdat_linkage (tree decl)
 {
-  if (flag_weak)
-make_decl_one_only (decl, cxx_comdat_group (decl));
+  if (flag_weak
+   (flag_weak_comdat_functions
+ || TREE_CODE (decl) != FUNCTION_DECL
+ || DECL_VIRTUAL_P (decl)))
+{
+  make_decl_one_only (decl, cxx_comdat_group (decl));
+  if (TREE_CODE (decl) == FUNCTION_DECL
+  DECL_VIRTUAL_P (decl)
+  !flag_weak_comdat_functions)
+   warning_at (DECL_SOURCE_LOCATION (decl), 0,
+   fno-weak-comdat-functions: Comdat linkage of virtual 
+   function %q#D preserved.);
+}
   else if (TREE_CODE (decl) == FUNCTION_DECL
   || (VAR_P (decl)  DECL_ARTIFICIAL (decl)))
 /* We can just emit function and compiler-generated variables
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 224486)
+++ doc/invoke.texi (working copy)
@@ -189,7 +189,7 @@ in the following sections.
 -fno-pretty-templates @gol
 -frepo  -fno-rtti  -fstats  -ftemplate-backtrace-limit=@var{n} @gol
 -ftemplate-depth=@var{n} @gol
--fno-threadsafe-statics -fuse-cxa-atexit  -fno-weak  -nostdinc++ @gol
+-fno-threadsafe-statics -fuse-cxa-atexit  -fno-weak -fno-weak-comdat-functions 
-nostdinc++ @gol
 -fvisibility-inlines-hidden @gol
 -fvtable-verify=@var{std|preinit|none} @gol
 -fvtv-counts -fvtv-debug @gol
@@ -2445,6 +2445,16 @@ option exists only for testing, and should not be
 it results in inferior code and has no benefits.  This option may
 be removed in a future release of G++.
 
+@item -fno-weak-comdat-functions
+@opindex fno-weak-comdat-functions
+Do not use weak symbol support for comdat non-virtual functions, even if it
+is provided by the linker.  By default, G++ 

Re: [patch] Make std::list safe against overloaded operator

2015-06-16 Thread Jonathan Wakely

On 16/06/15 22:05 +0100, Jonathan Wakely wrote:

This fixes some unsafe uses of operator in std::list, and also in
Debug Mode found running the new test with -D_GLIBCXX_DEBUG.


And another related patch, found after rebasing some std::list changes
I've been working on.

Tested powerpc64le-linux, committed to trunk.

commit 7c2d6125ffabb27c89ad3c2345ab90bc8159e550
Author: Jonathan Wakely jwak...@redhat.com
Date:   Tue Jun 16 22:29:37 2015 +0100

	* include/bits/allocated_ptr.h (__allocated_ptr): Use __addressof.

diff --git a/libstdc++-v3/include/bits/allocated_ptr.h b/libstdc++-v3/include/bits/allocated_ptr.h
index 63088c2..d7f00d7 100644
--- a/libstdc++-v3/include/bits/allocated_ptr.h
+++ b/libstdc++-v3/include/bits/allocated_ptr.h
@@ -50,14 +50,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// Take ownership of __ptr
   __allocated_ptr(_Alloc __a, pointer __ptr) noexcept
-  : _M_alloc(__a), _M_ptr(__ptr)
+  : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
   { }
 
   /// Convert __ptr to allocator's pointer type and take ownership of it
   templatetypename _Ptr,
 	   typename _Req = _Requireis_same_Ptr, value_type*
   __allocated_ptr(_Alloc __a, _Ptr __ptr)
-  : _M_alloc(__a), _M_ptr(pointer_traitspointer::pointer_to(*__ptr))
+  : _M_alloc(std::__addressof(__a)),
+	_M_ptr(pointer_traitspointer::pointer_to(*__ptr))
   { }
 
   /// Transfer ownership of the owned pointer


Re: Drop TYPE_NEEDS_CONSTRUCTING checks from ipa-pure-const and tree-inline

2015-06-16 Thread Jan Hubicka
 On Mon, 15 Jun 2015, Jan Hubicka wrote:
 
  Hi,
  this patch removes last two remaining uses of TYPE_NEEDS_CONSTRUCTING
  in the back-end.  I believe those are remainders from the time we did not
  gimplify as much as we do now. Alias analysis machinery already skips
  checks of TYPE_NEEDS_CONSTRUCTING and thus we need to mark tree correctly
  as non-readonly if it is constructed.
 
 I think it is relevant only for globals anyway, no?  Thus with
 unit-at-a-time and global constructors built we should even see it
 is not readonly.

Yes, I believe this is all lowered now.
 
  Incrementally I would like to remove TYPE_NEEDS_CONSTRUCTING streaming
  and clear it in free_lang_data.
  
  Bootstrapped/regtested ppc64le-linux, OK?
 
 Ok.

Thanks! One bit fewer to care about :)

Honza


Re: [PATCH] rs6000: Clean up the cmp* insns

2015-06-16 Thread David Edelsohn
On Tue, Jun 16, 2015 at 5:47 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 No change in behaviour; bootstrapped and tested as usual.  Is this okay
 for trunk?

 Now the output modifier %b is unused; what do we do with that?
 Leave it in place in case anything uses it in inline asm?  It never
 was documented.  We could use some freed modifiers, almost everything
 is used now (there are only 52 possible ones).

Okay.

Does GMP use %b?  Otherwise we can probably recycle it.

Thanks, David


Re: [PATCH] Refactoring: use std::swap instead of manual swaps (part 2)

2015-06-16 Thread Uros Bizjak
Hello!

 The attached patch replaces manual swaps (i.e. tmp = a; a = b; b =
 tmp;) with std::swap. It also removes a couple of static functions
 which were used only for implementing such swaps.

 Bootstrapped/regtested on x86_64-linux; full target list build in
 progress. OK for trunk?

According to [1], patches that convert to std::swap are considered as
obvious and don't need approval. If there is a non-trivial part,
please split it to a separate patch for an eventual discussion.

[1] https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01620.html

Uros.


Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Richard Biener
On June 15, 2015 7:31:37 PM GMT+02:00, Marc Glisse marc.gli...@inria.fr wrote:
On Mon, 15 Jun 2015, Martin Liška wrote:

 Ah, I overlooked that it's not a placement new, but just static
casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T*
pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call
to ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void*
cselib_val::operator new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2
provided

#include new

Please include that from system.h

Richard.




Re: [C++/58583] ICE instantiating NSDMIs

2015-06-16 Thread Andreas Schwab
Nathan Sidwell nat...@acm.org writes:

   PR c++/58583
   * g++.dg/cpp0x/nsdmi-template14.C: New test.

spawn -ignore SIGHUP 
/usr/local/gcc/gcc-20150616/Build/gcc/testsuite/g++2/../../xg++ 
-B/usr/local/gcc/gcc-20150616/Build/gcc/testsuite/g++2/../../ 
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C 
-fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++ 
-I/usr/local/gcc/gcc-20150616/Build/ia64-suse-linux/libstdc++-v3/include/ia64-suse-linux
 -I/usr/local/gcc/gcc-20150616/Build/ia64-suse-linux/libstdc++-v3/include 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/libsupc++ 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/include/backward 
-I/usr/local/gcc/gcc-20150616/libstdc++-v3/testsuite/util -fmessage-length=0 
-std=c++11 -pedantic-errors -Wno-long-long -S -o nsdmi-template14.s.
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C:14:6: 
error: recursive instantiation of non-static data member initializer for 
'B1::p'.
compiler exited with status 1
output is:
/usr/local/gcc/gcc-20150616/gcc/testsuite/g++.dg/cpp0x/nsdmi-template14.C:14:6: 
error: recursive instantiation of non-static data member initializer for 
'B1::p'.

FAIL: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 4)
FAIL: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 6)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11  (test for errors, line 14)
PASS: g++.dg/cpp0x/nsdmi-template14.C  -std=c++11 (test for excess errors)

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
And now for something completely different.


[01/13] Move hash traits to their own header file

2015-06-16 Thread Richard Sandiford
This patch just moves the traits classes to their own header file,
hash-traits.h.

gcc/
* hash-table.h: Include hash-traits.h.
(typed_free_remove, typed_noop_remove, pointer_hash, ggc_hasher)
(ggc_cache_hasher): Move to...
* hash-traits.h: ...this new file.

Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-15 16:04:44.775663659 +0100
+++ gcc/hash-table.h2015-06-15 16:04:44.771663705 +0100
@@ -81,7 +81,7 @@ Software Foundation; either version 3, o
We compose this into a few steps.
 
   1. Decide on a removal policy for values stored in the table.
- This header provides class templates for the two most common
+ hash-traits.h provides class templates for the two most common
  policies.
 
  * typed_free_remove implements the static 'remove' member function
@@ -202,6 +202,7 @@ #define TYPED_HASHTAB_H
 #include hashtab.h
 #include inchash.h
 #include mem-stats-traits.h
+#include hash-traits.h
 #include hash-map-traits.h
 
 templatetypename, typename, typename class hash_map;
@@ -238,143 +239,6 @@ xcallocator Type::data_free (Type *mem
 }
 
 
-/* Helpful type for removing with free.  */
-
-template typename Type
-struct typed_free_remove
-{
-  static inline void remove (Type *p);
-};
-
-
-/* Remove with free.  */
-
-template typename Type
-inline void
-typed_free_remove Type::remove (Type *p)
-{
-  free (p);
-}
-
-
-/* Helpful type for a no-op remove.  */
-
-template typename Type
-struct typed_noop_remove
-{
-  static inline void remove (Type *p);
-};
-
-
-/* Remove doing nothing.  */
-
-template typename Type
-inline void
-typed_noop_remove Type::remove (Type *p ATTRIBUTE_UNUSED)
-{
-}
-
-
-/* Pointer hash with a no-op remove method.  */
-
-template typename Type
-struct pointer_hash : typed_noop_remove Type
-{
-  typedef Type *value_type;
-  typedef Type *compare_type;
-
-  static inline hashval_t hash (const value_type );
-
-  static inline bool equal (const value_type existing,
-   const compare_type candidate);
-};
-
-template typename Type
-inline hashval_t
-pointer_hash Type::hash (const value_type candidate)
-{
-  /* This is a really poor hash function, but it is what the current code uses,
- so I am reusing it to avoid an additional axis in testing.  */
-  return (hashval_t) ((intptr_t)candidate  3);
-}
-
-template typename Type
-inline bool
-pointer_hash Type::equal (const value_type existing,
-  const compare_type candidate)
-{
-  return existing == candidate;
-}
-
-/* Hasher for entry in gc memory.  */
-
-templatetypename T
-struct ggc_hasher
-{
-  typedef T value_type;
-  typedef T compare_type;
-
-  static void remove (T) {}
-
-  static void
-  ggc_mx (T p)
-  {
-extern void gt_ggc_mx (T );
-gt_ggc_mx (p);
-  }
-
-  static void
-  pch_nx (T p)
-  {
-  extern void gt_pch_nx (T );
-  gt_pch_nx (p);
-  }
-
-  static void
-  pch_nx (T p, gt_pointer_operator op, void *cookie)
-  {
-op (p, cookie);
-  }
-};
-
-/* Hasher for cache entry in gc memory.  */
-
-templatetypename T
-struct ggc_cache_hasher
-{
-  typedef T value_type;
-  typedef T compare_type;
-
-  static void remove (T ) {}
-
-  /* Entries are weakly held because this is for caches.  */
-
-  static void ggc_mx (T ) {}
-
-  static void
-  pch_nx (T p)
-  {
-  extern void gt_pch_nx (T );
-  gt_pch_nx (p);
-  }
-
-  static void
-  pch_nx (T p, gt_pointer_operator op, void *cookie)
-  {
-op (p, cookie);
-  }
-
-  /* Clear out entries if they are about to be gc'd.  */
-
-  static void
-  handle_cache_entry (T e)
-  {
-if (e != HTAB_EMPTY_ENTRY  e != HTAB_DELETED_ENTRY  !ggc_marked_p (e))
-  e = static_castT (HTAB_DELETED_ENTRY);
-  }
-};
-
-
 /* Table of primes and their inversion information.  */
 
 struct prime_ent
Index: gcc/hash-traits.h
===
--- /dev/null   2015-06-02 17:27:28.541944012 +0100
+++ gcc/hash-traits.h   2015-06-15 16:04:44.771663705 +0100
@@ -0,0 +1,159 @@
+/* Traits for hashable types.
+   Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+http://www.gnu.org/licenses/.  */
+
+#ifndef hash_traits_h
+#define hash_traits_h
+
+/* Helpful type for removing with free.  */
+
+template typename Type
+struct typed_free_remove
+{
+  static inline void remove 

[PATCH][wwwdocs][obvious] Fix typo in -finline-matmul

2015-06-16 Thread Kyrill Tkachov

Hi all,

As per subject, committed the attached as obvious.

Cheers,
Kyrill
Index: htdocs/gcc-6/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/changes.html,v
retrieving revision 1.11
diff -U 3 -r1.11 changes.html
--- htdocs/gcc-6/changes.html	7 Jun 2015 10:02:28 -	1.11
+++ htdocs/gcc-6/changes.html	16 Jun 2015 08:47:28 -
@@ -61,7 +61,7 @@
   cases if front-end optimization is active.  The maximum size for
   inlining can be set to coden/code with the
   code-finline-matmul-limit=n/code option and turned off
-  with code-finine-matmul-llimit=0/code./li
+  with code-finline-matmul-llimit=0/code./li
 liThe code-Wconversion-extra/code option will warn about
   codeREAL/code constants which have excess precision for
   their kind./li


[gomp4] Generate sequential loop for OpenACC loop directive inside kernels

2015-06-16 Thread Chung-Lin Tang
This patch adjusts omp-low.c:expand_omp_for_generic() to expand to a 
sequential
loop form (without the OMP runtime calls), used for loop directives inside
OpenACC kernels constructs. Tom mentions that this allows the kernels 
parallelization
to work when '#pragma acc loop' makes the front-ends create OMP_FOR, which the
loop analysis phases don't understand.

Tested and committed to gomp-4_0-branch.

Chung-Lin

2015-06-16  Chung-Lin Tang  clt...@codesourcery.com

* omp-low.c (struct omp_region): Add inside_kernels_p field.
(expand_omp_for_generic): Adjust to generate a 'sequential' loop
when GOMP builtin arguments are BUILT_IN_NONE.
(expand_omp_for): Use expand_omp_for_generic() to generate a
non-parallelized loop for OMP_FORs inside OpenACC kernels regions.
(expand_omp): Mark inside_kernels_p field true for regions
nested inside OpenACC kernels constructs.
Index: omp-low.c
===
--- omp-low.c	(revision 224475)
+++ omp-low.c	(working copy)
@@ -161,6 +161,9 @@ struct omp_region
   /* True if this is a combined parallel+workshare region.  */
   bool is_combined_parallel;
 
+  /* True if this is nested inside an OpenACC kernels construct.  */
+  bool inside_kernels_p;
+
   /* For an OpenACC loop, the level of parallelism requested.  */
   int gwv_this;
 
@@ -6734,6 +6737,7 @@ expand_omp_for_generic (struct omp_region *region,
   gassign *assign_stmt;
   bool in_combined_parallel = is_combined_parallel (region);
   bool broken_loop = region-cont == NULL;
+  bool seq_loop = (!start_fn || !next_fn);
   edge e, ne;
   tree *counts = NULL;
   int i;
@@ -6821,8 +6825,21 @@ expand_omp_for_generic (struct omp_region *region,
 			zero_iter_bb));
 	}
 }
-  if (in_combined_parallel)
+  if (seq_loop)
 {
+  tree n1 = fold_convert (fd-iter_type, fd-loop.n1);
+  tree n2 = fold_convert (fd-iter_type, fd-loop.n2);
+
+  assign_stmt = gimple_build_assign (istart0, n1);
+  gsi_insert_before (gsi, assign_stmt, GSI_SAME_STMT);
+
+  assign_stmt = gimple_build_assign (iend0, n2);
+  gsi_insert_before (gsi, assign_stmt, GSI_SAME_STMT);
+
+  t = fold_build2 (NE_EXPR, boolean_type_node, istart0, iend0);
+}
+  else if (in_combined_parallel)
+{
   /* In a combined parallel loop, emit a call to
 	 GOMP_loop_foo_next.  */
   t = build_call_expr (builtin_decl_explicit (next_fn), 2,
@@ -7007,32 +7024,38 @@ expand_omp_for_generic (struct omp_region *region,
 	collapse_bb = extract_omp_for_update_vars (fd, cont_bb, l1_bb);
 
   /* Emit code to get the next parallel iteration in L2_BB.  */
-  gsi = gsi_start_bb (l2_bb);
+  if (!seq_loop)
+	{
+	  gsi = gsi_start_bb (l2_bb);
 
-  t = build_call_expr (builtin_decl_explicit (next_fn), 2,
-			   build_fold_addr_expr (istart0),
-			   build_fold_addr_expr (iend0));
-  t = force_gimple_operand_gsi (gsi, t, true, NULL_TREE,
-false, GSI_CONTINUE_LINKING);
-  if (TREE_TYPE (t) != boolean_type_node)
-	t = fold_build2 (NE_EXPR, boolean_type_node,
-			 t, build_int_cst (TREE_TYPE (t), 0));
-  gcond *cond_stmt = gimple_build_cond_empty (t);
-  gsi_insert_after (gsi, cond_stmt, GSI_CONTINUE_LINKING);
+	  t = build_call_expr (builtin_decl_explicit (next_fn), 2,
+			   build_fold_addr_expr (istart0),
+			   build_fold_addr_expr (iend0));
+	  t = force_gimple_operand_gsi (gsi, t, true, NULL_TREE,
+	false, GSI_CONTINUE_LINKING);
+	  if (TREE_TYPE (t) != boolean_type_node)
+	t = fold_build2 (NE_EXPR, boolean_type_node,
+			 t, build_int_cst (TREE_TYPE (t), 0));
+	  gcond *cond_stmt = gimple_build_cond_empty (t);
+	  gsi_insert_after (gsi, cond_stmt, GSI_CONTINUE_LINKING);
+	}
 }
 
   /* Add the loop cleanup function.  */
   gsi = gsi_last_bb (exit_bb);
-  if (gimple_omp_return_nowait_p (gsi_stmt (gsi)))
-t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT);
-  else if (gimple_omp_return_lhs (gsi_stmt (gsi)))
-t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_CANCEL);
-  else
-t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END);
-  gcall *call_stmt = gimple_build_call (t, 0);
-  if (gimple_omp_return_lhs (gsi_stmt (gsi)))
-gimple_call_set_lhs (call_stmt, gimple_omp_return_lhs (gsi_stmt (gsi)));
-  gsi_insert_after (gsi, call_stmt, GSI_SAME_STMT);
+  if (!seq_loop)
+{
+  if (gimple_omp_return_nowait_p (gsi_stmt (gsi)))
+	t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT);
+  else if (gimple_omp_return_lhs (gsi_stmt (gsi)))
+	t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_CANCEL);
+  else
+	t = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END);
+  gcall *call_stmt = gimple_build_call (t, 0);
+  if (gimple_omp_return_lhs (gsi_stmt (gsi)))
+	gimple_call_set_lhs (call_stmt, gimple_omp_return_lhs (gsi_stmt (gsi)));
+  gsi_insert_after (gsi, call_stmt, GSI_SAME_STMT);
+}
   gsi_remove (gsi, true);
 
   /* Connect the new 

Re: [PING^3] [PATCH] [AArch64, NEON] Improve vmulX intrinsics

2015-06-16 Thread James Greenhalgh
On Tue, May 05, 2015 at 02:14:16PM +0100, Jiangjiji wrote:
 Hi James,
 
 Thanks for your comment.
 
 Seems we need a 'dup' before 'fmul' if we use the GCC vector extension syntax 
 way.
 
 Example:
 dup v1.2s, v1.s[0]
 fmulv0.2s, v1.2s, v0.2s
 
 And we need another pattern to combine this two insns into 'fmul
 %0.2s,%1.2s,%2.s[0]', which is kind of complex.

This would be the best way to handle the intrinsic - then we can
potentially make a nice optimization of lots of additional code. I
think it would be best if we add that extra pattern to combine the two
instructions, then write the intrinsic as __a * __b.

Looking at the pattern you propose to add for vmul_n_f32, I'm not sure
why this does not currently work, maybe it is just as simple as swapping
the operand order in:

+(define_insn aarch64_mul_nmode
+  [(set (match_operand:VMUL 0 register_operand =w)
+(mult:VMUL
+  (match_operand:VMUL 1 register_operand w)
+  (vec_duplicate:VMUL
+(match_operand:VEL 2 register_operand h_con]
+  TARGET_SIMD
+  fmul\t%0.Vtype, %1.Vtype, %2.Vetype[0]
+  [(set_attr type neon_mul_Vetype_long)]
+)
+

To look like:

+(define_insn aarch64_mul_nmode
+  [(set (match_operand:VMUL 0 register_operand =w)
+(mult:VMUL
+  (vec_duplicate:VMUL
+(match_operand:VEL 2 register_operand h_con))
+  (match_operand:VMUL 1 register_operand w)))]
+  TARGET_SIMD
+  fmul\t%0.Vtype, %1.Vtype, %2.Vetype[0]
+  [(set_attr type neon_mul_Vetype_long)]
+)
+

Which I think better matches the canonicalization rules for combine?


 BTW: maybe it's better to reconsider this issue after this patch, right?

Maybe, but I'd rather see this done now rather than later. Otherwise,
we have to add and remove the 

If you want to split your patch in to two parts, one part for the
vmul_n_* intrinsics, and one part for the other intrinsics, then I'd be
happy to review them as two separate patches.

Thanks,
James

 On Sat, Apr 11, 2015 at 11:37:47AM +0100, Jiangjiji wrote:
  Hi,
This is a ping for: 
  https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00772.html
Regtested with aarch64-linux-gnu on QEMU.
This patch has no regressions for aarch64_be-linux-gnu big-endian target 
  too.
OK for the trunk?
  
  Thanks.
  Jiang jiji
  
  
  --
  Re: [PING^2] [PATCH] [AArch64, NEON] Improve vmulX intrinsics
  
  Hi, Kyrill
Thank you for your suggestion.
I fixed it and regtested with aarch64-linux-gnu on QEMU.
This patch has no regressions for aarch64_be-linux-gnu big-endian target 
  too.
OK for the trunk?
 
 Hi Jiang,
 
 I'm sorry that I've taken so long to get to this, I've been out of office for 
 several weeks. I have one comment.
 
  +__extension__ static __inline float32x2_t __attribute__ 
  +((__always_inline__))
  +vmul_n_f32 (float32x2_t __a, float32_t __b) {
  +  return __builtin_aarch64_mul_nv2sf (__a, __b); }
  +
 
 For vmul_n_* intrinsics, is there a reason we don't want to use the GCC 
 vector extension syntax to allow us to write these as:
 
   __extension__ static __inline float32x2_t __attribute__ 
 ((__always_inline__))
   vmul_n_f32 (float32x2_t __a, float32_t __b)
   {
 return __a * __b;
   }
 
 It would be great if we could make that work.
 
 Thanks,
 James
 


Re: [gomp4] Generate sequential loop for OpenACC loop directive inside kernels

2015-06-16 Thread Tom de Vries

On 16/06/15 10:59, Chung-Lin Tang wrote:

This patch adjusts omp-low.c:expand_omp_for_generic() to expand to a 
sequential
loop form (without the OMP runtime calls), used for loop directives inside
OpenACC kernels constructs. Tom mentions that this allows the kernels 
parallelization
to work when '#pragma acc loop' makes the front-ends create OMP_FOR, which the
loop analysis phases don't understand.

Tested and committed to gomp-4_0-branch.



Hi Chung-Lin,

can you commit a test-case to exercise the code?

Thanks,
- Tom


Chung-Lin

2015-06-16  Chung-Lin Tang  clt...@codesourcery.com

 * omp-low.c (struct omp_region): Add inside_kernels_p field.
 (expand_omp_for_generic): Adjust to generate a 'sequential' loop
 when GOMP builtin arguments are BUILT_IN_NONE.
 (expand_omp_for): Use expand_omp_for_generic() to generate a
 non-parallelized loop for OMP_FORs inside OpenACC kernels regions.
 (expand_omp): Mark inside_kernels_p field true for regions
 nested inside OpenACC kernels constructs.





[09/13] Make remaining pointer hashes inherit from a generic class

2015-06-16 Thread Richard Sandiford
This patch mops up the remaining pointer traits classes that didn't
inherit from any of the standard ones and just did their own thing.

gcc/
* cgraph.h (asmname_hasher): Inherit from ggc_ptr_hash.  Remove
redundant typedefs and members.
* coverage.c (counts_entry): Inherit from pointer_hash.  Remove
redundant typedefs.
* dwarf2out.c (cu_hash_table_entry_hasher): Likewise.
* ipa-devirt.c (odr_name_hasher): Likewise.
(polymorphic_call_target_hasher): Likewise.
* ira-costs.c (cost_classes_hasher): Likewise.
* statistics.c (stats_counter_hasher): Likewise.
* trans-mem.c (log_entry_hasher): Likewise.
* tree-ssa-dom.c (expr_elt_hasher): Likewise.
* tree-ssa-sccvn.c (vn_phi_hasher, vn_reference_hasher): Likewise.
* tree-ssa-tail-merge.c (same_succ_def): Likewise.
* var-tracking.c (variable_hasher): Likewise.
* valtrack.h (dead_debug_hash_descr): Inherit from free_ptr_hash.
Remove redundant typedefs and members.

Index: gcc/cgraph.h
===
--- gcc/cgraph.h2015-06-15 16:05:17.879281703 +0100
+++ gcc/cgraph.h2015-06-15 16:05:17.863281887 +0100
@@ -1868,17 +1868,12 @@ enum symtab_state
   FINISHED
 };
 
-struct asmname_hasher
+struct asmname_hasher : ggc_ptr_hash symtab_node
 {
-  typedef symtab_node *value_type;
   typedef const_tree compare_type;
 
   static hashval_t hash (symtab_node *n);
   static bool equal (symtab_node *n, const_tree t);
-  static void ggc_mx (symtab_node *n);
-  static void pch_nx (symtab_node *);
-  static void pch_nx (symtab_node *, gt_pointer_operator, void *);
-  static void remove (symtab_node *) {}
 };
 
 class GTY((tag (SYMTAB))) symbol_table
@@ -2188,28 +2183,6 @@ asmname_hasher::equal (symtab_node *n, c
   return symbol_table::decl_assembler_name_equal (n-decl, t);
 }
 
-extern void gt_ggc_mx (symtab_node *);
-
-inline void
-asmname_hasher::ggc_mx (symtab_node *n)
-{
-  gt_ggc_mx (n);
-}
-
-extern void gt_pch_nx (symtab_node *);
-
-inline void
-asmname_hasher::pch_nx (symtab_node *n)
-{
-  gt_pch_nx (n);
-}
-
-inline void
-asmname_hasher::pch_nx (symtab_node *n, gt_pointer_operator op, void *cookie)
-{
-  op (n, cookie);
-}
-
 /* In cgraph.c  */
 void cgraph_c_finalize (void);
 void release_function_body (tree);
Index: gcc/coverage.c
===
--- gcc/coverage.c  2015-06-15 16:05:17.879281703 +0100
+++ gcc/coverage.c  2015-06-15 16:05:17.867281842 +0100
@@ -88,7 +88,7 @@ struct GTY((chain_next (%h.next))) cov
 };
 
 /* Counts information for a function.  */
-typedef struct counts_entry
+typedef struct counts_entry : pointer_hash counts_entry
 {
   /* We hash by  */
   unsigned ident;
@@ -101,8 +101,6 @@ typedef struct counts_entry
   struct gcov_ctr_summary summary;
 
   /* hash_table support.  */
-  typedef counts_entry *value_type;
-  typedef counts_entry *compare_type;
   static inline hashval_t hash (const counts_entry *);
   static int equal (const counts_entry *, const counts_entry *);
   static void remove (counts_entry *);
Index: gcc/dwarf2out.c
===
--- gcc/dwarf2out.c 2015-06-15 16:05:17.879281703 +0100
+++ gcc/dwarf2out.c 2015-06-15 16:05:17.875281749 +0100
@@ -6959,9 +6959,8 @@ struct cu_hash_table_entry
 
 /* Helpers to manipulate hash table of CUs.  */
 
-struct cu_hash_table_entry_hasher
+struct cu_hash_table_entry_hasher : pointer_hash cu_hash_table_entry
 {
-  typedef cu_hash_table_entry *value_type;
   typedef die_struct *compare_type;
   static inline hashval_t hash (const cu_hash_table_entry *);
   static inline bool equal (const cu_hash_table_entry *, const die_struct *);
Index: gcc/ipa-devirt.c
===
--- gcc/ipa-devirt.c2015-06-15 16:05:17.879281703 +0100
+++ gcc/ipa-devirt.c2015-06-15 16:05:17.875281749 +0100
@@ -385,9 +385,8 @@ type_possibly_instantiated_p (tree t)
 /* Hash used to unify ODR types based on their mangled name and for anonymous
namespace types.  */
 
-struct odr_name_hasher
+struct odr_name_hasher : pointer_hash odr_type_d
 {
-  typedef odr_type_d *value_type;
   typedef union tree_node *compare_type;
   static inline hashval_t hash (const odr_type_d *);
   static inline bool equal (const odr_type_d *, const tree_node *);
@@ -2731,10 +2730,9 @@ struct polymorphic_call_target_d
 
 /* Polymorphic call target cache helpers.  */
 
-struct polymorphic_call_target_hasher 
+struct polymorphic_call_target_hasher
+  : pointer_hash polymorphic_call_target_d
 {
-  typedef polymorphic_call_target_d *value_type;
-  typedef polymorphic_call_target_d *compare_type;
   static inline hashval_t hash (const polymorphic_call_target_d *);
   static inline bool equal (const polymorphic_call_target_d *,
const 

[10/13] Require {mark,id}_{deleted,empty} functions

2015-06-16 Thread Richard Sandiford
After the previous changes, all traits classes provide an implementation
of the empty  deleted entry functions, so we can remove the code that
provided defaults.

gcc/
* hash-table.h (has_is_deleted, is_deleted_helper): Delete.
(has_is_empty, is_empty_helper): Delete.
(has_mark_deleted, mark_deleted_helper): Delete.
(has_mark_empty, mark_empty_helper): Delete.
(hash_table::is_deleted): Call the Descriptor unconditionally.
(hash_table::is_empty): Likewise.
(hash_table::mark_deleted): Likewise.
(hash_table::mark_empty): Likewise.

Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-16 10:10:16.374654332 +0100
+++ gcc/hash-table.h2015-06-16 10:10:16.370654379 +0100
@@ -323,122 +323,6 @@ hash_table_mod2 (hashval_t hash, unsigne
   return 1 + mul_mod (hash, p-prime - 2, p-inv_m2, p-shift);
 }
 
- templatetypename Traits
- struct has_is_deleted
-{
-  templatetypename U, bool (*)(U ) struct helper {};
-  templatetypename U static char test (helperU, U::is_deleted *);
-  templatetypename U static int test (...);
-  static const bool value = sizeof (testTraits (0)) == sizeof (char);
-};
-
-templatetypename Type, typename Traits, bool = has_is_deletedTraits::value
-struct is_deleted_helper
-{
-  static inline bool
-  call (Type v)
-  {
-return Traits::is_deleted (v);
-  }
-};
-
-templatetypename Type, typename Traits
-struct is_deleted_helperType *, Traits, false
-{
-  static inline bool
-  call (Type *v)
-  {
-return v == HTAB_DELETED_ENTRY;
-  }
-};
-
- templatetypename Traits
- struct has_is_empty
-{
-  templatetypename U, bool (*)(U ) struct helper {};
-  templatetypename U static char test (helperU, U::is_empty *);
-  templatetypename U static int test (...);
-  static const bool value = sizeof (testTraits (0)) == sizeof (char);
-};
-
-templatetypename Type, typename Traits, bool = has_is_deletedTraits::value
-struct is_empty_helper
-{
-  static inline bool
-  call (Type v)
-  {
-return Traits::is_empty (v);
-  }
-};
-
-templatetypename Type, typename Traits
-struct is_empty_helperType *, Traits, false
-{
-  static inline bool
-  call (Type *v)
-  {
-return v == HTAB_EMPTY_ENTRY;
-  }
-};
-
- templatetypename Traits
- struct has_mark_deleted
-{
-  templatetypename U, void (*)(U ) struct helper {};
-  templatetypename U static char test (helperU, U::mark_deleted *);
-  templatetypename U static int test (...);
-  static const bool value = sizeof (testTraits (0)) == sizeof (char);
-};
-
-templatetypename Type, typename Traits, bool = has_is_deletedTraits::value
-struct mark_deleted_helper
-{
-  static inline void
-  call (Type v)
-  {
-Traits::mark_deleted (v);
-  }
-};
-
-templatetypename Type, typename Traits
-struct mark_deleted_helperType *, Traits, false
-{
-  static inline void
-  call (Type *v)
-  {
-v = static_castType * (HTAB_DELETED_ENTRY);
-  }
-};
-
- templatetypename Traits
- struct has_mark_empty
-{
-  templatetypename U, void (*)(U ) struct helper {};
-  templatetypename U static char test (helperU, U::mark_empty *);
-  templatetypename U static int test (...);
-  static const bool value = sizeof (testTraits (0)) == sizeof (char);
-};
-
-templatetypename Type, typename Traits, bool = has_is_deletedTraits::value
-struct mark_empty_helper
-{
-  static inline void
-  call (Type v)
-  {
-Traits::mark_empty (v);
-  }
-};
-
-templatetypename Type, typename Traits
-struct mark_empty_helperType *, Traits, false
-{
-  static inline void
-  call (Type *v)
-  {
-v = static_castType * (HTAB_EMPTY_ENTRY);
-  }
-};
-
 class mem_usage;
 
 /* User-facing hash table type.
@@ -610,23 +494,24 @@ struct mark_empty_helperType *, Traits,
   value_type *find_empty_slot_for_expand (hashval_t);
   void expand ();
   static bool is_deleted (value_type v)
-{
-  return is_deleted_helpervalue_type, Descriptor::call (v);
-}
+  {
+return Descriptor::is_deleted (v);
+  }
+
   static bool is_empty (value_type v)
-{
-  return is_empty_helpervalue_type, Descriptor::call (v);
-}
+  {
+return Descriptor::is_empty (v);
+  }
 
   static void mark_deleted (value_type v)
-{
-  return mark_deleted_helpervalue_type, Descriptor::call (v);
-}
+  {
+Descriptor::mark_deleted (v);
+  }
 
   static void mark_empty (value_type v)
-{
-  return mark_empty_helpervalue_type, Descriptor::call (v);
-}
+  {
+Descriptor::mark_empty (v);
+  }
 
   /* Table itself.  */
   typename Descriptor::value_type *m_entries;



Re: [patch 2/6] scalar-storage-order merge: C front-end

2015-06-16 Thread Andrew Pinski
On Tue, Jun 16, 2015 at 2:06 AM, Ramana Radhakrishnan
ramana.radhakrish...@foss.arm.com wrote:


 On 16/06/15 09:54, Eric Botcazou wrote:

 This is the C front-end + C family part.

 * doc/extend.texi (type attributes): Document
 scalar_storage_order.
 * doc/invoke.texi (Warnings): Document -Wno-scalar-storage-order.
 c-family/
 * c-common.c (c_common_attributes): Add scalar_storage_order.
 (handle_scalar_storage_order_attribute): New function.
 * c.opt (Wscalar-storage-order): New warning.
 c/
 * c-decl.c (finish_struct): If the structure has reverse scalar
 storage
 order, rewrite the type of array fields with scalar component.
 * c-typeck.c (build_unary_op) ADDR_EXPR: Remove left-overs.
 Issue
 errors on bit-fields and reverse SSO here and not...
 (c_mark_addressable): ...here.

   doc/extend.texi |   47 +
   doc/invoke.texi |6 +
   c-family/c.opt  |4 +++
   c-family/c-common.c |   54
 +-
   c/c-typeck.c|   53
 +++---
   c/c-decl.c  |   45 +--
   6 files changed, 175 insertions(+), 34 deletions(-)


 A very cursory glance at the patch set but should we restrict this attribute
 to apply only to scalar types rather than allow them on vector extensions.
 I haven't had enough coffee this morning but a first thought is that if it
 does apply on vector type extensions, clarifying the lane ordering up front
 would be helpful especially as we now allow indexing into short vectors.

I think it applies to vector types but really it acts the same way as
we apply attributes on arrays, that is on the inner scalar type
instead.

Thanks,
Andrew



 regards
 Ramana





Re: New type-based pool allocator code miscompiled due to aliasing issue?

2015-06-16 Thread Martin Liška
On 06/15/2015 07:31 PM, Marc Glisse wrote:
 On Mon, 15 Jun 2015, Martin Liška wrote:
 
 Ah, I overlooked that it's not a placement new, but just static casting.
 Anyway, if I added:

 cselib_val () {}

 to struct cselib_val and changed the cast to placement new:
  char *ptr = (char *) header;
  return new (ptr) T ();

 I got following compilation error:

 In file included from ../../gcc/alias.c:46:0:
 ../../gcc/alloc-pool.h: In instantiation of ‘T* 
 pool_allocatorT::allocate() [with T = cselib_val]’:
 ../../gcc/cselib.h:51:27:   required from here
 ../../gcc/alloc-pool.h:416:23: error: no matching function for call to 
 ‘cselib_val::operator new(sizetype, char*)’
   return new (ptr) T ();
   ^
 In file included from ../../gcc/alias.c:47:0:
 ../../gcc/cselib.h:49:16: note: candidate: static void* cselib_val::operator 
 new(size_t)
   inline void *operator new (size_t)
^
 ../../gcc/cselib.h:49:16: note:   candidate expects 1 argument, 2 provided
 
 #include new
 

Hi.

new header file is not missing (explicit addition of the file does not help).
Feel free to play with following patch which should fix cselib.h compilation 
error.

Thanks,
Martin
diff --git a/gcc/alloc-pool.h b/gcc/alloc-pool.h
index 1785df5..4b4bc56 100644
--- a/gcc/alloc-pool.h
+++ b/gcc/alloc-pool.h
@@ -413,7 +413,8 @@ pool_allocatorT::allocate ()
   VALGRIND_DISCARD (VALGRIND_MAKE_MEM_UNDEFINED (header, size));
 
   /* Call default constructor.  */
-  return (T *)(header);
+  char *ptr = (char *) header;
+  return new (ptr) T ();
 }
 
 /* Puts PTR back on POOL's free list.  */
diff --git a/gcc/cselib.h b/gcc/cselib.h
index cdd06ad..a0da27f 100644
--- a/gcc/cselib.h
+++ b/gcc/cselib.h
@@ -42,6 +42,9 @@ struct cselib_val
 
   struct cselib_val *next_containing_mem;
 
+  /* Default constructor.  */
+  cselib_val () {}
+
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {
@@ -67,6 +70,9 @@ struct elt_loc_list {
   /* The insn that made the equivalence.  */
   rtx_insn *setting_insn;
 
+  /* Default constructor.  */
+  elt_loc_list () {}
+
   /* Pool allocation new operator.  */
   inline void *operator new (size_t)
   {


[02/13] Replace handle_cache_entry with new interface

2015-06-16 Thread Richard Sandiford
As described in the covering note, this patch replaces handle_cache_entry
with a new function keep_cache_entry.  It also ensures that elements are
deleted using the proper function, so that m_n_deleted is updated.

I couldn't tell whether the unusual name of the function
(gt_cleare_cache) is deliberate or not, but I left it be.

gcc/ada/
* gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry):
Delete.
(value_annotation_hasher::keep_cache_entry): New function.
* gcc-interface/utils.c (pad_type_hasher::handle_cache_entry):
Delete.
(pad_type_hasher::keep_cache_entry): New function.

gcc/
* hash-table.h (hash_table): Add gt_cleare_cache as a friend.
(gt_cleare_cache): Check here for deleted and empty entries.
Replace handle_cache_entry with a call to keep_cache_entry.
* hash-traits.h (ggc_cache_hasher::handle_cache_entry): Delete.
(ggc_cache_hasher::keep_cache_entry): New function.
* trans-mem.c (tm_wrapper_hasher::handle_cache_entry): Delete.
(tm_wrapper_hasher::keep_cache_entry): New function.
* tree.h (tree_decl_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* tree.c (type_cache_hasher::handle_cache_entry): Delete.
(type_cache_hasher::keep_cache_entry): New function.
(tree_vec_map_cache_hasher::handle_cache_entry): Delete.
(tree_vec_map_cache_hasher::keep_cache_entry): New function.
* ubsan.c (tree_type_map_cache_hasher::handle_cache_entry): Delete.
(tree_type_map_cache_hasher::keep_cache_entry): New function.
* varasm.c (tm_clone_hasher::handle_cache_entry): Delete.
(tm_clone_hasher::keep_cache_entry): New function.
* config/i386/i386.c (dllimport_hasher::handle_cache_entry): Delete.
(dllimport_hasher::keep_cache_entry): New function.

Index: gcc/ada/gcc-interface/decl.c
===
--- gcc/ada/gcc-interface/decl.c2015-06-15 16:04:47.379633614 +0100
+++ gcc/ada/gcc-interface/decl.c2015-06-15 16:04:47.363633798 +0100
@@ -149,16 +149,10 @@ struct value_annotation_hasher : ggc_cac
 return a-base.from == b-base.from;
   }
 
-  static void
-  handle_cache_entry (tree_int_map *m)
+  static int
+  keep_cache_entry (tree_int_map *m)
   {
-extern void gt_ggc_mx (tree_int_map *);
-if (m == HTAB_EMPTY_ENTRY || m == HTAB_DELETED_ENTRY)
-  return;
-else if (ggc_marked_p (m-base.from))
-  gt_ggc_mx (m);
-else
-  m = static_casttree_int_map * (HTAB_DELETED_ENTRY);
+return ggc_marked_p (m-base.from);
   }
 };
 
Index: gcc/ada/gcc-interface/utils.c
===
--- gcc/ada/gcc-interface/utils.c   2015-06-15 16:04:47.379633614 +0100
+++ gcc/ada/gcc-interface/utils.c   2015-06-15 16:04:47.359633844 +0100
@@ -243,7 +243,7 @@ struct pad_type_hasher : ggc_cache_hashe
 {
   static inline hashval_t hash (pad_type_hash *t) { return t-hash; }
   static bool equal (pad_type_hash *a, pad_type_hash *b);
-  static void handle_cache_entry (pad_type_hash *);
+  static int keep_cache_entry (pad_type_hash *);
 };
 
 static GTY ((cache))
@@ -1170,16 +1170,10 @@ make_type_from_size (tree type, tree siz
 
 /* See if the data pointed to by the hash table slot is marked.  */
 
-void
-pad_type_hasher::handle_cache_entry (pad_type_hash *t)
+int
+pad_type_hasher::keep_cache_entry (pad_type_hash *t)
 {
-  extern void gt_ggc_mx (pad_type_hash *);
-  if (t == HTAB_EMPTY_ENTRY || t == HTAB_DELETED_ENTRY)
-return;
-  else if (ggc_marked_p (t-type))
-gt_ggc_mx (t);
-  else
-t = static_castpad_type_hash * (HTAB_DELETED_ENTRY);
+  return ggc_marked_p (t-type);
 }
 
 /* Return true iff the padded types are equivalent.  */
Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-15 16:04:47.379633614 +0100
+++ gcc/hash-table.h2015-06-15 16:04:47.355633890 +0100
@@ -52,6 +52,16 @@ Software Foundation; either version 3, o
  individual elements of the table need to be disposed of (e.g.,
  when deleting a hash table, removing elements from the table, etc).
 
+- An optional static function named 'keep_cache_entry'.  This
+function is provided only for garbage-collected elements that
+are not marked by the normal gc mark pass.  It describes what
+what should happen to the element at the end of the gc mark phase.
+The return value should be:
+  - 0 if the element should be deleted
+  - 1 if the element should be kept and needs to be marked
+  - -1 if the element should be kept and is already marked.
+Returning -1 rather than 1 is purely an optimization.
+
   3. The type of the hash table itself.  (More later.)
 
In very special circumstances, users 

[patch 1/6] scalar-storage-order merge: Ada front-end

2015-06-16 Thread Eric Botcazou
This is the Ada front-end (in fact gigi) part.

ada/
* gcc-interface/gigi.h (set_reverse_storage_order_on_pad_type): Declare
* gcc-interface/decl.c (gnat_to_gnu_entity) discrete_type: Set the
storage order on the enclosing record for a packed array type.
E_Array_Type: Set the storage order.
E_Array_Subtype: Likewise.
E_Record_Type: Likewise.
E_Record_Subtype: Likewise.
(gnat_to_gnu_component_type): Set the reverse storage order on a padded
type built for a non-bit-packed array.
(gnat_to_gnu_field): Likewise.
(components_to_record): Deal with TYPE_REVERSE_STORAGE_ORDER.
* gcc-interface/utils.c (make_packable_type): Likewise.
(pad_type_hasher::equal): Likewise.
(gnat_types_compatible_p): Likewise.
(unchecked_convert): Likewise.
(set_reverse_storage_order_on_pad_type): New public function.
* gcc-interface/trans.c (Attribute_to_gnu): Adjust call to
get_inner_reference.
* gcc-interface/utils2.c (build_unary_op): Likewise.
(gnat_build_constructor): Deal with TYPE_REVERSE_STORAGE_ORDER.
(gnat_rewrite_reference): Propagate the REF_REVERSE_STORAGE_ORDER flag.

 decl.c   |   49 +---
 gigi.h   |3 ++
 trans.c  |4 +--
 utils.c  |   84 +++--
 utils2.c |   15 +++
 5 files changed, 131 insertions(+), 24 deletions(-)

-- 
Eric BotcazouIndex: gcc/ada/gcc-interface/utils.c
===
--- gcc/ada/gcc-interface/utils.c	(.../trunk)	(revision 224461)
+++ gcc/ada/gcc-interface/utils.c	(.../branches/scalar-storage-order)	(revision 224467)
@@ -971,6 +971,7 @@ make_packable_type (tree type, bool in_r
   TYPE_NAME (new_type) = TYPE_NAME (type);
   TYPE_JUSTIFIED_MODULAR_P (new_type) = TYPE_JUSTIFIED_MODULAR_P (type);
   TYPE_CONTAINS_TEMPLATE_P (new_type) = TYPE_CONTAINS_TEMPLATE_P (type);
+  TYPE_REVERSE_STORAGE_ORDER (new_type) = TYPE_REVERSE_STORAGE_ORDER (type);
   if (TREE_CODE (type) == RECORD_TYPE)
 TYPE_PADDING_P (new_type) = TYPE_PADDING_P (type);
 
@@ -1195,14 +1196,15 @@ pad_type_hasher::equal (pad_type_hash *t
   type1 = t1-type;
   type2 = t2-type;
 
-  /* We consider that the padded types are equivalent if they pad the same
- type and have the same size, alignment and RM size.  Taking the mode
- into account is redundant since it is determined by the others.  */
+  /* We consider that the padded types are equivalent if they pad the same type
+ and have the same size, alignment, RM size and storage order.  Taking the
+ mode into account is redundant since it is determined by the others.  */
   return
 TREE_TYPE (TYPE_FIELDS (type1)) == TREE_TYPE (TYPE_FIELDS (type2))
  TYPE_SIZE (type1) == TYPE_SIZE (type2)
  TYPE_ALIGN (type1) == TYPE_ALIGN (type2)
- TYPE_ADA_SIZE (type1) == TYPE_ADA_SIZE (type2);
+ TYPE_ADA_SIZE (type1) == TYPE_ADA_SIZE (type2)
+ TYPE_REVERSE_STORAGE_ORDER (type1) == TYPE_REVERSE_STORAGE_ORDER (type2);
 }
 
 /* Look up the padded TYPE in the hash table and return its canonical version
@@ -1460,6 +1462,31 @@ built:
 
   return record;
 }
+
+/* Return a copy of the padded TYPE but with reverse storage order.  */
+
+tree
+set_reverse_storage_order_on_pad_type (tree type)
+{
+  tree field, canonical_pad_type;
+
+#ifdef ENABLE_CHECKING
+  /* If the inner type is not scalar then the function does nothing.  */
+  tree inner_type = TREE_TYPE (TYPE_FIELDS (type));
+  gcc_assert (!AGGREGATE_TYPE_P (inner_type));
+#endif
+
+  /* This is required for the canonicalization.  */
+  gcc_assert (TREE_CONSTANT (TYPE_SIZE (type)));
+
+  field = copy_node (TYPE_FIELDS (type));
+  type = copy_type (type);
+  DECL_CONTEXT (field) = type;
+  TYPE_FIELDS (type) = field;
+  TYPE_REVERSE_STORAGE_ORDER (type) = 1;
+  canonical_pad_type = lookup_and_insert_pad_type (type);
+  return canonical_pad_type ? canonical_pad_type : type;
+}
 
 /* Relate the alias sets of GNU_NEW_TYPE and GNU_OLD_TYPE according to OP.
If this is a multi-dimensional array type, do this recursively.
@@ -3358,7 +3385,7 @@ gnat_types_compatible_p (tree t1, tree t
 return 1;
 
   /* Array types are also compatible if they are constrained and have the same
- domain(s) and the same component type.  */
+ domain(s), the same component type and the same scalar storage order.  */
   if (code == ARRAY_TYPE
(TYPE_DOMAIN (t1) == TYPE_DOMAIN (t2)
 	  || (TYPE_DOMAIN (t1)
@@ -3369,7 +3396,8 @@ gnat_types_compatible_p (tree t1, tree t
  TYPE_MAX_VALUE (TYPE_DOMAIN (t2)
(TREE_TYPE (t1) == TREE_TYPE (t2)
 	  || (TREE_CODE (TREE_TYPE (t1)) == ARRAY_TYPE
-	   gnat_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)
+	   gnat_types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2
+   TYPE_REVERSE_STORAGE_ORDER (t1) == TYPE_REVERSE_STORAGE_ORDER (t2))
  

[05/13] Add nofree_ptr_hash

2015-06-16 Thread Richard Sandiford
This patch stops pointer_hash from inheriting typed_noop_remove and
instead creates a new class nofree_ptr_hash that inherits from both.
It then updates all uses of typed_noop_remove (which are all pointers)
and pointer_hash so that they use this new class instead.

gcc/
* hash-table.h: Update comments.
* hash-traits.h (pointer_hash): Don't inherit from typed_noop_remove.
(nofree_ptr_hash): New class.
* asan.c (asan_mem_ref_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.
* attribs.c (attribute_hasher): Likewise.
* cfg.c (bb_copy_hasher): Likewise.
* cselib.c (cselib_hasher): Likewise.
* dse.c (invariant_group_base_hasher): Likewise.
* dwarf2cfi.c (trace_info_hasher): Likewise.
* dwarf2out.c (macinfo_entry_hasher): Likewise.
(comdat_type_hasher, loc_list_hasher): Likewise.
* gcse.c (pre_ldst_expr_hasher): Likewise.
* genmatch.c (id_base): Likewise.
* genrecog.c (test_pattern_hasher): Likewise.
* gimple-ssa-strength-reduction.c (cand_chain_hasher): Likewise.
* haifa-sched.c (delay_i1_hasher): Likewise.
* hard-reg-set.h (simplifiable_subregs_hasher): Likewise.
* ipa-icf.h (congruence_class_group_hash): Likewise.
* ipa-profile.c (histogram_hash): Likewise.
* ira-color.c (allocno_hard_regs_hasher): Likewise.
* lto-streamer.h (string_slot_hasher): Likewise.
* lto-streamer.c (tree_entry_hasher): Likewise.
* plugin.c (event_hasher): Likewise.
* postreload-gcse.c (expr_hasher): Likewise.
* store-motion.c (st_expr_hasher): Likewise.
* tree-sra.c (uid_decl_hasher): Likewise.
* tree-ssa-coalesce.c (coalesce_pair_hasher): Likewise.
(ssa_name_var_hash): Likewise.
* tree-ssa-live.c (tree_int_map_hasher): Likewise.
* tree-ssa-loop-im.c (mem_ref_hasher): Likewise.
* tree-ssa-pre.c (pre_expr_d): Likewise.
* tree-ssa-sccvn.c (vn_nary_op_hasher): Likewise.
* vtable-verify.h (registration_hasher): Likewise.
* vtable-verify.c (vtbl_map_hasher): Likewise.
* config/arm/arm.c (libcall_hasher): Likewise.
* config/i386/winnt.c (wrapped_symbol_hasher): Likewise.
* config/ia64/ia64.c (bundle_state_hasher): Likewise.
* config/sol2.c (comdat_entry_hasher): Likewise.
* fold-const.c (fold): Use nofree_ptr_hash instead of pointer_hash.
(print_fold_checksum, fold_checksum_tree): Likewise.
(debug_fold_checksum, fold_build1_stat_loc): Likewise.
(fold_build2_stat_loc, fold_build3_stat_loc): Likewise.
(fold_build_call_array_loc): Likewise.
* tree-ssa-ccp.c (gimple_htab): Likewise.
* tree-browser.c (tree_upper_hasher): Inherit from nofree_ptr_hash
rather than pointer_type.

gcc/c/
* c-decl.c (detect_field_duplicates_hash): Use nofree_ptr_hash
instead of pointer_hash.
(detect_field_duplicates): Likewise.

gcc/cp/
* class.c (fixed_type_or_null_ref_ht): Inherit from nofree_ptr_hash
rather than pointer_hash.
(fixed_type_or_null): Use nofree_ptr_hash instead of pointer_hash.
* semantics.c (nrv_data): Likewise.
* tree.c (verify_stmt_tree_r, verify_stmt_tree): Likewise.

gcc/java/
* jcf-io.c (charstar_hash): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

gcc/lto/
* lto.c (tree_scc_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

gcc/objc/
* objc-act.c (decl_name_hash): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.

libcc1/
* plugin.cc (string_hasher): Inherit from nofree_ptr_hash rather
than typed_noop_remove.  Remove redudant typedefs.
(plugin_context): Use nofree_ptr_hash rather than pointer_hash.
(plugin_context::mark): Likewise.

Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-16 09:53:47.338092692 +0100
+++ gcc/hash-table.h2015-06-16 09:53:47.322092878 +0100
@@ -118,12 +118,10 @@ Software Foundation; either version 3, o
Suppose you want to put some_type into the hash table.  You could define
the descriptor type as follows.
 
-  struct some_type_hasher : typed_noop_remove some_type
-  // Deriving from typed_noop_remove means that we get a 'remove' that does
+  struct some_type_hasher : nofree_ptr_hash some_type
+  // Deriving from nofree_ptr_hash means that we get a 'remove' that does
   // nothing.  This choice is good for raw values.
   {
-typedef some_type value_type;
-typedef some_type compare_type;
 static inline hashval_t hash (const value_type *);
 static inline bool equal (const value_type *, const compare_type 

[patch 2/6] scalar-storage-order merge: C front-end

2015-06-16 Thread Eric Botcazou
This is the C front-end + C family part.

* doc/extend.texi (type attributes): Document scalar_storage_order.
* doc/invoke.texi (Warnings): Document -Wno-scalar-storage-order.
c-family/
* c-common.c (c_common_attributes): Add scalar_storage_order.
(handle_scalar_storage_order_attribute): New function.
* c.opt (Wscalar-storage-order): New warning.
c/
* c-decl.c (finish_struct): If the structure has reverse scalar storage
order, rewrite the type of array fields with scalar component.
* c-typeck.c (build_unary_op) ADDR_EXPR: Remove left-overs.  Issue
errors on bit-fields and reverse SSO here and not...
(c_mark_addressable): ...here.

 doc/extend.texi |   47 +
 doc/invoke.texi |6 +
 c-family/c.opt  |4 +++
 c-family/c-common.c |   54 +-
 c/c-typeck.c|   53 +++---
 c/c-decl.c  |   45 +--
 6 files changed, 175 insertions(+), 34 deletions(-)

-- 
Eric BotcazouIndex: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi	(.../trunk)	(revision 224461)
+++ gcc/doc/extend.texi	(.../branches/scalar-storage-order)	(revision 224467)
@@ -6064,6 +6064,53 @@ S *p = (S *)malloc (sizeof(S) + 100);
 p-data[10] = 0; //OK
 @end smallexample
 
+@item scalar_storage_order
+@itemx scalar_storage_order (@var{endianness})
+@cindex @code{scalar_storage_order} type attribute
+When attached to a @code{union} or a @code{struct}, this attribute sets
+the storage order, aka endianness, of the scalar fields of the type, as
+well as the array fields whose component is scalar.  The supported
+endianness are @code{big-endian} and @code{little-endian}.  The attribute
+has no effects on fields which are themselves a @code{union}, a @code{struct}
+or an array whose component is a @code{union} or a @code{struct}, and it is
+possible to have fields with a different scalar storage order than the
+enclosing type.
+
+This attribute is supported only for targets that use a uniform default
+scalar storage order (fortunately, most of them), i.e. targets that store
+the scalars either all in big-endian or all in little-endian.
+
+Additional restrictions are enforced for types with the reverse scalar
+storage order with regard to the scalar storage order of the target:
+
+@itemize
+@item Taking the address of a scalar field of a @code{union} or a
+@code{struct} with reverse scalar storage order is illegal and will
+yield an error
+@item Taking the address of an array field, whose component is scalar, of
+a @code{union} or a @code{struct} with reverse scalar storage order is
+permitted but will yield a warning, unless @option{-Wno-scalar-storage-order}
+is specified
+@item Taking the address of a @code{union} or a @code{struct} with reverse
+scalar storage order is permitted
+@end itemize
+
+These restrictions exist because the storage order attribute is lost when
+the address of a scalar or the address of an array with scalar component
+is taken, so storing indirectly through this address will generally not work.
+The second case is nevertheless allowed to be able to perform a block copy
+from or to the array.
+
+@item unused
+@cindex @code{unused} type attribute
+When attached to a type (including a @code{union} or a @code{struct}),
+this attribute means that variables of that type are meant to appear
+possibly unused.  GCC does not produce a warning for any variables of
+that type, even if the variable appears to do nothing.  This is often
+the case with lock or thread classes, which are usually defined and then
+not referenced, but contain constructors and destructors that have
+nontrivial bookkeeping functions.
+
 @item deprecated
 @itemx deprecated (@var{msg})
 @cindex @code{deprecated} type attribute
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(.../trunk)	(revision 224461)
+++ gcc/doc/invoke.texi	(.../branches/scalar-storage-order)	(revision 224467)
@@ -275,6 +275,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wreturn-type  -Wsequence-point  -Wshadow  -Wno-shadow-ivar @gol
 -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value @gol
 -Wsign-compare  -Wsign-conversion -Wfloat-conversion @gol
+-Wno-scalar-storage-order @gol
 -Wsizeof-pointer-memaccess  -Wsizeof-array-argument @gol
 -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol
 -Wstrict-aliasing=n @gol -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
@@ -4938,6 +4939,11 @@ This includes conversions from real to i
 real to lower precision real values.  This option is also enabled by
 @option{-Wconversion}.
 
+@item -Wno-scalar-storage-order
+@opindex -Wno-scalar-storage-order
+@opindex -Wscalar-storage-order
+Do not warn on suspicious constructs 

[06/13] Add free_ptr_hash

2015-06-16 Thread Richard Sandiford
Similarly to the last patch, this one adds a free_ptr_hash that inherits
from both pointer_hash and typed_free_remove.

gcc/
* hash-traits.h (free_ptr_hash): New class.
* dwarf2out.c (decl_table_entry_hasher): Inherit from free_ptr_hash
rather than typed_free_remove.  Remove redudant typedefs.
(external_ref_hasher): Likewise.
* except.c (action_record_hasher, ttypes_filter_hasher): Likewise.
(ehspec_hasher): Likewise.
* ggc-common.c (saving_hasher): Likewise.
* gimplify.c (gimplify_hasher): Likewise.
* haifa-sched.c (delay_i2_hasher): Likewise.
* loop-invariant.c (invariant_expr_hasher): Likewise.
* loop-iv.c (biv_entry_hasher): Likewise.
* loop-unroll.c (iv_split_hasher, var_expand_hasher): Likewise.
* trans-mem.c (tm_mem_map_hasher, tm_memop_hasher): Likewise.
* tree-cfg.c (locus_discrim_hasher): Likewise.
* tree-eh.c (finally_tree_hasher): Likewise.
* tree-into-ssa.c (var_info_hasher): Likewise.
* tree-parloops.c (reduction_hasher, name_to_copy_hasher): Likewise.
* tree-ssa-loop-ivopts.c (iv_inv_expr_hasher): Likewise.
* tree-ssa-phiopt.c (ssa_names_hasher): Likewise.
* tree-ssa-pre.c (expr_pred_trans_d): Likewise.
* tree-ssa-sccvn.c (vn_constant_hasher): Likewise.
* tree-ssa-structalias.c (equiv_class_hasher): Likewise.
(shared_bitmap_hasher): Likewise.
* tree-ssa-threadupdate.c (redirection_data): Likewise.
* tree-vectorizer.h (peel_info_hasher): Likewise.
* tree-vectorizer.c (simduid_to_vf, simd_array_to_simduid): Likewise.
* config/mips/mips.c (mips_lo_sum_offset_hasher): Likewise.

libcc1/
* plugin.cc (decl_addr_hasher): Inherit from free_ptr_hash
rather than typed_free_remove.  Remove redudant typedefs.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-16 09:55:59.084568044 +0100
+++ gcc/hash-traits.h   2015-06-16 09:55:59.084568044 +0100
@@ -173,4 +173,10 @@ struct ggc_cache_hasher : ggc_hasherT
 template typename T
 struct nofree_ptr_hash : pointer_hash T, typed_noop_remove T {};
 
+/* Traits for pointer elements that should be freed via free() when an
+   element is deleted.  */
+
+template typename T
+struct free_ptr_hash : pointer_hash T, typed_free_remove T {};
+
 #endif
Index: gcc/dwarf2out.c
===
--- gcc/dwarf2out.c 2015-06-16 09:55:59.084568044 +0100
+++ gcc/dwarf2out.c 2015-06-16 09:55:59.072568191 +0100
@@ -7296,9 +7296,8 @@ struct decl_table_entry
 
 /* Hashtable helpers.  */
 
-struct decl_table_entry_hasher : typed_free_remove decl_table_entry
+struct decl_table_entry_hasher : free_ptr_hash decl_table_entry
 {
-  typedef decl_table_entry *value_type;
   typedef die_struct *compare_type;
   static inline hashval_t hash (const decl_table_entry *);
   static inline bool equal (const decl_table_entry *, const die_struct *);
@@ -7838,10 +7837,8 @@ struct external_ref
 
 /* Hashtable helpers.  */
 
-struct external_ref_hasher : typed_free_remove external_ref
+struct external_ref_hasher : free_ptr_hash external_ref
 {
-  typedef external_ref *value_type;
-  typedef external_ref *compare_type;
   static inline hashval_t hash (const external_ref *);
   static inline bool equal (const external_ref *, const external_ref *);
 };
Index: gcc/except.c
===
--- gcc/except.c2015-06-16 09:55:59.084568044 +0100
+++ gcc/except.c2015-06-16 09:55:59.072568191 +0100
@@ -207,10 +207,8 @@ struct action_record
 
 /* Hashtable helpers.  */
 
-struct action_record_hasher : typed_free_remove action_record
+struct action_record_hasher : free_ptr_hash action_record
 {
-  typedef action_record *value_type;
-  typedef action_record *compare_type;
   static inline hashval_t hash (const action_record *);
   static inline bool equal (const action_record *, const action_record *);
 };
@@ -723,9 +721,8 @@ struct ttypes_filter {
 
 /* Helper for ttypes_filter hashing.  */
 
-struct ttypes_filter_hasher : typed_free_remove ttypes_filter
+struct ttypes_filter_hasher : free_ptr_hash ttypes_filter
 {
-  typedef ttypes_filter *value_type;
   typedef tree_node *compare_type;
   static inline hashval_t hash (const ttypes_filter *);
   static inline bool equal (const ttypes_filter *, const tree_node *);
@@ -751,10 +748,8 @@ typedef hash_tablettypes_filter_hasher
 
 /* Helper for ehspec hashing.  */
 
-struct ehspec_hasher : typed_free_remove ttypes_filter
+struct ehspec_hasher : free_ptr_hash ttypes_filter
 {
-  typedef ttypes_filter *value_type;
-  typedef ttypes_filter *compare_type;
   static inline hashval_t hash (const ttypes_filter *);
   static inline bool equal (const ttypes_filter *, const ttypes_filter *);
 };
Index: gcc/ggc-common.c

Re: [patch 2/6] scalar-storage-order merge: C front-end

2015-06-16 Thread Ramana Radhakrishnan



On 16/06/15 09:54, Eric Botcazou wrote:

This is the C front-end + C family part.

* doc/extend.texi (type attributes): Document scalar_storage_order.
* doc/invoke.texi (Warnings): Document -Wno-scalar-storage-order.
c-family/
* c-common.c (c_common_attributes): Add scalar_storage_order.
(handle_scalar_storage_order_attribute): New function.
* c.opt (Wscalar-storage-order): New warning.
c/
* c-decl.c (finish_struct): If the structure has reverse scalar storage
order, rewrite the type of array fields with scalar component.
* c-typeck.c (build_unary_op) ADDR_EXPR: Remove left-overs.  Issue
errors on bit-fields and reverse SSO here and not...
(c_mark_addressable): ...here.

  doc/extend.texi |   47 +
  doc/invoke.texi |6 +
  c-family/c.opt  |4 +++
  c-family/c-common.c |   54 +-
  c/c-typeck.c|   53 +++---
  c/c-decl.c  |   45 +--
  6 files changed, 175 insertions(+), 34 deletions(-)



A very cursory glance at the patch set but should we restrict this 
attribute to apply only to scalar types rather than allow them on vector 
extensions.  I haven't had enough coffee this morning but a first 
thought is that if it does apply on vector type extensions, clarifying 
the lane ordering up front would be helpful especially as we now allow 
indexing into short vectors.



regards
Ramana





[11/13] Generalise typed_noop_remove

2015-06-16 Thread Richard Sandiford
The traits interface is supposed to support non-pointer element types,
so there's no real reason for typed_noop_remove to be specifically for
pointers.  It should be usable by anything that wants a no-op remove().

gcc/
* hash-traits.h (typed_noop_remove): Don't require a pointer type.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-15 16:05:24.059210397 +0100
+++ gcc/hash-traits.h   2015-06-15 16:05:24.051210490 +0100
@@ -44,7 +44,7 @@ typed_free_remove Type::remove (Type *
 template typename Type
 struct typed_noop_remove
 {
-  static inline void remove (Type *p);
+  static inline void remove (Type );
 };
 
 
@@ -52,7 +52,7 @@ struct typed_noop_remove
 
 template typename Type
 inline void
-typed_noop_remove Type::remove (Type *p ATTRIBUTE_UNUSED)
+typed_noop_remove Type::remove (Type )
 {
 }
 
@@ -169,7 +169,7 @@ struct ggc_cache_remove : ggc_removeT
is deleted.  */
 
 template typename T
-struct nofree_ptr_hash : pointer_hash T, typed_noop_remove T {};
+struct nofree_ptr_hash : pointer_hash T, typed_noop_remove T * {};
 
 /* Traits for pointer elements that should be freed via free() when an
element is deleted.  */



[13/13] Update comments in hash-table.h

2015-06-16 Thread Richard Sandiford
This updates the commentary in hash-table.h for the changes in this
series and fixes some cases that were already out of date.  It also has
a couple of trivial formatting fixes.

gcc/
* hash-table.h: Update comments.

Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-15 16:05:53.294873079 +0100
+++ gcc/hash-table.h2015-06-15 16:05:53.286873170 +0100
@@ -37,15 +37,16 @@ Software Foundation; either version 3, o
  - A typedef named 'value_type' to the value type (from above).
 
  - A static member function named 'hash' that takes a value_type
- pointer and returns a hashval_t value.
+ (or 'const value_type ') and returns a hashval_t value.
 
- - A typedef named 'compare_type' that is used to test when an value
+ - A typedef named 'compare_type' that is used to test when a value
  is found.  This type is the comparison type.  Usually, it will be the
  same as value_type.  If it is not the same type, you must generally
  explicitly compute hash values and pass them to the hash table.
 
  - A static member function named 'equal' that takes a value_type
- pointer and a compare_type pointer, and returns a bool.
+ and a compare_type, and returns a bool.  Both arguments can be
+ const references.
 
  - A static function named 'remove' that takes an value_type pointer
  and frees the memory allocated by it.  This function is used when
@@ -68,7 +69,7 @@ Software Foundation; either version 3, o
 
   4. The template type used to describe how hash table memory
   is allocated.  This type is called the allocator type.  It is
-  parameterized on the value type.  It provides four functions.
+  parameterized on the value type.  It provides two functions:
 
  - A static member function named 'data_alloc'.  This function
  allocates the data elements in the table.
@@ -120,10 +121,16 @@ Software Foundation; either version 3, o
 
   2. Choose a hash function.  Write the static 'hash' member function.
 
-  3. Choose an equality testing function.  In most cases, its two
-  arguments will be value_type pointers.  If not, the first argument must
-  be a value_type pointer, and the second argument a compare_type pointer.
-
+  3. Decide whether the lookup function should take as input an object
+of type value_type or something more restricted.  Define compare_type
+accordingly.
+
+  4. Choose an equality testing function 'equal' that compares a value_type
+and a compare_type.
+
+   If your elements are pointers, it is usually easiest to start with one
+   of the generic pointer descriptors described below and override the bits
+   you need to change.
 
AN EXAMPLE DESCRIPTOR TYPE
 
@@ -163,11 +170,19 @@ Software Foundation; either version 3, o
 
EASY DESCRIPTORS FOR POINTERS
 
-   The class template pointer_hash provides everything you need to hash
-   pointers (as opposed to what they point to).  So, to instantiate a hash
-   table over pointers to whatever_type,
+   There are four descriptors for pointer elements, one for each of
+   the removal policies above:
+
+   * nofree_ptr_hash (based on typed_noop_remove)
+   * free_ptr_hash (based on typed_free_remove)
+   * ggc_ptr_hash (based on ggc_remove)
+   * ggc_cache_ptr_hash (based on ggc_cache_remove)
+
+   These descriptors hash and compare elements by their pointer value,
+   rather than what they point to.  So, to instantiate a hash table over
+   pointers to whatever_type, without freeing the whatever_types, use:
 
-  hash_table pointer_hash whatever_type whatever_type_hash_table;
+  hash_table nofree_ptr_hash whatever_type  whatever_type_hash_table;
 
 
HASH TABLE ITERATORS
@@ -327,20 +342,9 @@ hash_table_mod2 (hashval_t hash, unsigne
 
 /* User-facing hash table type.
 
-   The table stores elements of type Descriptor::value_type.
-
-   It hashes values with the hash member function.
- The table currently works with relatively weak hash functions.
- Use typed_pointer_hash Value when hashing pointers instead of objects.
-
-   It compares elements with the equal member function.
- Two elements with the same hash may not be equal.
- Use typed_pointer_equal Value when hashing pointers instead of objects.
-
-   It removes elements with the remove member function.
- This feature is useful for freeing memory.
- Derive from typed_null_remove Value when not freeing objects.
- Derive from typed_free_remove Value when doing a simple object free.
+   The table stores elements of type Descriptor::value_type and uses
+   the static descriptor functions described at the top of the file
+   to hash, compare and remove elements.
 
Specify the template Allocator to allocate and free memory.
  The default is xcallocator.
@@ -363,7 +367,6 @@ hash_table_mod2 

[patch 4/6] scalar-storage-order merge: bulk

2015-06-16 Thread Eric Botcazou
This is the bulk of the implementation.

* calls.c (store_unaligned_arguments_into_pseudos): Adjust calls to
extract_bit_field and store_bit_field.
(initialize_argument_information): Adjust call to store_expr.
(load_register_parameters): Adjust call to extract_bit_field.
* expmed.c (check_reverse_storage_order_support): New function.
(check_reverse_float_storage_order_support): Likewise.
(flip_storage_order): Likewise.
(store_bit_field_1): Add REVERSE parameter.  Flip the storage order
of the value if it is true.  Pass REVERSE to recursive call after
adjusting the target offset.
Do not use extraction or movstrict instruction if REVERSE is true.
Pass REVERSE to store_fixed_bit_field.
(store_bit_field): Add REVERSE parameter and pass to it to above.
(store_fixed_bit_field): Add REVERSE parameter and pass to it to
store_split_bit_field and store_fixed_bit_field_1.
(store_fixed_bit_field_1):  Add REVERSE parameter.  Flip the storage
order of the value if it is true and adjust the target offset.
(store_split_bit_field): Add REVERSE parameter and pass it to
store_fixed_bit_field.  Adjust the target offset if it is true.
(extract_bit_field_1): Add REVERSE parameter.  Flip the storage order
of the value if it is true.  Pass REVERSE to recursive call after
adjusting the target offset.
Do not use extraction or subreg instruction if REVERSE is true.
Pass REVERSE to extract_fixed_bit_field.
(extract_bit_field): Add REVERSE parameter and pass to it to above.
(extract_fixed_bit_field): Add REVERSE parameter and pass to it to
extract_split_bit_field and extract_fixed_bit_field_1.
(extract_fixed_bit_field_1): Add REVERSE parameter.  Flip the storage
order of the value if it is true and adjust the target offset.
(extract_split_bit_field): Add REVERSE parameter and pass it to
extract_fixed_bit_field.  Adjust the target offset if it is true.
* expmed.h (flip_storage_order): Declare.
(store_bit_field): Adjust prototype.
(extract_bit_field): Likewise.
* expr.c (emit_group_load_1): Adjust calls to extract_bit_field.
(emit_group_store): Adjust call to store_bit_field.
(copy_blkmode_from_reg): Likewise.
(copy_blkmode_to_reg): Likewise.
(write_complex_part): Likewise.
(read_complex_part): Likewise.
(optimize_bitfield_assignment_op): Add REVERSE parameter.  Assert
that it isn't true if the target is a register.
PLUS_EXPR: If it is, do not optimize unless bitsize is equal to 1,
and flip the storage order of the mask.
BIT_IOR_EXPR: Use str_mode/str_bitsize instead of more convoluted
expressions and flip the storage order of the mask.
(get_bit_range): Adjust call to get_inner_reference.
(expand_assignment): Adjust calls to get_inner_reference, store_expr,
optimize_bitfield_assignment_op and store_field.  Handle MEM_EXPRs
with reverse storage order.
(store_expr_with_bounds): Add REVERSE parameter and pass it to recursive
calls and call to store_bit_field.  Force the value into a register if
it is true and then flip the storage order of the value.
(store_expr): Add REVERSE parameter and pass it to above.
(store_constructor_field): Add REVERSE parameter and pass it to
recursive calls and call to store_field.
(store_constructor): Add REVERSE parameter and pass it to calls to
store_constructor_field and store_expr.  Set it to true for an
aggregate type with TYPE_REVERSE_STORAGE_ORDER.
(store_field): Add REVERSE parameter and pass it to recursive calls
and calls to store_expr and store_bit_field.  Temporarily flip the
storage order of the value with record type and integral mode and
adjust the shift if it is true.
(get_inner_reference): Add PREVERSEP parameter and set it to true
upon encoutering a reference with reverse storage order.
(expand_expr_addr_expr_1): Adjust call to get_inner_reference.
(expand_constructor): Adjust call to store_constructor.
(expand_expr_real_2) CASE_CONVERT: Pass TYPE_REVERSE_STORAGE_ORDER
of the union type to store_expr in the MEM case and assert that it
isn't set in the REG case.  Adjust call to store_field.
(expand_expr_real_1) MEM_REF: Handle reverse storage order.
normal_inner_ref: Add REVERSEP variable and adjust calls to
get_inner_reference and extract_bit_field. Temporarily flip the
storage order of the value with record type and integral mode and
adjust the shift if it is true.  Flip the storage order of the value
at the end if it is true.
VIEW_CONVERT_EXPR: Add REVERSEP variable and adjust call to
 

[00/13] Share hash traits between hash_table and hash_set

2015-06-16 Thread Richard Sandiford
When reviewing Mikhail's patch, I objected to another local traits for
hashing a string class.  But when I looked into it, I realised it really
is quite hard to unify the current hash traits.

At the moment we need separate traits classes for hash_table, hash_set
and hash_map.  I think that's a sign that we don't have the right
abstraction.

The aim of this series is to unify the traits for hash_table and hash_set.
If that's OK, I'll look at adding default hash_map traits for the common
case in which the deleted/empty information is stored in the key rather
than the value and where hash_table traits could be used.

There were various things I needed to change along the way:

- Our one generic hasher, pointer_hash, inherits from typed_noop_remove.
  In other words, it's specifically for cases where the pointer isn't
  freed when an entry is deleted.  That seems a bit arbitrary.  I think
  we should separate out the hashing and the removing aspects.

  Also, typed_noop_remove and typed_free_remove don't provide hashing typedefs,
  but the ggc equivalents ggc_hasher and ggc_cache_hasher do.  If we separate
  the hashing and removing aspects, the typedefs belong to the hashing side.

  This gives:

  Hashers
- the only generic one is pointer_hash, but I'll follow up with a string
  one if the series is OK

  Removers
- typed_noop_remove (as it exists now)
- typed_free_remove (as it exists now)
- ggc_remove (renamed from ggc_hasher, but without the typedefs)
- ggc_cache_remove (renamed from ggc_cache_hasher, but without the typedefs)

  These are then combined to give:
- nofree_ptr_hash
- free_ptr_hash
- ggc_ptr_hash
- ggc_cache_ptr_hash

  For this particular case, it might be cleaner to use a vec-style
  parameter for the allocator (really just freer), e.g.

hash_tablefoo, da_gc,
hash_tablefoo, da_heap

  I did try that, but it felt unnatural in the cases where the remove()
  function frees some subobject as well.  Either you have a separate
  allocator that frees both the subdata and the entry itself, or you
  have a separate (hasher?) function for freeing subdata.

  Much of the awkwardness here is due to not having proper object
  construction and destruction.  If we had that, the memory management
  would be an integral part of the element type rather than being part
  of the traits.  So I don't think adding a template parameter for the
  element remover would necessarily be forward progress.

  Although we end up with four classes for pointers, and could have at
  least three for strings, most other types have only one.

- The traits have optional is_deleted, is_empty, mark_deleted and
  mark_empty methods, with a default behaviour suitable for pointer elements.
  The methods were probably optional because many pointer traits classes
  were implemented independently, but after the change above, they can
  instead inherit from pointer_hash (or from an allocator-specific
  derivation).  It then makes sense to put the handling of empty and
  deleted pointer entries in pointer_hash and remove the complicated
  code for handling defaults.

- handle_cache_entry is too tied to the internals.  The generic
  implementation is:

static void
handle_cache_entry (T e)
{
  if (e != HTAB_EMPTY_ENTRY  e != HTAB_DELETED_ENTRY  !ggc_marked_p (e))
e = static_castT (HTAB_DELETED_ENTRY);
}

  and a typical override looks like:

void
pad_type_hasher::handle_cache_entry (pad_type_hash *t)
{
  extern void gt_ggc_mx (pad_type_hash *);
  if (t == HTAB_EMPTY_ENTRY || t == HTAB_DELETED_ENTRY)
return;
  else if (ggc_marked_p (t-type))
gt_ggc_mx (t);
  else
t = static_castpad_type_hash * (HTAB_DELETED_ENTRY);
}

  In particular, this bypasses the normal remove() function, so we never
  update m_n_deleted.

  ISTM the (single) caller should be checking for empty and deleted items
  first and handling any deletion itself.  All we want to know from the
  traits is which of the following applies:

  - the entry should be deleted
  - the entry should be kept and needs to be marked
  - the entry should be kept and is already marked (an optimisation of
the previous case).

  The patch adds a keep_cache_entry function to provide this information.

Series bootstrapped  regression-tested on x86_64-linux-gnu.  Also tested
with config-list.mk.

Thanks,
Richard



[08/13] Add a ggc_cache_ptr_hash

2015-06-16 Thread Richard Sandiford
Like the previous patch, but for ggc_cache_hasher.

gcc/
* hash-traits.h (ggc_cache_hasher): Rename to...
(ggc_cache_remove): ...this and remove typedefs.
(ggc_cache_ptr_hash): New class.
* hash-table.h: Update commentary.
* emit-rtl.c (const_int_hasher): Inherit from ggc_cache_ptr_hash
rather than ggc_cache_hasher.
(const_wide_int_hasher, reg_attr_hasher): Likewise.
(const_double_hasher, const_fixed_hasher): Likewise.
* function.c (insn_cache_hasher): Likewise.
* trans-mem.c (tm_wrapper_hasher): Likewise.
* tree.h (tree_decl_map_cache_hasher): Likewise.
* tree.c (type_cache_hasher, int_cst_hasher): Likewise.
(cl_option_hasher, tree_vec_map_cache_hasher): Likewise.
* ubsan.c (tree_type_map_cache_hasher): Likewise.
* varasm.c (tm_clone_hasher): Likewise.
* config/i386/i386.c (dllimport_hasher): Likewise.
* config/nvptx/nvptx.c (declared_libfunc_hasher): Likewise.
(tree_hasher): Likewise.

gcc/ada/
* gcc-interface/decl.c (value_annotation_hasher): Inherit from
ggc_cache_ptr_hash rather than ggc_cache_hasher.
* gcc-interface/utils.c (pad_type_hasher): Likewise.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-16 10:02:04.196341817 +0100
+++ gcc/hash-traits.h   2015-06-16 10:02:04.192341864 +0100
@@ -149,14 +149,12 @@ struct ggc_remove
   }
 };
 
-/* Hasher for cache entry in gc memory.  */
+/* Remover and marker for cache entries in gc memory.  These entries can
+   be deleted if there are no non-cache references to the data.  */
 
 templatetypename T
-struct ggc_cache_hasher : ggc_removeT
+struct ggc_cache_remove : ggc_removeT
 {
-  typedef T value_type;
-  typedef T compare_type;
-
   /* Entries are weakly held because this is for caches.  */
   static void ggc_mx (T ) {}
 
@@ -185,4 +183,11 @@ struct free_ptr_hash : pointer_hash T,
 template typename T
 struct ggc_ptr_hash : pointer_hash T, ggc_remove T * {};
 
+/* Traits for elements that point to gc memory.  The elements don't
+   in themselves keep the pointed-to data alive and they can be deleted
+   if the pointed-to data is going to be collected.  */
+
+template typename T
+struct ggc_cache_ptr_hash : pointer_hash T, ggc_cache_remove T * {};
+
 #endif
Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-16 10:02:04.196341817 +0100
+++ gcc/hash-table.h2015-06-16 10:02:40.715918847 +0100
@@ -91,7 +91,7 @@ Software Foundation; either version 3, o
We compose this into a few steps.
 
   1. Decide on a removal policy for values stored in the table.
- hash-traits.h provides class templates for the three most common
+ hash-traits.h provides class templates for the four most common
  policies:
 
  * typed_free_remove implements the static 'remove' member function
@@ -105,6 +105,13 @@ Software Foundation; either version 3, o
  Use this for garbage-collected data that needs to be preserved across
  collections.
 
+ * ggc_cache_remove is like ggc_remove, except that it does not
+ mark the entries during the normal gc mark phase.  Instead it
+ uses 'keep_cache_entry' (described above) to keep elements that
+ were not collected and delete those that were.  Use this for
+ garbage-collected caches that should not in themselves stop
+ the data from being collected.
+
  You can use these policies by simply deriving the descriptor type
  from one of those class template, with the appropriate argument.
 
Index: gcc/emit-rtl.c
===
--- gcc/emit-rtl.c  2015-06-16 10:02:04.196341817 +0100
+++ gcc/emit-rtl.c  2015-06-16 10:02:04.188341910 +0100
@@ -141,7 +141,7 @@ rtx const_tiny_rtx[4][(int) MAX_MACHINE_
 /* A hash table storing CONST_INTs whose absolute value is greater
than MAX_SAVED_CONST_INT.  */
 
-struct const_int_hasher : ggc_cache_hasherrtx
+struct const_int_hasher : ggc_cache_ptr_hashrtx_def
 {
   typedef HOST_WIDE_INT compare_type;
 
@@ -151,7 +151,7 @@ struct const_int_hasher : ggc_cache_hash
 
 static GTY ((cache)) hash_tableconst_int_hasher *const_int_htab;
 
-struct const_wide_int_hasher : ggc_cache_hasherrtx
+struct const_wide_int_hasher : ggc_cache_ptr_hashrtx_def
 {
   static hashval_t hash (rtx x);
   static bool equal (rtx x, rtx y);
@@ -160,7 +160,7 @@ struct const_wide_int_hasher : ggc_cache
 static GTY ((cache)) hash_tableconst_wide_int_hasher *const_wide_int_htab;
 
 /* A hash table storing register attribute structures.  */
-struct reg_attr_hasher : ggc_cache_hasherreg_attrs *
+struct reg_attr_hasher : ggc_cache_ptr_hashreg_attrs
 {
   static hashval_t hash (reg_attrs *x);
   static bool equal (reg_attrs *a, reg_attrs *b);
@@ -169,7 +169,7 @@ 

[12/13] Reuse hash_table traits for hash_set

2015-06-16 Thread Richard Sandiford
This is the main patch, to reuse the hash_table traits for hash_set.
The idea is to replace the untemplated default_hashset_traits with a
templated default_hash_traits, which gives the default traits for a
given type.  This allows things like hash_setvoid * to continue
to work.

For now I've left default_hash_traits without a default implementation.
It could instead be defined to inherit its argument, so that hash_set
free_ptr_hash foo  would work.  I didn't do that because I don't
have a use case, but it seems like a reasonably clean approach if
needed.

gcc/
* hash-traits.h (default_hash_traits): New structure.
* hash-set.h (default_hashset_traits): Delete.
(hash_set): Use default_hash_traitsKey instead of
default_hashset_traits.  Delete hash_entry type and use Key directly.
* ipa-devirt.c (pair_traits): Delete.
(default_hash_traits type_pair): Override.
(odr_subtypes_equivalent_p): Remove pair_types template parameter.
(odr_types_equivalent_p, add_type_duplicate): Likewise.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-16 10:12:56.580811647 +0100
+++ gcc/hash-traits.h   2015-06-16 10:12:56.576811695 +0100
@@ -190,4 +190,9 @@ struct ggc_ptr_hash : pointer_hash T,
 template typename T
 struct ggc_cache_ptr_hash : pointer_hash T, ggc_cache_remove T * {};
 
+template typename T struct default_hash_traits;
+
+template typename T
+struct default_hash_traits T * : ggc_ptr_hash T {};
+
 #endif
Index: gcc/hash-set.h
===
--- gcc/hash-set.h  2015-06-16 10:12:56.580811647 +0100
+++ gcc/hash-set.h  2015-06-16 10:12:56.572811743 +0100
@@ -21,162 +21,9 @@ Software Foundation; either version 3, o
 #ifndef hash_set_h
 #define hash_set_h
 
-/* implement default behavior for traits when types allow it.  */
-
-struct default_hashset_traits
-{
-  /* Hashes the passed in key.  */
-
-  templatetypename T
-  static hashval_t
-  hash (T *p)
-{
-  return uintptr_t (p)  3;
-}
-
-  templatetypename T static hashval_t hash(const T v) { return v; }
-
-  /* Return true if the two keys passed as arguments are equal.  */
-
-  templatetypename T
-  static bool
-  equal (const T a, const T b)
-{
-  return a == b;
-}
-
-  /* Called to dispose of the key before marking the entry as deleted.  */
-
-  templatetypename T static void remove (T v) { v.~T (); }
-
-  /* Mark the passed in entry as being deleted.  */
-
-  templatetypename T
-  static void
-  mark_deleted (T *e)
-{
-  e = reinterpret_castvoid * (1);
-}
-
-  /* Mark the passed in entry as being empty.  */
-
-  templatetypename T
-  static void
-  mark_empty (T *e)
-{
-  e = NULL;
-}
-
-  /* Return true if the passed in entry is marked as deleted.  */
-
-  templatetypename T
-  static bool
-  is_deleted (T *e)
-{
-  return e == reinterpret_castvoid * (1);
-}
-
-  /* Return true if the passed in entry is marked as empty.  */
-
-  templatetypename T static bool is_empty (T *e) { return e == NULL; }
-
-  /* ggc walking routine, mark all objects refered to by this one.  */
-
-  templatetypename T
-  static void
-  ggc_mx (T x)
-{
-  extern void gt_ggc_mx (T );
-  gt_ggc_mx (x);
-}
-
-  /* pch walking routine, note all objects refered to by this element.  */
-
-  templatetypename T
-  static void
-  pch_nx (T x)
-{
-  extern void gt_pch_nx (T );
-  gt_pch_nx (x);
-}
-};
-
-templatetypename Key, typename Traits = default_hashset_traits
+templatetypename Key, typename Traits = default_hash_traitsKey 
 class hash_set
 {
-  struct hash_entry
-  {
-Key m_key;
-
-typedef hash_entry value_type;
-typedef Key compare_type;
-
-static hashval_t hash (const hash_entry e)
-  {
-   return Traits::hash (e.m_key);
-  }
-
-static bool equal (const hash_entry a, const Key b)
-   {
- return Traits::equal (a.m_key, b);
-   }
-
-static void remove (hash_entry e) { Traits::remove (e.m_key); }
-
-static void
-mark_deleted (hash_entry e)
-  {
-   Traits::mark_deleted (e.m_key);
-  }
-
-static bool is_deleted (const hash_entry e)
-  {
-   return Traits::is_deleted (e.m_key);
-  }
-
-static void
-mark_empty (hash_entry e)
-  {
-   Traits::mark_empty (e.m_key);
-  }
-
-static bool
-is_empty (const hash_entry e)
-  {
-   return Traits::is_empty (e.m_key);
-  }
-
-static void ggc_mx (hash_entry e)
-  {
-   Traits::ggc_mx (e.m_key);
-  }
-
-static void pch_nx (hash_entry e)
-  {
-   Traits::pch_nx (e.m_key);
-  }
-
-static void pch_nx (hash_entry e, gt_pointer_operator op, void *c)
-  {
-   pch_nx_helper (e.m_key, op, c);
-  }
-
-  private:
-templatetypename T
-static void
-  pch_nx_helper 

[AArch64 Testsuite obvious] Reinstate torture-init and torture-finalize in advsimd-intrinsics.exp

2015-06-16 Thread James Greenhalgh

Hi,

advsimd-intrinsics.exp is polluting set-torture-options without
cleaning up after itself. This manifests as a failure in
aarch64-none-linux-gnu testing:

  FAIL: gcc.dg/torture/builtin-cproj-1.c   -Og -g  (test for excess errors)

This test does not expect to be called with -Og and will fail if you
do so.

There is a different question about whether we want to enable -Og
testing in dg-torture.exp , in which case this test will need patched
up. But regardless of that decision, advsimd-intrinsics.exp should
not clobber the set-torture-options without good reason.

Fixed by wrapping the main loop of advsimd-intrinsics.exp in torture-init
and torture-finish.

Tested with an aarch64-none-linux-gnu cross build to ensure it
clears the issue I was seeing.

Applied as revision 224507.

Thanks,
James

---
2015-06-16  James Greenhalgh  james.greenha...@arm.com

* gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp:
Reinstate calls to torture-init and torture-finalize.

diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp
index f57da39..ceada83 100644
--- a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp
+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp
@@ -49,6 +49,7 @@ if {[istarget arm*-*-*]} then {
 set dg-do-what-default run
 }
 
+torture-init
 set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
 
 # Make sure Neon flags are provided, if necessary.
@@ -60,4 +61,5 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \
 
 # All done.
 set dg-do-what-default ${save-dg-do-what-default}
+torture-finish
 dg-finish


[Patch Testsuite obvious] gcc.target/arm/pr65647.c should not unconditionally add -mfloat-abi=soft

2015-06-16 Thread James Greenhalgh

Hi,

This is another instance in the ARM testsuite of a test unconditionally
adding a -mfloat-abi=soft directive, which can conflict with multi-lib.

Fixed in the same way as the other recent testsuite patches.

This test also wants limiting to run on armv6-m, so check that we are
safe to do that.

Applied as obvious as r224512.

Thanks,
James

---
2015-06-16  James Greenhalgh  james.greenha...@arm.com

* gcc.target/arm/pr65647.c: Do not override -mfloat-abi directives
passed by the testsuite driver.

diff --git a/gcc/testsuite/gcc.target/arm/pr65647.c b/gcc/testsuite/gcc.target/arm/pr65647.c
index d3b44b2..26b4e39 100644
--- a/gcc/testsuite/gcc.target/arm/pr65647.c
+++ b/gcc/testsuite/gcc.target/arm/pr65647.c
@@ -1,4 +1,6 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v6m_ok } */
+/* { dg-skip-if do not override -mfloat-abi { *-*-* } { -mfloat-abi=* } {-mfloat-abi=soft } } */
 /* { dg-options -march=armv6-m -mthumb -O3 -w -mfloat-abi=soft } */
 
 a, b, c, e, g = e, h, i = 7, l = 1, m, n, o, q = m, r, s = r, u, w = 9, x,


Re: [PATCH] Fix PR 66301

2015-06-16 Thread Richard Biener
On Thu, Jun 11, 2015 at 6:34 PM, Martin Jambor mjam...@suse.cz wrote:
 Hi,

 the following patch is a quick fix for PR 66301.
 eliminate_dom_walker::before_dom_children in tree-ssa-pre.c calls
 dump_possible_polymorphic_call_targets when dump_enabled_p returns
 true, but the function assumes dump_file is not NULL while the
 predicate also returns true when alt_dump_file is not NULL (and
 dump_file is).

 There were no comments from the author of the new dumping interface in
 bugzilla and so I suggest we simply check the dump_file like almost
 everywhere else.

 Bootstrapped and tested on x86_64-linux.  I do not have a testcase
 because the one in bugzilla is biggish and it did not seem worth
 reducing.

 OK for trunk and the 5 branch?

Ok.

But I think dump_possible_polymorphic_call_targets should be ajdusted
to how dumping works now (thus _not_ pass an explicit FILE).  Eventually
this could be done with a function template wrapper

 dump_fn dump_possible_polymorphic_call_targets (MSG_NOTE, ...);

which calls dump_possible_... possibly twice.  The function template
would need to be varargs and all functions called by it need to be va-list
taking functions though...

Richard.

 Martin


 diff --git a/gcc/ChangeLog.mine b/gcc/ChangeLog.mine
 new file mode 100644
 index 000..a26c4d4
 --- /dev/null
 +++ b/gcc/ChangeLog.mine
 @@ -0,0 +1,6 @@
 +2015-06-11  Martin Jambor  mjam...@suse.cz
 +
 +   PR debug/66301
 +   * tree-ssa-pre.c (before_dom_children): Check that dump_file is not
 +   NULL instead of calling dump_enabled_p.
 +
 diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
 index 192084f..2cd0b67 100644
 --- a/gcc/tree-ssa-pre.c
 +++ b/gcc/tree-ssa-pre.c
 @@ -4381,7 +4381,7 @@ eliminate_dom_walker::before_dom_children (basic_block 
 b)
(OBJ_TYPE_REF_TOKEN 
 (fn)),
  context,
  final);
 - if (dump_enabled_p ())
 + if (dump_file)
 dump_possible_polymorphic_call_targets (dump_file,
 obj_type_ref_class 
 (fn),
 tree_to_uhwi


Re: Fix verify_type ICE with -fshort-enum

2015-06-16 Thread Richard Biener
On Fri, Jun 12, 2015 at 10:00 AM, Marek Polacek pola...@redhat.com wrote:
 On Thu, Jun 11, 2015 at 11:47:43PM +0200, Jan Hubicka wrote:
 Hi,
 gcc.c-torture/execute/930408-1.c currently ICE on -fshort-enum target(s) 
 because
 TYPE_PACKED is not consistently set among type variants.

 I guess that's because of the forward declaration in the test.  But I have
 no access to an ARM machine, so can't verify.

 Bootstrapped/regtested ppc64le-linux, OK?
 Honza

   PR middle-end/66325
   * c-decl.c (start_enum): Set TYPE_PACKED consistently among type 
 variants.
 Index: c-decl.c
 ===
 --- c-decl.c  (revision 224250)
 +++ c-decl.c  (working copy)
 @@ -7946,7 +7946,8 @@
the_enum-enum_overflow = 0;

if (flag_short_enums)
 -TYPE_PACKED (enumtype) = 1;
 +for (tree v = TYPE_MAIN_VARIANT (enumtype); v ;v = TYPE_NEXT_VARIANT 
 (v))

Though I wonder why flag_short_enums was not true when building the
(main-)variant?
Looks like -fshort-enums is also 'Optimization', so the above is bogus for

enum foo {x = 1 };

void __attribute__((optimize(short-enums))) foo()
{
  const enum foo x = 1;
}

no?  The main variant is correctly _not_ packed but now you make it
packed as you reach foo ()?

Richard.

 Please fix the formatting here: no space before ;.

 Ok with that change.

 Marek


Re: [AArch64] Fix predicate and constraint mismatch in logical atomic operations

2015-06-16 Thread Christophe Lyon
On 15 June 2015 at 14:16, Christophe Lyon christophe.l...@linaro.org wrote:
 On 8 May 2015 at 12:42, Richard Biener richard.guent...@gmail.com wrote:
 On Tue, Nov 4, 2014 at 11:44 AM, Marcus Shawcroft
 marcus.shawcr...@gmail.com wrote:
 On 25 September 2014 04:45, Michael Collison
 michael.colli...@linaro.org wrote:
 On certain patterns in atomics.md the constraint 'n' is used in combination
 with the predicate atomic_op_operand. The constraint is too general and
 allows constants that are disallowed by the predicate. This causes an ICE 
 In
 final_scan_insn when the insn cannot be split because the constraint and
 predicate do not match.

 Tested on aarch64-none-elf, aarch64-linux-gnu. Additionally the originally
 reporter of the bug, (d...@ubuntu.com), applied the patch and successfully
 bootstrapped and tested with no regressions.

 2014-09-23  Michael Collison michael.colli...@linaro.org

 * config/aarch64/iterators.md (lconst_atomic): New mode attribute to
 support constraints for CONST_INT in atomic operations.
 * config/aarch64/atomics.md
 (atomic_atomic_optabmode): Use lconst_atomic constraint.
 (atomic_nandmode): Likewise.
 (atomic_fetch_atomic_optabmode): Likewise.
 (atomic_fetch_nandmode): Likewise.
 (atomic_atomic_optab_fetchmode): Likewise.
 (atomic_nand_fetchmode): Likewise.

 OK Thanks.  /Marcus

 Can you please backport this to all release branches as well?


 Hi Richard,

 I have tested this backport against 4.8 and 4.9 branches.
 I applies cleanly in both cases, shows no regression and fixes the ICE.

 I'm afraid it's too late for committing into the 4.8 branch?

 Sorry for the delay in handling this.

 Christophe.


For the record, I have committed this backport as r224503. in the 4.9-branch.

I will commit it in the 4.8-branch when Richard confirms it's OK.


 Thanks,
 Richard.


Re: [PATCH][ARM] Add debug dumping of cost table fields

2015-06-16 Thread Kyrill Tkachov


On 27/05/15 09:39, Andrew Pinski wrote:

On Wed, May 27, 2015 at 4:38 PM, Kyrill Tkachov kyrylo.tkac...@arm.com wrote:

Ping.
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00054.html

This and the one in AARCH64 is too noisy.  Can we have an option to
turn this on and default to turning them off.


How about this? The new undocumented option can be used to turn on verbose 
costs dumping.
It is off by default.

Tested arm-none-eabi.

Ok for trunk?

Thanks,
Kyrill

2015-06-16  Kyrylo Tkachov  kyrylo.tkac...@arm.com

* config/arm/arm.c (DBG_COST): New macro.
(arm_new_rtx_costs): Use above.
* config/arm/arm.opt (mdebug-rtx-costs): New option.


Thanks,
Andrew


Thanks,
Kyrill

On 01/05/15 15:31, Kyrill Tkachov wrote:

Hi all,

This patch adds a macro to wrap cost field accesses into a helpful debug
dump,
saying which field is being accessed at what line and with what values.
This helped me track down cases where the costs were doing the wrong thing
by allowing me to see which path in arm_new_rtx_costs was taken.
For example, the combine log might now contain:

Trying 2 - 6:
Successfully matched this instruction:
(set (reg:SI 115 [ D.5348 ])
   (neg:SI (reg:SI 0 r0 [ a ])))
using extra_cost-alu.arith with cost 0 from line 10506

which can be useful in debugging the rtx costs.

Bootstrapped and tested on arm.

Ok for trunk?

Thanks,
Kyrill


2015-05-01  Kyrylo Tkachov  kyrylo.tkac...@arm.com

   * config/arm/arm.c (DBG_COST): New macro.
   (arm_new_rtx_costs): Use above.




commit 9db83ab2f7763f84445763150642fe418b06b1fe
Author: Kyrylo Tkachov kyrylo.tkac...@arm.com
Date:   Thu Apr 2 13:37:20 2015 +0100

[ARM] Add debug dumping of cost table fields.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 737d824..cae3c02 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -9322,6 +9322,12 @@ arm_unspec_cost (rtx x, enum rtx_code /* outer_code */, bool speed_p, int *cost)
 	  }\
 	while (0);
 
+
+#define DBG_COST(F) (((debug_rtx_costs	\
+		dump_file  (dump_flags  TDF_DETAILS))	\
+  ? fprintf (dump_file, using #F with cost %d from line %d\n,	\
+(F), __LINE__) : 0), (F))
+
 /* RTX costs.  Make an estimate of the cost of executing the operation
X, which is contained with an operation with code OUTER_CODE.
SPEED_P indicates whether the cost desired is the performance cost,
@@ -9422,7 +9428,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 		  + arm_address_cost (XEXP (x, 0), mode,
   ADDR_SPACE_GENERIC, speed_p));
 #else
-*cost += extra_cost-ldst.load;
+*cost += DBG_COST (extra_cost-ldst.load);
 #endif
   return true;
 
@@ -9450,11 +9456,11 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 	{
 	  HOST_WIDE_INT nregs = XVECLEN (x, 0);
 	  HOST_WIDE_INT regs_per_insn_1st = is_ldm
-	  ? extra_cost-ldst.ldm_regs_per_insn_1st
-	  : extra_cost-ldst.stm_regs_per_insn_1st;
+		? DBG_COST (extra_cost-ldst.ldm_regs_per_insn_1st)
+		: DBG_COST (extra_cost-ldst.stm_regs_per_insn_1st);
 	  HOST_WIDE_INT regs_per_insn_sub = is_ldm
-	   ? extra_cost-ldst.ldm_regs_per_insn_subsequent
-	   : extra_cost-ldst.stm_regs_per_insn_subsequent;
+		? DBG_COST (extra_cost-ldst.ldm_regs_per_insn_subsequent)
+		: DBG_COST (extra_cost-ldst.stm_regs_per_insn_subsequent);
 
 	  *cost += regs_per_insn_1st
 	   + COSTS_N_INSNS (((MAX (nregs - regs_per_insn_1st, 0))
@@ -9471,9 +9477,10 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
   if (TARGET_HARD_FLOAT  GET_MODE_CLASS (mode) == MODE_FLOAT
 	   (mode == SFmode || !TARGET_VFP_SINGLE))
 	*cost += COSTS_N_INSNS (speed_p
-			   ? extra_cost-fp[mode != SFmode].div : 0);
+			? DBG_COST (extra_cost-fp[mode != SFmode].div) : 0);
   else if (mode == SImode  TARGET_IDIV)
-	*cost += COSTS_N_INSNS (speed_p ? extra_cost-mult[0].idiv : 0);
+	*cost += COSTS_N_INSNS (speed_p ? DBG_COST (extra_cost-mult[0].idiv)
+	 : 0);
   else
 	*cost = LIBCALL_COST (2);
   return false;	/* All arguments must be in registers.  */
@@ -9489,7 +9496,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 	  *cost += (COSTS_N_INSNS (1)
 		   + rtx_cost (XEXP (x, 0), code, 0, speed_p));
 	  if (speed_p)
-	*cost += extra_cost-alu.shift_reg;
+	*cost += DBG_COST (extra_cost-alu.shift_reg);
 	  return true;
 	}
   /* Fall through */
@@ -9502,7 +9509,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 	  *cost += (COSTS_N_INSNS (2)
 		   + rtx_cost (XEXP (x, 0), code, 0, speed_p));
 	  if (speed_p)
-	*cost += 2 * extra_cost-alu.shift;
+	*cost += DBG_COST (2 * extra_cost-alu.shift);
 	  return true;
 	}
   else if (mode == SImode)
@@ -9510,7 +9517,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code,
 	  *cost += 

[PATCH][ARM][obvious] Fix gcc.target/arm/attr_thumb.c

2015-06-16 Thread Kyrill Tkachov

Hi all,

This test fails to scan for an ite block when testing a compiler configured to 
produce armv8-a code by default.
The reason the ite instruction is not produced is because the -mrestrict-it 
rules that are on by default for armv8-a
don't allow ite blocks.  This patch adds -mno-restrict-it to the test options 
to remove that restriction.

Test now passes on my arm-none-eabi compiler configured --with-arch=armv8-a.

Committed as obvious with r224504.

Cheers,
Kyrill

2015-06-16  Kyrylo Tkachov  kyrylo.tkac...@arm.com

* gcc.target/arm/attr_thumb.c: Add -mno-restrict-it to dg-options.
diff --git a/gcc/testsuite/gcc.target/arm/attr_thumb.c b/gcc/testsuite/gcc.target/arm/attr_thumb.c
index 0134021..4e98f5e 100644
--- a/gcc/testsuite/gcc.target/arm/attr_thumb.c
+++ b/gcc/testsuite/gcc.target/arm/attr_thumb.c
@@ -1,7 +1,7 @@
 /* Check that attribute target thumb is recogniwed. */
 /* { dg-do compile } */
 /* { dg-require-effective-target arm_thumb2_ok } */
-/* { dg-options -O2 } */
+/* { dg-options -O2 -mno-restrict-it } */
 /* { dg-final { scan-assembler .thumb } } */
 /* { dg-final { scan-assembler ite } } */
 


[patch 0/6] scalar-storage-order merge

2015-06-16 Thread Eric Botcazou
Hi,

I have split the diff into 6 pieces, which are interdependent and thus cannot 
be applied independently: 3 for the Ada, C and C++ front-ends, 1 for the bulk 
of the implementation, 1 for the rest and 1 for the testsuite.

It has been bootstrapped/regtested on x86_64-linux and powerpc-linux.

-- 
Eric Botcazou


Re: [PATCH, AARCH64] make stdarg functions work with +nofp

2015-06-16 Thread James Greenhalgh
On Tue, Jun 09, 2015 at 03:18:05AM +0100, Jim Wilson wrote:
 On Tue, Jun 2, 2015 at 3:45 AM, James Greenhalgh
 james.greenha...@arm.com wrote:
  On Tue, Jun 02, 2015 at 11:38:29AM +0100, Kyrill Tkachov wrote:
  Hi James, Jim,
 
  On 02/06/15 10:42, James Greenhalgh wrote:
   On Sat, May 23, 2015 at 12:24:00AM +0100, Jim Wilson wrote:
   The compiler currently ICEs when compiling a stdarg function with
   +nofp, as reported in PR 66258.
 
 I'd like approval to add this patch to the gcc-5 release branch.  I
 got two requests for this in the PR as currently grub won't build with
 gcc-5.1.  I tested the patch on the gcc-5-release branch with a
 default languages bootstrap and make check on an APM box running
 Ubuntu.  I also verified that the patch fixes my testcase.

I'm happy for this to be backported.

I think Grub probably wants to change if they want to be safe, from
what I've read it looks like they are hoping to use something like a
standard printf without touching the FP registers, which is suspect...

Thanks,
James


[03/13] Make ggc_cached_hasher inherit from ggc_hasher

2015-06-16 Thread Richard Sandiford
Most of ggc_cache_hasher is duplicated from ggc_hasher.  This patch
gets the same functionality via inheritance.  It also brings the
ggc_hasher functions in line with ggc_cache_hasher by making remove()
and ggc_mx() take references rather than pointers.  This seems more
consistent with the idea that elements don't need to be pointers and
could be some gc-ed structure instead.

gcc/
* hash-traits.h (ggc_hasher::remove): Take a reference parameter.
(ggc_hasher::ggc_mx): Likewise.
(ggc_cache_hasher): Inherit from ggc_hasher.  Remove definitions
that duplicate ggc_hasher ones.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-16 09:48:19.893867495 +0100
+++ gcc/hash-traits.h   2015-06-16 09:48:42.361611494 +0100
@@ -96,10 +96,10 @@ struct ggc_hasher
   typedef T value_type;
   typedef T compare_type;
 
-  static void remove (T) {}
+  static void remove (T ) {}
 
   static void
-  ggc_mx (T p)
+  ggc_mx (T p)
   {
 extern void gt_ggc_mx (T );
 gt_ggc_mx (p);
@@ -122,30 +122,11 @@ struct ggc_hasher
 /* Hasher for cache entry in gc memory.  */
 
 templatetypename T
-struct ggc_cache_hasher
+struct ggc_cache_hasher : ggc_hasherT
 {
-  typedef T value_type;
-  typedef T compare_type;
-
-  static void remove (T ) {}
-
   /* Entries are weakly held because this is for caches.  */
-
   static void ggc_mx (T ) {}
 
-  static void
-  pch_nx (T p)
-  {
-extern void gt_pch_nx (T );
-gt_pch_nx (p);
-  }
-
-  static void
-  pch_nx (T p, gt_pointer_operator op, void *cookie)
-  {
-op (p, cookie);
-  }
-
   static int
   keep_cache_entry (T e)
   {



[04/13] Add {mark,is}_{empty,deleted} to pointer_hash

2015-06-16 Thread Richard Sandiford
This patch just adds the standard pointer handling of empty and deleted
entries.  As the series goes on, more and more traits classes will inherit
these definitions, to the point where we can require the functions to exist.

gcc/
* hash-traits.h (pointer_hash::mark_deleted, pointer_hash::mark_empty)
(pointer_hash::is_deleted, pointer_hash::is_empty): New functions.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-15 16:04:53.375564430 +0100
+++ gcc/hash-traits.h   2015-06-15 16:04:53.371564477 +0100
@@ -66,9 +66,12 @@ struct pointer_hash : typed_noop_remove
   typedef Type *compare_type;
 
   static inline hashval_t hash (const value_type );
-
   static inline bool equal (const value_type existing,
const compare_type candidate);
+  static inline void mark_deleted (Type *);
+  static inline void mark_empty (Type *);
+  static inline bool is_deleted (Type *);
+  static inline bool is_empty (Type *);
 };
 
 template typename Type
@@ -88,6 +91,34 @@ pointer_hash Type::equal (const value_
   return existing == candidate;
 }
 
+template typename Type
+inline void
+pointer_hash Type::mark_deleted (Type *e)
+{
+  e = reinterpret_castType * (1);
+}
+
+template typename Type
+inline void
+pointer_hash Type::mark_empty (Type *e)
+{
+  e = NULL;
+}
+
+template typename Type
+inline bool
+pointer_hash Type::is_deleted (Type *e)
+{
+  return e == reinterpret_castType * (1);
+}
+
+template typename Type
+inline bool
+pointer_hash Type::is_empty (Type *e)
+{
+  return e == NULL;
+}
+
 /* Hasher for entry in gc memory.  */
 
 templatetypename T



[patch 3/6] scalar-storage-order merge: C++ front-end

2015-06-16 Thread Eric Botcazou
This is the C++ front-end part, probably incomplete but passes the testsuite.

cp/
* class.c (finish_struct_1): If structure has reverse scalar storage
order, rewrite the type of array fields with scalar component.
* semantics.c (reduced_constant_expression_p) CONSTRUCTOR: Deal with
TYPE_REVERSE_STORAGE_ORDER.
* typeck.c (structural_comptypes): Return false if two aggregate types
have different scalar storage order.
(cp_build_addr_expr_1) case COMPONENT_REF: New case.  Issue the error
for bit-fields here and not later.
case ARRAY_REF: Issue error and warning for reverse scalar storage
order.
* typeck2.c (split_nonconstant_init_1) RECORD_TYPE: Deal with
TYPE_REVERSE_STORAGE_ORDER.

 typeck.c|   44 +---
 class.c |   18 ++
 constexpr.c |   21 ++---
 typeck2.c   |8 ++--
 4 files changed, 79 insertions(+), 12 deletions(-)

-- 
Eric BotcazouIndex: gcc/cp/typeck.c
===
--- gcc/cp/typeck.c	(.../trunk)	(revision 224461)
+++ gcc/cp/typeck.c	(.../branches/scalar-storage-order)	(revision 224467)
@@ -1218,6 +1218,9 @@ structural_comptypes (tree t1, tree t2,
 return false;
   if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
 return false;
+  if (AGGREGATE_TYPE_P (t1)
+   TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2))
+return false;
 
   /* Allow for two different type nodes which have essentially the same
  definition.  Note that we already checked for equality of the type
@@ -5551,6 +5554,40 @@ cp_build_addr_expr_1 (tree arg, bool str
 	}
   break;
 
+case COMPONENT_REF:
+  if (BASELINK_P (TREE_OPERAND (arg, 1)))
+	break;
+
+  if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
+	{
+	  if (complain  tf_error)
+	error (attempt to take address of bit-field structure member %qD,
+		   TREE_OPERAND (arg, 1));
+	  return error_mark_node;
+	}
+  /* Fall through.  */
+
+case ARRAY_REF:
+  if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0
+	{
+	  if (!AGGREGATE_TYPE_P (TREE_TYPE (arg)))
+	{
+	  if (complain  tf_error)
+		error (attempt to take address of scalar with reverse 
+		   storage order);
+	  return error_mark_node;
+	}
+
+	   if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
+	TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
+	{
+	  if (complain  tf_warning)
+		warning (OPT_Wscalar_storage_order, address of array with 
+			 reverse scalar storage order requested);
+	}
+	}
+  break;
+
 case BASELINK:
   arg = BASELINK_FUNCTIONS (arg);
   /* Fall through.  */
@@ -5614,13 +5651,6 @@ cp_build_addr_expr_1 (tree arg, bool str
 	val = build2 (COMPOUND_EXPR, TREE_TYPE (val),
 		  TREE_OPERAND (arg, 0), val);
 }
-  else if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
-{
-  if (complain  tf_error)
-	error (attempt to take address of bit-field structure member %qD,
-	   TREE_OPERAND (arg, 1));
-  return error_mark_node;
-}
   else
 {
   tree object = TREE_OPERAND (arg, 0);
Index: gcc/cp/class.c
===
--- gcc/cp/class.c	(.../trunk)	(revision 224461)
+++ gcc/cp/class.c	(.../branches/scalar-storage-order)	(revision 224467)
@@ -6664,6 +6664,24 @@ finish_struct_1 (tree t)
  TREE_TYPE (x) != error_mark_node
 	 same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t))
   DECL_MODE (x) = TYPE_MODE (t);
+else if (TYPE_REVERSE_STORAGE_ORDER (t)
+	  TREE_CODE (x) == FIELD_DECL
+	  TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)
+  {
+	tree ftype = TREE_TYPE (x);
+	do
+	  ftype = TREE_TYPE (ftype);
+	while (TREE_CODE (ftype) == ARRAY_TYPE);
+	if (!RECORD_OR_UNION_TYPE_P (ftype))
+	  {
+	tree *ftypep = TREE_TYPE (x);
+	do {
+	  *ftypep = build_distinct_type_copy (*ftypep);
+	  TYPE_REVERSE_STORAGE_ORDER (*ftypep) = 1;
+	  ftypep = TREE_TYPE (*ftypep);
+	} while (TREE_CODE (*ftypep) == ARRAY_TYPE);
+	  }
+  }
 
   /* Done with FIELDS...now decide whether to sort these for
  faster lookups later.
Index: gcc/cp/constexpr.c
===
--- gcc/cp/constexpr.c	(.../trunk)	(revision 224461)
+++ gcc/cp/constexpr.c	(.../branches/scalar-storage-order)	(revision 224467)
@@ -1438,10 +1438,25 @@ reduced_constant_expression_p (tree t)
 
 case CONSTRUCTOR:
   /* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR.  */
-  tree elt; unsigned HOST_WIDE_INT idx;
+  tree elt, reloc; unsigned HOST_WIDE_INT idx;
   FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, elt)
-	if (!reduced_constant_expression_p (elt))
-	  return false;
+	switch (TREE_CODE (elt))
+	  {
+	  case PTRMEM_CST:
+	break;
+	  case CONSTRUCTOR:
+	if (!reduced_constant_expression_p (elt))
+	

[07/13] Add ggc_ptr_hash

2015-06-16 Thread Richard Sandiford
This patch renames ggc_hasher to ggc_remove and removes the typedefs,
to make it provide the same kind of interface as typed_noop_remove and
typed_free_remove.  It then defines a new class ggc_ptr_hash that
inherits from both pointer_hash and ggc_remove.  It changes all uses of
ggc_hasher to use ggc_ptr_hash instead.

gcc/
* hash-traits.h (ggc_hasher): Rename to...
(ggc_remover): ...this and remove typedefs.
(ggc_cache_hasher): Update accordingly.  Add typedefs.
(ggc_ptr_hash): New class.
* hash-table.h: Update comment.
* cfgloop.h (loop_exit_hasher): Inherit from ggc_ptr_hash rather than
ggc_hasher.
* cgraph.h (section_name_hasher, cgraph_edge_hasher): Likewise.
(tree_descriptor_hasher): Likewise.
* cgraph.c (function_version_hasher): Likewise.
* dwarf2out.c (indirect_string_hasher, dwarf_file_hasher): Likewise.
(decl_die_hasher, block_die_hasher, decl_loc_hasher): Likewise.
(dw_loc_list_hasher, addr_hasher): Likewise.
* function.h (used_type_hasher): Likewise.
* function.c (temp_address_hasher): Likewise.
* gimple-ssa.h (tm_restart_hasher, ssa_name_hasher): Likewise.
* libfuncs.h (libfunc_hasher): Likewise.
* lto-streamer.h (decl_state_hasher): Likewise.
* optabs.c (libfunc_decl_hasher): Likewise.
* tree-scalar-evolution.c (scev_info_hasher): Likewise.
* varasm.c (section_hasher, object_block_hasher): Likewise.
(const_rtx_desc_hasher): Likewise.
* config/darwin.c (indirection_hasher, cfstring_hasher): Likewise.
* config/rs6000/rs6000.c (toc_hasher, builtin_hasher): Likewise.

gcc/c-family/
* c-common.c (c_type_hasher): Inherit from ggc_ptr_hash rather than
ggc_hasher.

gcc/cp/
* constexpr.c (constexpr_fundef_hasher): Inherit from ggc_ptr_hash
rather than ggc_hasher.
(constexpr_call_hasher): Likewise.
* cp-tree.h (cxx_int_tree_map_hasher, named_label_hasher): Likewise.
* decl.c (typename_hasher): Likewise.
* mangle.c (conv_type_hasher): Likewise.
* pt.c (spec_hasher): Likewise.
* tree.c (cplus_array_hasher, list_hasher): Likewise.
* typeck2.c (abstract_type_hasher): Likewise.

gcc/fortran/
* trans-decl.c (module_hasher): Likewise.
* trans.h (module_decl_hasher): Likewise.

gcc/java/
* java-tree.h (treetreehasher): Inherit from ggc_ptr_hash
rather than ggc_hasher.
(ict_hasher, type_assertion_hasher): Likewise.

gcc/objc/
* objc-act.c (objc_string_hasher): Inherit from ggc_ptr_hash
rather than ggc_hasher.

Index: gcc/hash-traits.h
===
--- gcc/hash-traits.h   2015-06-16 09:57:55.899216049 +0100
+++ gcc/hash-traits.h   2015-06-16 09:58:55.658524164 +0100
@@ -121,14 +121,11 @@ pointer_hash Type::is_empty (Type *e)
   return e == NULL;
 }
 
-/* Hasher for entry in gc memory.  */
+/* Remover and marker for entries in gc memory.  */
 
 templatetypename T
-struct ggc_hasher
+struct ggc_remove
 {
-  typedef T value_type;
-  typedef T compare_type;
-
   static void remove (T ) {}
 
   static void
@@ -155,8 +152,11 @@ struct ggc_hasher
 /* Hasher for cache entry in gc memory.  */
 
 templatetypename T
-struct ggc_cache_hasher : ggc_hasherT
+struct ggc_cache_hasher : ggc_removeT
 {
+  typedef T value_type;
+  typedef T compare_type;
+
   /* Entries are weakly held because this is for caches.  */
   static void ggc_mx (T ) {}
 
@@ -179,4 +179,10 @@ struct nofree_ptr_hash : pointer_hash T
 template typename T
 struct free_ptr_hash : pointer_hash T, typed_free_remove T {};
 
+/* Traits for elements that point to gc memory.  The pointed-to data
+   must be kept across collections.  */
+
+template typename T
+struct ggc_ptr_hash : pointer_hash T, ggc_remove T * {};
+
 #endif
Index: gcc/hash-table.h
===
--- gcc/hash-table.h2015-06-16 09:57:55.899216049 +0100
+++ gcc/hash-table.h2015-06-16 10:00:54.221151068 +0100
@@ -91,8 +91,8 @@ Software Foundation; either version 3, o
We compose this into a few steps.
 
   1. Decide on a removal policy for values stored in the table.
- hash-traits.h provides class templates for the two most common
- policies.
+ hash-traits.h provides class templates for the three most common
+ policies:
 
  * typed_free_remove implements the static 'remove' member function
  by calling free().
@@ -100,6 +100,11 @@ Software Foundation; either version 3, o
  * typed_noop_remove implements the static 'remove' member function
  by doing nothing.
 
+ * ggc_remove implements the static 'remove' member by doing nothing,
+ but instead provides routines for gc marking and for PCH streaming.
+ Use this for garbage-collected data that needs to be preserved 

  1   2   >