public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: PPC64 HTM support (was [buildbot] r201513: Invalid cast)
@ 2013-08-06 23:36 David Edelsohn
  2013-08-07  3:01 ` Peter Bergner
  0 siblings, 1 reply; 4+ messages in thread
From: David Edelsohn @ 2013-08-06 23:36 UTC (permalink / raw)
  To: Peter Bergner; +Cc: Oleg Endo, Jan-Benedict Glaw, GCC Patches

Peter,

Would you please help answer Oleg questions about case 0 in
htm_expand_builtin in rs6000.c?

Thanks, David

Speaking of GEN_FCN usage in rs6000.c.  The recently added HTM builtin
code has one interesting piece:

static rtx
htm_expand_builtin (tree exp, rtx target, bool * expandedp)
{
...
switch (nopnds)
 {
 case 0:
   pat = GEN_FCN (icode) (NULL_RTX);
   break;
 case 1:
   pat = GEN_FCN (icode) (op[0]);
   break;

The 'case 0' looks suspicious.  If the function behind the pointer
really is a zero-arg function this might or might not work depending on
the ABI.  I'm not sure what the intention here is.  I've compiled
gcc/testsuite/gcc.target/powerpc/htm-builtin-1.c to see if it ever gets
into the 'case 0' but it doesn't.
The function 'htm_init_builtins' doesn't seem to handle a 'case 0'.  I'm
confused, somebody else should have a look at this please.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PPC64 HTM support (was [buildbot] r201513: Invalid cast)
  2013-08-06 23:36 PPC64 HTM support (was [buildbot] r201513: Invalid cast) David Edelsohn
@ 2013-08-07  3:01 ` Peter Bergner
  2013-08-07 13:23   ` Peter Bergner
  2013-08-07 19:32   ` Oleg Endo
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Bergner @ 2013-08-07  3:01 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Oleg Endo, Jan-Benedict Glaw, GCC Patches

Oleg Endo wrote:
> Speaking of GEN_FCN usage in rs6000.c.  The recently added HTM builtin
> code has one interesting piece:
> 
> static rtx
> htm_expand_builtin (tree exp, rtx target, bool * expandedp)
> {
> ...
> switch (nopnds)
>  {
>  case 0:
>    pat = GEN_FCN (icode) (NULL_RTX);
>    break;
>  case 1:
>    pat = GEN_FCN (icode) (op[0]);
>    break;
> 
> The 'case 0' looks suspicious.

Yes, the "case 0:" is not needed.  It was needed at one point
when I originally modeled this code after Andreas's s390 changes.
The code then passed in the target rtx as a separate parameter
from the operands, so nopnds was actually zero in some cases.
I realized I could simplify the code a lot by placing the
target rtx into the op[] array along with the source operands
and at that point, the "case 0:" statements became dead code
as you discovered.  I'll bootstrap and regtest the change
below and commit it as an obvious fix when that is done.

Thanks for spotting this.

Peter


Index: rs6000.c
===================================================================
--- rs6000.c	(revision 201409)
+++ rs6000.c	(working copy)
@@ -11148,9 +11148,6 @@ htm_expand_builtin (tree exp, rtx target
 
 	switch (nopnds)
 	  {
-	  case 0:
-	    pat = GEN_FCN (icode) (NULL_RTX);
-	    break;
 	  case 1:
 	    pat = GEN_FCN (icode) (op[0]);
 	    break;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PPC64 HTM support (was [buildbot] r201513: Invalid cast)
  2013-08-07  3:01 ` Peter Bergner
@ 2013-08-07 13:23   ` Peter Bergner
  2013-08-07 19:32   ` Oleg Endo
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Bergner @ 2013-08-07 13:23 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Oleg Endo, Jan-Benedict Glaw, GCC Patches

On Tue, 2013-08-06 at 22:01 -0500, Peter Bergner wrote:
> I'll bootstrap and regtest the change
> below and commit it as an obvious fix when that is done.

Everything looked as as expected.  Committed.

Peter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PPC64 HTM support (was [buildbot] r201513: Invalid cast)
  2013-08-07  3:01 ` Peter Bergner
  2013-08-07 13:23   ` Peter Bergner
@ 2013-08-07 19:32   ` Oleg Endo
  1 sibling, 0 replies; 4+ messages in thread
From: Oleg Endo @ 2013-08-07 19:32 UTC (permalink / raw)
  To: Peter Bergner; +Cc: David Edelsohn, Jan-Benedict Glaw, GCC Patches

On Tue, 2013-08-06 at 22:01 -0500, Peter Bergner wrote:
> Oleg Endo wrote:
> > Speaking of GEN_FCN usage in rs6000.c.  The recently added HTM builtin
> > code has one interesting piece:
> > 
> > static rtx
> > htm_expand_builtin (tree exp, rtx target, bool * expandedp)
> > {
> > ...
> > switch (nopnds)
> >  {
> >  case 0:
> >    pat = GEN_FCN (icode) (NULL_RTX);
> >    break;
> >  case 1:
> >    pat = GEN_FCN (icode) (op[0]);
> >    break;
> > 
> > The 'case 0' looks suspicious.
> 
> Yes, the "case 0:" is not needed.  It was needed at one point
> when I originally modeled this code after Andreas's s390 changes.
> The code then passed in the target rtx as a separate parameter
> from the operands, so nopnds was actually zero in some cases.
> I realized I could simplify the code a lot by placing the
> target rtx into the op[] array along with the source operands
> and at that point, the "case 0:" statements became dead code
> as you discovered.  I'll bootstrap and regtest the change
> below and commit it as an obvious fix when that is done.
> 
> Thanks for spotting this.

No problem.  Thanks for the explanation.
BTW please don't forget to add documentation of the builtins.
Being a non-PPC person, I had to dig and hack in the backend to get the
HTM builtins to work for the test.  I think the binutils version that I
used (2.23.1) is too old or something.  Even though I specified the
"-mhtm" option it would complain about that I need to specify the
"-mhtm" option to use the builtins...

Cheers,
Oleg

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-07 19:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-06 23:36 PPC64 HTM support (was [buildbot] r201513: Invalid cast) David Edelsohn
2013-08-07  3:01 ` Peter Bergner
2013-08-07 13:23   ` Peter Bergner
2013-08-07 19:32   ` Oleg Endo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).